Previous Up Next

19.2.2  3D graph

Functions of two variables

The plotfunc can draw the graphs of two-variable function.

Examples

plotfunc(x^2+y^2,[x,y])
plotfunc(x*y,[x,y])
plotfunc([x*y-10,x*y,x*y+10],[x,y])
plotfunc(x*sin(y),[x=0..2,y=-pi..pi])

As an example where you specify the x and y discretization step with xstep and ystep:

plotfunc(x*sin(y),[x=0..2,y=-pi..pi],xstep=1,ystep=0.5)

Alternatively you can specify the number of points used for the representation of the function with nstep instead of xstep and ystep.

plotfunc(x*sin(y),[x=0..2,y=-pi..pi],nstep=300)
Remarks.

3D graph with rainbow colors

If the expression with two variables is purely imaginary, iexpr, then plotfunc will still draw the graph, but the color will depend on the height z=expr resulting in a rainbow colored surface. This provides you with an easy way to find points having the same third coordinate. For example:

plotfunc(i*x*sin(y),[x=0..2,y=-pi..pi])

“4D” graph

If expr is a complex valued expression whose real part is not identically zero on the discretization mesh, then plotfunc will draw the surface z=abs(expr), where arg(expr) determines the color from the rainbow. This gives you an easy way to see the points having the same argument. Note that if the real part of expr is zero on the discretization mesh, then it will look purely imaginary to plotfunc and will represented with rainbow colors, as in Section 19.2.2. For example:

plotfunc((x+i*y)^2,[x,y])
plotfunc((x+i*y)^2,[x,y],display=filled)

You can specify the range of variation of x and y and the number of discretization points.

plotfunc((x+i*y)^2,[x=-1..1,y=-2..2],nstep=900,display=filled)

Previous Up Next