home *** CD-ROM | disk | FTP | other *** search
- # library plot2y
- # plot2y(y,y2,x)
- # plots two functions of y=y(x) and y2=y2(x) on the same graph
- # on xy-plane by default xmin:=-5, xmax:=5, ymin:=-5, ymax:=5
- # It graphically solves a system of 2 equations so a cross of 2 curves
- # is a solution.
- # e.g. plot2y(x^2-1,x+1,x)
-
- plot2y(y_, y2_, x_, xmin_, xmax_, ymin_, ymax_) := block(numeric:=on,
- graph,
- dx:=(xmax-xmin)/getmaxx,
- dy:=(ymax-ymin)/getmaxy,
- xstep:=dx*10,
- axis(xmin,xmax,ymin,ymax),
- setcolor(colorno(yellow)),
- moveto(0,getmaxy-(subs(y,x=xmin)-ymin)/dy),
- do( lineto((x-xmin)/dx,getmaxy-(y-ymin)/dy),
- x,xmin,xmax,xstep),
- setcolor(colorno(green)),
- moveto(0,getmaxy-(subs(y2,x=xmin)-ymin)/dy),
- do( lineto((x-xmin)/dx,getmaxy-(y2-ymin)/dy),
- x,xmin,xmax,xstep),
- numeric:=off,
- readchar,
- text,
- local(dx,dy,xstep))
- plot2y(y_, y2_, x_, xmin_, xmax_) := plot2y(y,y2,x,xmin,xmax,-5,5)
- plot2y(y_, y2_, x_) := plot2y(y,y2,x,-5,5,-5,5)
-