# Problem with DensityPlot when using very small values of function

I am trying to plot the following function, using a density plot, unfortunately, I do not get any output, it seems to be for the small values.

  L = 15;
F[x, y]=  - ((2.6006853090496755*^-17 Abs[x + I y] BesselJ[-(1/4),
0.45 Im[Sqrt[x + I y]]^2] BesselJ[-(1/4),
0.45 Re[Sqrt[x + I y]]^2] BesselJ[3/4,
0.45 Im[Sqrt[x + I y]]^2] BesselJ[3/4,
0.45 Re[Sqrt[x + I y]]^2] Im[Sqrt[x + I y]]^2 Re[Sqrt[
x + I y]]^2)/((x + I y) Conjugate[Sqrt[x + I y]]^2))


I can obtain and get a density plot only if remove the small value, the goal is to obtain the plot like this, but note that the example is without the small value 2.600*^-17

 outplot =
DensityPlot[
Abs[((Abs[x + I y] BesselJ[-(1/4),
0.45 Im[Sqrt[x + I y]]^2] BesselJ[-(1/4),
0.45 Re[Sqrt[x + I y]]^2] BesselJ[3/4,
0.45 Im[Sqrt[x + I y]]^2] BesselJ[3/4,
0.45 Re[Sqrt[x + I y]]^2] Im[Sqrt[x + I y]]^2 Re[Sqrt[
x + I y]]^2)/((x + I y) Conjugate[Sqrt[x + I y]]^2))], {x, -L, L}, {y, -L, L},
PlotRange -> Full, PlotPoints -> 150,
ColorFunction -> "Rainbow", Axes -> True, AxesLabel -> {x, y},
FrameTicks -> True, Exclusions -> None]


How can I fixed this problem in order to obtain the plot well? Thanks!

This is an extended comment, rather than an answer.

As you know, the values of your function are extremely small because you multiply it by that tiny number. Obviously, the simple workaround is not to do that: especially in a DensityPlot, and since you are rescaling the values passed to your colorfunction, that really makes no difference at all.

What I found surprising, however, is the following result, that seems to indicate that, no matter the requested WorkingPrecision, the results passed to ColorFunction are not calculated at high enough precision.

I am going to redefine your function so it has arbitrary precision, replacing the machine-precision numbers:

L = 15;
ClearAll[f]
f[x_, y_] := -(26*^-18 Abs[x + I y] BesselJ[-(1/4), 45/100 Im[Sqrt[x + I y]]^2]
BesselJ[-(1/4), 45/100 Re[Sqrt[x + I y]]^2] BesselJ[3/4, 45/100 Im[Sqrt[x + I y]]^2]
BesselJ[3/4, 45/100 Re[Sqrt[x + I y]]^2] Im[Sqrt[x + I y]]^2
Re[Sqrt[x + I y]]^2)/((x + I y) Conjugate[Sqrt[x + I y]]^2);


Then I extract the values being passed to the color function, without scaling:

output = Reap@
DensityPlot[
f[x, y], {x, -L, L}, {y, -L, L},
WorkingPrecision -> 40,
ColorFunctionScaling -> False, ColorFunction -> (Sow[#] &)
]


As you can see, the values have been truncated to zero as though they had been Chopped even though the working precision. Indeed, the raw values are smaller than $MachineEpsilon, but in my view this behavior is improper, because it does not seem to respect the requested working precision. Of course you can bring them "in range" by multiplying your function by a small number, e.g. plotting 57 f[x, y] returns DensityPlot[ 57 f[x, y], {x, -L, L}, {y, -L, L}, WorkingPrecision -> 40, ColorFunction -> "Rainbow", PlotPoints -> 50 ]  • You can use ClippingStyle -> Automatic to fill in the missing white area. – mjw Mar 29 '19 at 15:43 • @mjw Yes, that would be a good idea. However, I included that last plot really just to show that, providing "large enough" numerical values to DensityPlot, we can obtain a reasonable output. – MarcoB Mar 29 '19 at 15:46 • yes, agreed. ... – mjw Mar 29 '19 at 16:27 You can use ScalingFunctions to scale the function values. It seems that if all values are less than around $MachineEpsilon, DensityPlot figures that the function is zero and the small values are due to rounding noise.

outplot = DensityPlot[Abs@F[x, y], {x, -L, L}, {y, -L, L},
ScalingFunctions -> {None, None, {# 1000 &, #/1000 &}},
PlotRange -> Full, PlotPoints -> 150, ColorFunction -> "Rainbow",
Axes -> True, AxesLabel -> {x, y}, FrameTicks -> True,
Exclusions -> None]


If you want to use PlotLegends, you need to delete the ScalingFunctions from the legend to get the correct scale:

DeleteCases[
outplot = DensityPlot[Abs@F[x, y], {x, -L, L}, {y, -L, L},
ScalingFunctions -> {None, None, {# 1000 &, #/1000 &}},
PlotRange -> Full, PlotPoints -> 150, ColorFunction -> "Rainbow",
Axes -> True, AxesLabel -> {x, y}, FrameTicks -> True,
Exclusions -> None, PlotLegends -> Automatic],
ScalingFunctions -> _, Infinity]


Taking MarcoB's solution, and plotting on a logarithmic scale, also is interesting (and we don't have to search for the multiplicative constant):

Note, we do need Abs[] before the Log10[], (or perhaps plot both positive and negative on different color scales and combine):

Also adding a legend to see what values the colors represent ...

 DensityPlot[Log10@Abs[f[x, y]], {x, -L, L}, {y, -L, L},
WorkingPrecision -> 40, ColorFunction -> "Rainbow",
PlotPoints -> 50, ClippingStyle -> Automatic,
PlotLegends -> BarLegend[-15 - Range[20]/2,
LegendLabel -> "\!$$\*SubscriptBox[\(log$$, $$10$$]\)|f(x,y)|"]]


• You can add Exclusions -> None` to get rid of that cut. – J. M.'s ennui Mar 29 '19 at 17:28
• @J. M., Yes, that would look nicer. I thought, though, that it is a branch cut due to the square root, and maybe should therefore remain. – mjw Mar 29 '19 at 17:49