vendredi 28 novembre 2014

Incomplete trace of a function


Why the curve is not drawn to the point x1 ?



\starttext
\startMPcode
xmin := -1; xmax := 5; ymax :=4 ;ymin:=-4; u := 1cm;
pickup pencircle scaled 1pt ;
a:=2-sqrt(3);
b:=2+sqrt(3);
def compute_curve(suffix f)(expr xmin, xmax, xinc) =
((xmin,f(xmin))
for x=xmin+xinc step xinc until xmax:
.. (x,f(x))
endfor )
enddef;
vardef f(expr x) = x*x-4*x+1 enddef;
path pts_f;
pts_f := compute_curve(f, a, b, .1) scaled u;
path axe_x,axe_y;
path screen;
screen=(xmin,ymin)*u--(xmax,ymin)*u--(xmax,ymax)*u--(xmin,ymax)*u--cycle;
axe_x = (xmin,0)*u -- (xmax,0)*u;
axe_y = (0,ymin)*u -- (0,ymax)*u;
drawarrow axe_x;
drawarrow axe_y;
draw pts_f withcolor blue withpen pencircle scaled 1pt;
label.lrt(btex $x_1$ etex,(a,0)*u);
label.lrt(btex $x_2$ etex,(b,0)*u);
draw (a,0)*u withpen pencircle scaled 3bp;
draw (b,0)*u withpen pencircle scaled 3bp;
clip currentpicture to screen;
\stopMPcode
\stoptext


enter image description here





Aucun commentaire:

Enregistrer un commentaire