
Calling Sequence


implicitplot(expr, x=a..b, y=c(x)..d(x), options)
implicitplot(ineq, x=a..b, y=c(x)..d(x), options)
implicitplot(f, a..b, c..d, options)
implicitplot([expr1,expr2,t], x=a..b, y=c(x)..d(x), options)


Parameters


expr



expression or equation depending on x and y

ineq



inequality depending on x and y

f



equation containing procedures or operators representing a function of 2 variables

expr1,expr2



equations or expressions in x, y and t, polynomial in t

x,y,t



variables

a,b,c,d



real constants

c(x),d(x)



expressions that evaluate to real constants for a fixed x value

options



(optional) as described in the Options section, or any plot options; see plot/options





Options


This section describes options to implicitplot.
•

Any additional arguments are interpreted as options which are specified as equations of the form option = value. Most options available for the plot command can also be used with the implicitplot command. For more information, see plot/options. The options that result in specific behavior when used with implicitplot are described below.

•

The option grid = [m, n] where m and n are positive integers (larger than 1) specifies that the points used initially to plot the 2D curve lie on an m by n grid of equally spaced points in the ranges a..b and c..d respectively. By default a 26 by 26 grid is used, and thus 676 points are generated. In contrast, the numpoints = k option controls the total number of points, so the grid will have isqrt(k+3)+1 points in each direction.

•

The option gridrefine = l where l is a nonnegative integer (default 0) specifies the number of recursive subdivisions to perform on any cells in the initial grid that have been determined to contain part of the curve to be plotted. This allows for a more efficient refinement of the curve, as it only computes function values where necessary. One problem is that for some curves, and some choices of the initial grid, it may not appear as though a cell contains any part of the curve, but implicitplot has some degree of intelligence in this respect, as it uses a quadratic interpolation to detect if some part of the curve may be in a cell before rejecting it. The subdivisions are performed recursively, so if the initial grid is [26,26], setting gridrefine=1 will have the highest grid level as [51,51], setting gridrefine=2 will have the highest grid level as [101,101], etc. The highest grid level for gridrefine=l will be [2^l*m,2^l*n].

•

The option crossingrefine = i where i is a nonnegative integer (default 0) provides a facility for improving the interpolation used to determine the location where the curve crosses a cell boundary. Normally a simple linear interpolation is used, but setting crossingrefine to i>0 performs i1 steps of bisection, and uses a quadratic interpolant to determine the cell boundary crossing. This is most useful for high degree curves where a linear interpolation does not provide a good estimate of the crossing point.

•

The option rational = true/false (default false), when set to true, tells implicitplot to use a rational interpolant to determine the location where the curve crosses a cell boundary. With this option implicitplot is better able to interpolate across a singular curve (for example, this provides a more accurate interpolation for the singular curve of 1/(x^2+y^21)). The rational interpolation is more expensive than standard interpolation as it always requires an additional function evaluation for each crossing point.

•

The option signchange = true/false (default true), when set to true, implicitly plots sign changes of the function. This includes, for example, the line y=0 for the input x/y. If this is not desired, and only the zeros of the input function are of interest, then signchange should be set to false. Note that when signchange is set to false, rational is automatically set to true, as it is not generally possible to detect sign changes that are not zeros unless a rational interpolant is used.

•

If the first argument is an expression or a procedure f, the option filledregions = true specifies that the regions defined by f = 0 should be colored. The option coloring = [c1, c2] allows the default colors to be changed, and causes region f < 0 to be given color c1 and region f > 0 to be given color c2. Note that the color of the curve defined by f = 0 now defaults to black, but this can be changed with the color option.


If the first argument is an equation, such as f=g, the option filledregions = true specifies that the regions defined by fg should be colored.


If the first argument is an inequality, and filledregions is specified, then only the region that satisfies the inequality will be drawn. Just as for filledregions=false, if the inequality is strict, then the lines for f = 0 will be plotted as dotted lines instead of solid lines.

•

The option resolution = r applies resolutionbased smoothing of the output curve to reduce the size of the output data structure, but retain the visual features of the curve up to a resolution of r x r pixels. By default, this value is 0, which means that no smoothing is to be applied. Note that this option cannot be used in combination with filledregions. Specifying resolution = 1000, when used in combination with crossingrefine, can reduce the size of a high detail plot by as much as a factor of 10.

•

The option resultant = fast/stable applies only to the third calling sequence, and specifies the algorithm used to numerically compute the resultant of expr1 and expr2 with respect to t. The default is fast, which uses Euclid's algorithm to compute the numerical resultant for each evaluation. The option stable uses a full Gauss elimination of the Sylvester matrix to compute the resultant for each evaluation. Use of resultant = stable is only really helpful when the input, as polynomials in t, have numerical instability when the resultant is computed using Euclid's algorithm.

•

The option factor = true/false (default false) when set to true tells implicitplot to perform symbolic preprocessing to make the plotting easier, and may be the only way, for simple functions, of plotting the zeros of a function that is greater or equal to zero over the plotting region. Note that this option cannot be used for the resultant form (third calling sequence), operator input (no way to factor) or for inequalities. Also note that this option may disable the use of adaptive ranges (only when multiple factors are present) as the zeros are computed independently for each factor.

•

The option rangeasview = true/false (default false) is simply a convenience option that, when set to true, tells implicitplot to use the specified region (a..b,c..d) as the view option (see view in plot/options). Note that when the vertical range is dependent on x, in the form c(x)..d(x), then the vertical range is ignored for this option.

•

The option outlines = true/false (default false), when set to true, displays the mesh over which the sampling takes place. Note that it is only reasonable to display the mesh when using a fairly coarse grid or a low refinement.

•

The option adaptranges = true/false when set to true tells implicitplot that if a plot is produced where only a portion of the specified range contains curves, then the plot should be automatically recomputed with smaller ranges, thus providing greater resolution in the output plot. Note that the ranges are determined from the curves produced in the initial plot, so if the initial resolution (as specified by grid and gridrefine) is poor, then parts of the plot may be missed. This option is only effective when plotting a single function, and is ignored when multiple functions are being plotted. In the same manner it is ignored when factor = true and multiple factors are present. This option is false by default when filledregions=true, and otherwise it is true by default.



Description


•

The implicitplot command computes the twodimensional plot of an implicitly defined curve. By default, the curve is computed in Cartesian coordinates.

•

In the first calling sequence, implicitplot(expr, x=a..b, y=c(x)..d(x)), the equation expr must have components that are expressions in the names x and y. The expr parameter can also be an expression instead of an equation, in which case the equation expr = 0 is plotted. The range a..b must evaluate to real constants, and the range c(x)..d(x) must evaluate to real constants for any fixed value of x.

•

In the second calling sequence, implicitplot(ineq, x=a..b, y=c(x)..d(x)), the inequality can depend only upon x and y. If the inequality is strict, the border of the inequality is plotted as a dotted line, while for nonstrict it is plotted as a solid line. There is also a difference in the behavior of the filledregions option (described in the Options section).

•

In the third calling sequence, implicitplot(f, a..b, c..d), the assumption is made that the equation f consists only of procedures or operators taking no more than two arguments. The f parameter can also be a procedure or operator instead of an equation, in which case the equation f = 0 is plotted. Operator notation must be used, that is, the procedure name is given without parameters specified, and the ranges must be given simply in the form a..b and c..d, rather than as equations.

•

In the fourth calling sequence, implicitplot([expr1,expr2,t], x=a..b(x), y=c..d(x)), the expr1 and expr2 must be equations or expressions in the names x,y and t, and must be polynomial with respect to t. This form of call to implicitplot is equivalent to the call implicitplot(resultant(expr1,expr2,t), x=a..b(x), y=c..d(x)), except that the resultant is computed more efficiently avoiding expression growth and excessive roundoff error.

•

Because the implicitplot command samples the function being plotted and builds the final image from the sample, it does not, by default, detect discontinuities in the function. Instead, the function is interpolated across the discontinuities. To change this behavior, see the rational and signchange options (described in the Options section).

•

For similar reasons, a sample based method cannot be used to detect isolated points which should be plotted.

•

If expr or f is a set or list (for the first two calling sequences), then its members are plotted together. If it is a list, then particular option values can also be given as lists, with elements corresponding to elements of expr or f. The options that can take lists as values are: color, coords, grid, legend, linestyle, numpoints, style, symbol, symbolsize, thickness, and transparency.



Notes


•

Note that implicitplot with the default settings does not do well for problems where the solution curve is very close to a region in which the expression being plotted becomes undefined or complex valued (for example expressions containing ln, where the argument can become negative). For problems of this class, the ideal approach is to increase the initial grid until points appear in the region, then increase gridrefine until the points describe a smooth curve.



Examples


>

$\mathrm{with}\left(\mathrm{plots}\,\mathrm{implicitplot}\right)$

$\left[{\mathrm{implicitplot}}\right]$
 (1) 
Plot a circle.
>

$\mathrm{implicitplot}\left({x}^{2}\+{y}^{2}\=1\,x\=1..1\,y\=1..1\right)$

Use the operator form of the command.
>

p:= proc(x,y) if x<y then x^2+y^22 else 2*x+y3 end if end proc:

>

$\mathrm{implicitplot}\left(p\,2..2\,1..2\,\mathrm{scaling}\=\mathrm{constrained}\right)$

Use a different coordinate system.
>

$\mathrm{implicitplot}\left(r\=1\mathrm{cos}\left(\mathrm{\θ}\right)\,r\=0..2\,\mathrm{\θ}\=0..2\mathrm{Pi}\,\mathrm{coords}\=\mathrm{polar}\right)$

Use a set or a list to combine plots.
>

$\mathrm{implicitplot}\left(\left[{x}^{2}{y}^{2}\=1\,y\={\ⅇ}^{x}\right]\,x\=\mathrm{Pi}..\mathrm{Pi}\,y\=\mathrm{Pi}..\mathrm{Pi}\,\mathrm{color}\=\left[''NavyBlue''\,''Teal''\right]\,\mathrm{legend}\=\left[\mathrm{plot1}\,\mathrm{plot2}\right]\right)$

Color the regions with blue and green.
>

$\mathrm{implicitplot}\left({x}^{2}\+{y}^{2}1\,x\=1..1\,y\=1..1\,\mathrm{coloring}\=\left[''SteelBlue''\,''DarkGreen''\right]\,\mathrm{filledregions}\=\mathrm{true}\right)$

Implicit plot of 4 concentric circles  very rough
>

$\mathrm{fn}\u2254\left({x}^{2}\+{y}^{2}1\right)\left({x}^{2}\+{y}^{2}0.73\right)\left({x}^{2}\+{y}^{2}0.5\right)\left({x}^{2}\+{y}^{2}0.31\right)\:$

>

$\mathrm{implicitplot}\left(\mathrm{fn}\,x\=1.2..1.2\,y\=1.2..1.2\right)$

Use of gridrefine=2 to get a finer grid (up to [101,101])
>

$\mathrm{implicitplot}\left(\mathrm{fn}\,x\=1.2..1.2\,y\=1.2..1.2\,\mathrm{gridrefine}\=2\right)$

Use of crossingrefine=2 to more accurately determine crossings
>

$\mathrm{implicitplot}\left(\mathrm{fn}\,x\=1.2..1.2\,y\=1.2..1.2\,\mathrm{crossingrefine}\=2\right)$

Comparison of size for high detail plots using resolution
>

$\mathrm{p1}\u2254\mathrm{implicitplot}\left(\mathrm{fn}\,x\=1.2..1.2\,y\=1.2..1.2\,\mathrm{gridrefine}\=2\,\mathrm{crossingrefine}\=2\right)\:$

>

$\mathrm{p2}\u2254\mathrm{implicitplot}\left(\mathrm{fn}\,x\=1.2..1.2\,y\=1.2..1.2\,\mathrm{gridrefine}\=2\,\mathrm{crossingrefine}\=2\,\mathrm{resolution}\=1000\right)\:$

>

$\mathrm{length}\left(\mathrm{p1}\right)\,\mathrm{length}\left(\mathrm{p2}\right)$

Plot of a singular line using default linear interpolation
>

$\mathrm{implicitplot}\left(\frac{1}{xy0.01}\,x\=0..1\,y\=0..1\right)$

Improvement using rational interpolation
>

$\mathrm{implicitplot}\left(\frac{1}{xy0.01}\,x\=0..1\,y\=0..1\,\mathrm{rational}\right)$

Intersection of a unit sphere and a cylinder projected into the xy plane (two intersecting ellipses).
>

$\mathrm{implicitplot}\left(\left[{x}^{2}\+{y}^{2}\+{z}^{2}\=1\,\frac{{\left(x\+\frac{z}{2}\right)}^{2}}{\frac{5}{4}}\+{y}^{2}\=\frac{1}{3}\,z\right]\,x\=1..1\,y\=1..1\,\mathrm{gridrefine}\=3\,\mathrm{scaling}\=\mathrm{constrained}\right)$

Plotting of a curve that is strictly >=0
>

$\mathrm{implicitplot}\left({x}^{4}\+2{x}^{2}{y}^{2}2{x}^{2}\+{y}^{4}2{y}^{2}\+1\,x\=1.2..1.2\,y\=1.2..1.2\,\mathrm{factor}\right)$

Plotting of the region where x^2+y^2<1 (note the dotted border)
>

$\mathrm{implicitplot}\left({x}^{2}\+{y}^{2}<1\,x\=1.2..1.2\,y\=1.2..1.2\,\mathrm{filledregions}\right)$

Plotting a function where the vertical range is restricted by the horizontal variable
>

$\mathrm{implicitplot}\left(y{x}^{2}\,x\=0..2\,y\=0..x\right)$

A polar plot with outlines to indicate sampling grid
>

${\mathrm{plots}}_{\mathrm{implicitplot}}\left(2\mathrm{Pi}rt\,r\=0..1\,t\=0..2\mathrm{Pi}\,\mathrm{coords}\=\mathrm{polar}\,\mathrm{axes}\=\mathrm{boxed}\,\mathrm{outlines}\,\mathrm{grid}\=\left[5\,5\right]\,\mathrm{gridrefine}\=2\,\mathrm{style}\=\mathrm{point}\,\mathrm{axiscoordinates}\=\mathrm{polar}\right)$

The command to create the plot from the Plotting Guide is
>

$\mathrm{implicitplot}\left({x}^{2}{y}^{2}\=1\,x\=\mathrm{Pi}..\mathrm{Pi}\,y\=\mathrm{Pi}..\mathrm{Pi}\right)$



