# 3-d graph

### 7.4.2 3-d graph

#### Two variable functions

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

- plotfunc takes two mandatory argument and two optional arguments:
  - expr, an expression defining a function of two variables or a list of such expressions.
  - vars, a list of the variable names, possibly with bounds. If the variable is given as var=a..b, the graph will be drawn for that range of that variable, otherwise it will be graphed over the default interval (see Section 2.5.8).
  - Optionally, xstep, which can be xstep=n to specify the discretization step in the x direction.
  - Optionally, ystep, which can be ystep=m to specify the discretization step in the y direction.
  - Instead of xstep and ystep, you could use the option nstep=n to specify the number of points used to graph.
- plotfunc(expr,vars ⟨xstep,ystep⟩) draws the graph.

#### Examples.

- Input:
  plotfunc(x^2+y^2,[x,y])
  Output:
- Input:
  plotfunc(x*y,[x,y])
  Output:
- Input:
  plotfunc([x*y-10,x*y,x*y+10],[x,y])
  Output:
- Input:
  plotfunc(x*sin(y),[x=0..2,y=-pi..pi])
  Output:
- As an example where you specify the x and y discretization step with xstep and ystep:
  Input:
  plotfunc(x*sin(y),[x=0..2,y=-pi..pi],xstep=1,ystep=0.5)
  Output:
- Alternatively you can specify the number of points used for the representation of the function with nstep instead of xstep and ystep.
  Input:
  plotfunc(x*sin(y),[x=0..2,y=-pi..pi],nstep=300)
  Output:

Remarks:

- Like any 3-d scene, the viewpoint may be modified by rotation around the x axis, the y axis or the z axis, either by dragging the mouse inside the graphic window (push the mouse outside the parallelepiped used for the representation), or with the shortcuts x, X, y, Y, z and Z.
- If you want to print a graph or get a LATEX translation, use the graph menu
  Menu▸print▸Print(with Latex)

#### 3-d 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.

#### Example.

Input:

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

Output:

#### 4-d 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 7.4.2.

#### Examples.

- Input:
  plotfunc((x+i*y)^2,[x,y])
  Output:
- Input:
  plotfunc((x+i*y)^2,[x,y], display=filled)
  Output:
- You can specify the range of variation of x and y and the number of discretization points.
  Input:
  plotfunc((x+i*y)^2,[x=-1..1,y=-2..2], nstep=900,display=filled)
  Output: