0

I'm a new user of Mathematica 12. I have to plot real and imaginary solutions of two equations, eq1 and eq2, which contain the Dawson integral. Here is my program:

f[a_] := - 2 DawsonF[a]+I Exp[-a^2] Sqrt[π] 

eq1[x1_, y_, z_] := 1 - (z y^2/x1^2) - (1/(Sqrt[2] x1 y)) f[x1/(Sqrt[2] y)]
eq2[x2_, y_] := 1 - (1/(2 y^2)) f'[x2/(Sqrt[2] y)]

slo1[y_, z_] := Re[x1 /. FindRoot[eq1[x1, y, z], {x1, Sqrt[1 + z y^2]}]];
slo2[y_] := Re[x2 /. FindRoot[eq2[x2, y], {x2, Sqrt[1 + y^2]}]];

Plot[{slo1[y, 5000], slo2[y]}, {y, 0.0001, 0.5}, PlotRange -> {{0.0001, 0.5}, {0, 4}}, PlotRangePadding -> 0]

When I plot the graphs, I get these errors

General::munfl: Exp[-4.11658*10^7] is too small to represent as a normalized machine number; precision may be lost.

General::munfl: Exp[-4.11658*10^7] is too small to represent as a normalized machine number; precision may be lost.

FindRoot::lstol: The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the merit function. You may need more than MachinePrecision digits of working precision to meet these tolerances.

General::munfl: Exp[-4.11633*10^7] is too small to represent as a normalized machine number; precision may be lost.

General::stop: Further output of General::munfl will be suppressed during this calculation.

FindRoot::lstol: The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the merit function. You may need more than MachinePrecision digits of working precision to meet these tolerances.

This means that that the solutions plotted are incorrect. Please tell me how to eliminate these errors to get the exact solutions.

How to plot imaginary solutions too without errors?

Thank you.

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
Majorana
  • 51
  • 5
  • 1
    Try the WorkingPrecision option in FindRoot – Michael E2 Apr 04 '20 at 03:40
  • 1
    Adding WorkingPrecision to FindRoot doesn't seem to help enough. The form of your equations produces numbers so small that they can't be correctly expressed in floating point. Another issue is that your two graphs are different enough that when you combine them you miss critical details. Try replacing your Plot with Print[ListPlot[Table[{y,slo1[y, 5000]},{y,10^-4,1/2,10^-3}],Joined->True,PlotRange->All]]; Print[ListPlot[Table[{y, slo2[y]},{y, 10^-4,1/2,2*10^-3}], Joined->True]] and look VERY carefully at the details. You might want to zoom into the left side of the first plot. – Bill Apr 04 '20 at 05:09
  • @Bill I have plotted the graphs according to above but I still find the same errors. – Majorana Apr 04 '20 at 13:17
  • 1
    I didn't claim that I had fixed your problem, I would have said so if I did. I only showed that your problem is even worse than you think it is if all you are hoping for is no error messages and the plot you showed. Exp[-4.11658*10^7] has over 17 million zeros after the decimal point. The real fix for your problem is probably your deeply understanding the size of all the numbers involved in finding your solution and seeing if there is or is not a way of completely reformulating your problem to avoid these issues, if that is possible. – Bill Apr 04 '20 at 17:01
  • Thanks Bill. Indeed, as I'm a new user of Mathematica, I don't know how to efficiently handle numbers of such size, especially the problems related to precisions. For my problem, I don't know how to reformulate it, these are exact equations to solve. – Majorana Apr 04 '20 at 17:19
  • DawsonF[] is known to be problematic in versions 11.3 and later. Can you try using the compiled Dawson integral from this answer? (Of course, you will need to re-express and separately define f'[x] in terms of the compiled Dawson function.) – J. M.'s missing motivation Apr 17 '20 at 15:47

0 Answers0