# Incomplete plot problem

I have this code:

In[1]:= H[u_] =
1/2 ((-2 + Erfc[-((5 u)/Sqrt[2])]) Log[
1 - 1/2 Erfc[-((5 u)/Sqrt[2])]] - (Erfc[-((5 u)/Sqrt[2])] -
Erfc[-((3 u)/Sqrt[2])]) Log[
1/2 (Erfc[-((5 u)/Sqrt[2])] -
Erfc[-((3 u)/Sqrt[2])])] - (Erfc[-((3 u)/Sqrt[2])] -
Erfc[-(u/Sqrt[2])]) Log[
1/2 (Erfc[-((3 u)/Sqrt[2])] - Erfc[-(u/Sqrt[2])])] -
Erfc[-(u/Sqrt[2])] Log[1/2 Erfc[-(u/Sqrt[2])]]);

In[2]:= H[2.1] // Log10 // N[#, 10] &

Out[2]= Indeterminate

In[3]:= H[Rationalize[2.1, 10^-10]] // Log10 // N[#, 10] &

Out[3]= -1.047657131


However, when I do

In[4]:= Plot[(H[Rationalize[u, 10^-10]] // Log10 // N[#, 10] &) //
Evaluate, {u, 0, 3}, PlotRange -> All]


I get an incomplete plot; the values of the function for u>1.7 (or so) are apparently left unevaluated:

Out[4]=


How to fix this?

• Use H[u_] := rather than H[u_] = and things should work fine.
– JimB
Feb 9 '18 at 21:32

Use the WorkingPrecision option in Plot

H[u_] = 1/2 ((-2 + Erfc[-((5 u)/Sqrt[2])]) Log[
1 - 1/2 Erfc[-((5 u)/Sqrt[2])]] - (Erfc[-((5 u)/Sqrt[2])] -
Erfc[-((3 u)/Sqrt[2])]) Log[1/2 (Erfc[-((5 u)/Sqrt[2])] -
Erfc[-((3 u)/Sqrt[2])])] - (Erfc[-((3 u)/Sqrt[2])] -
Erfc[-(u/Sqrt[2])]) Log[
1/2 (Erfc[-((3 u)/Sqrt[2])] - Erfc[-(u/Sqrt[2])])] -
Erfc[-(u/Sqrt[2])] Log[1/2 Erfc[-(u/Sqrt[2])]]);

Plot[H[u] // Log10, {u, 0, 3}, WorkingPrecision -> 15, PlotRange -> All]


• Thank you. A crazy thing is that this works on a Windows 10 computer, but not on Windows 7 one! Cf. the opposite kind of situation described at mathematica.stackexchange.com/questions/165423/… . Can anyone explain these crazy things? Feb 11 '18 at 0:53
• @IosifPinelis - what version of Mathematica are you running in each case? If both are the current version (11.2), report it to Wolfram support. Feb 11 '18 at 1:23
• @IosifPinelis - if part of the plot is missing it is may be due to imaginary artifacts from precision issues. Since you know that the function is real in the range of interest, try plotting Re[H[u]//Log10] or H[u]//Log10//Chop with Windows 7. Feb 11 '18 at 1:32