## `plotfunc2d` -- 2D plots of function graphs

#### Introduction

`plotfunc2d``(f1, f2, ...)` generates a 2D plot of the graphs of the univariate functions `f1`, `f2` etc.

#### Call(s)

`plotfunc2d( <SceneOptions,> f1, f2, ... <, Grid = n> )`
`plotfunc2d( <SceneOptions,> f1, f2, ..., x = xmin..xmax <, Grid = n>)`
`plotfunc2d( <SceneOptions,> f1, f2, ..., x = xmin..xmax, y = ymin..ymax <, Grid = n>)`

#### Parameters

`f1, f1, ...` | - | the functions: arithmetical expressions or `piecewise` objects containing one indeterminate `x`
`x` | - | the horizontal coordinate: an identifier
`xmin, xmax` | - | the horizontal plot range: finite real numerical expressions
`y` | - | a dummy name for the vertical coordinate: an identifier. This name is used to label the y-axis.
`ymin, ymax` | - | the vertical plot range: finite real numerical expressions

#### Options

`SceneOptions` | - | a sequence of scene options. These determine the general appearance of the graphical scene. See `?plotOptions2d` for details.
`Grid = n` | - | sets the number of sample points used for the plot. The integer `n` must be larger than 1; the default is Grid = `100`.

#### Returns

MuPAD's graphics tool is called to render the graphical scene. The `null``()` object is returned to the MuPAD session.

#### Related Functions

`plot`, `plot::Function2d`, `plot2d`, `plot3d`, `plotfunc3d`

#### Details

- The functions must not contain any symbolic parameters apart from `x` that cannot be converted to floating point values.
- If no horizontal plot range is specified, the default range `x = -5..5` is used.
- If a vertical range `y = ymin..ymax` is specified, only function values between `ymin` and `ymax` are displayed. The name `y` of the vertical coordinate is arbitrary: any identifier may be used.
- Non-real function values are ignored. Cf. example 2.
- Functions with singularities are handled. Cf. example 3.
- Discontinuities and piecewise defined functions are handled. Cf. examples 5, 6.
- The graph of a function f(x) can also be plotted by `plot2d` as a parametrized curve

  `[Mode = Curve, [x, f(x)], x = [xmin, xmax] <, Options>]:`

  This way, ranges, color options and style options can be specified separately for each function. See the help page of `plot2d` for details.

- The `plot` library provides the routine `plot::Function2d` which allows to create a function graph as a graphical primitive, and to combine it with other graphical objects.
- MuPAD graphics can be saved in a variety of graphical formats. In a `plotfunc2d` command, the PlotDevice scene option allows to specify the conversion into the two MuPAD specific formats 'Ascii' and 'Binary'. See the help page `plotOptions2d` for details.

  For graphical standard formats such as Postscript, JPEG, TIFF etc., no direct conversion is available by a plot command inside a MuPAD session. Instead, conversion has to be requested interactively via the graphical interface of the rendering tool VCam. In a MuPAD Pro notebook, double click on the graphics to activate this interface. Using the menu item ``Edit/Save Graphics ..'', you can choose the desired format in the ``Export Graphics'' dialog box.

#### Option: Grid = `n`

- This option determines the number of sample points (function evaluations). The graphics uses linear interpolation between adjacent sample points. The integer `n` must be larger than 1; the default is Grid = `100`. Large values of `n` generate a smooth graph.

#### Example 1

The following command draws the sine and the cosine functions on the interval [-PI, PI]:

    >> plotfunc2d(sin(x), cos(x), x = -PI..PI):

#### Example 2

Only real functions values are plotted:

    >> plotfunc2d(sqrt(1 - x), sqrt(x), x = -2..2):

#### Example 3

The following functions have singularities in the specified interval:

    >> plotfunc2d(x/(x^3 - 4*x), x = -5..5):

    >> plotfunc2d(1/sin(x), tan(x), x = 0..2*PI):

#### Example 4

We define a vertical range to which the function graph is restricted:

    >> plotfunc2d(tan(x), x = -3..3, y = -10..10):

#### Example 5

The following function has a jump discontinuity:

    >> plotfunc2d((x^2 - x)/(2*abs(x - 1)), x = -3..3, y = -3..3)

#### Example 6

Piecewise defined functions are handled:

    >> f := piecewise([x < 1, -x^2 + 1], [x >= 1, x]):
       plotfunc2d(BackGround = RGB::White,
                  ForeGround = RGB::Black,
                  GridLines = Automatic,
                  Ticks = [Steps = 1, Steps = 1],
                  f(x), x = -3..3, y = -3..3)

    >> f := piecewise([x <= 0, x], [x > 0, 1/x]):
       plotfunc2d(BackGround = RGB::White,
                  ForeGround = RGB::Black,
                  GridLines = Automatic,
                  Ticks = [Steps = 1, Steps = 1],
                  f(x), x = -3..3, y = -3..3)

    >> delete f:

#### Example 7

We use the scene option AxesScaling to create a logarithmic plot:

    >> plotfunc2d(AxesScaling = [Lin, Log], x^2, x^3, x = 1/10..10^3):

We demonstrate various further scene options in a doubly logarithmic plot:

    >> plotfunc2d(Axes = Box,
                  AxesScaling = [Log, Log],
                  Discont = FALSE,
                  BackGround = RGB::White,
                  ForeGround = RGB::Black,
                  GridLines = Automatic,
                  GridLinesStyle = SolidLines,
                  GridLinesColor = RGB::Gray,
                  Ticks = [[10^i $ i = -1..3], [10^i $ i = -3..9]],
                  x^2, x^3/(1 + x^(1/2)), x^3, x = 1/10..10^3):

#### Changes

- used to be called `plotfunc`
- The new scene options Discont, GridLines, GridLinesColor, GridLinesStyle, GridLinesWidth, RealValuesOnly and ViewingBox were introduced. The functionality of the scene option Ticks was extended.
- The default values of various options were changed.
- Scene titles as well as object titles can now be moved interactively by the mouse.

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000