contour plot using Mathematica

356 Views Asked by At

I want do a contour plot in Mathematica as:

ContourPlot[{Re[F[5/4, x + I y]] == 0, Im[F[5/4, x + I y]] == 0}, {x, -20, 20}, {y, -20, 20}, PlotPoints -> 100];

where function F[b,z] is defined as:

F[b_,z_]:=(2*((b - I*z)/E^(2*Ibz) + E^(2*Ibz)(b + Iz)))/E^b^2 + (Sqrt[Pi]*(1 + 2*z^2)(Erf[b - Iz] + Erf[b + I*z]))/E^z^2;

The plot is not smooth in some area.

Why is that?

Thanks- mike

enter image description here

1

There are 1 best solutions below

0
On BEST ANSWER

This happens due to insufficient precision to compute the values of F in that region. By default Mathematica uses machine precision, i.e. a fixed ~16 digits of decimal precision. This function F is likely prone to catastrophic cancellation.

The fix is to use Mathematica's arbitrary precision arithmetic, which also supports precision tracking. Since Mathematica has an estimate of the precision of the results, it can automatically increase the number of digits it uses internally to achieve a satisfactory result. It can also detect if the result has no significant digits. While it's not 100% reliable, this feature is very useful in practice.

To force the system to use its builtin arbitrary precision arithmetic, simply add the option WorkingPrecision -> 10 (or higher if necessary).

The computation from the screenshot is very slow, instead I recommend something like

PlotPoints -> 40, MaxRecursion -> 3, WorkingPrecision -> 10