# Question: threshold for ignoring nonreal part in plots

August 24 2011 by
false
Maple

3

On the usenet newsgroup sci.math.symbolic Prof. Richard Fateman posted a question (or here) recently about what mechanisms a math application could use to handle the situation of negligible imaginary parts of computed data when plotting.

An example could be a function which evaluates to purely real numbers in the domain of interest with exact symbolic computation, but which produces small imaginary values due to numerical error at the working precision (eg. roundoff error) when doing the numerical floating-point computation required for plotting.

The Maple help-page ?plot,computation says,

    Many plotting commands check for numbers with very small imaginary parts and will convert
these numbers to real numbers, with the criteria for dropping an imaginary part depending
on the Digits environment variable and on its relative size compared to the real part. This
procedure helps to avoid problems caused by round-off errors during the computation.


This is often quite helpful behaviour. But would it help more to document precisely what is the decision formula used to determine whether the nonreal component is negligible?

Another way to pose this question is to seek a formulaic or algorithmic description of the boundary curve of the figures below. What relationship between Digits, the real and the imaginary components can describe this boundary?

restart:

Digits:=10:

plot3d(proc(x,y) []; evalf(y+I*10^(-x)); end proc,
0..10, 0..10, axes=box,grid=[300,300], color=blue,
style=patchnogrid, orientation=[90,0,0]);


Digits:=37:

plot3d(proc(x,y) []; evalf(y+I*10^(-x)); end proc,
Digits-20..Digits, 0..Digits, axes=box,grid=[300,300], color=blue,
style=patchnogrid, orientation=[90,0,0],
view=[Digits-20..Digits, 0..Digits, DEFAULT]);


Digits:=137:

plot3d(proc(x,y) []; evalf(y+I*10^(-x)); end proc,
Digits-20..Digits, 0..Digits, axes=box,grid=[300,300], color=blue,
style=patchnogrid, orientation=[90,0,0],
view=[Digits-20..Digits, 0..Digits, DEFAULT]);


cplxartefact.mw

Incidentally, Fateman uses an example which produces a "hole" in the plot, in Mathematica. He uses the JacobiSN function for this. See the 3rd (parametric) plot on WolframAlpha here. This is not such an interesting example for Maple, which produces purely real output for this function when computed in the region of interest.

plot([Re(JacobiSN(u,sqrt(3))),JacobiSN(u,sqrt(3)),u=3..5]);


But it might be of importance in some situations, whether such holes in the plotted curve are because of just-slightly too great an imaginary part, or because or a much too large imaginary part. Knowing the precise mechanism would be a virtue, then. I'll leave you to compare these two plots, if you're interested.

Digits:=10:

plot(x+4*sin(x)+(exp(1/x^5)+2.13)*I*1e-7,x=-8..8,
thickness=3,color=black);

plot(x+4*sin(x)+(exp(1/x^5)+2.13)*I*1e-20,x=-8..8,
thickness=3,color=black);


acer