I am trying to plot

F2q0overLambdaSimpler3[m_] := 
1/(Sqrt[2] (4*Pi)^2)*1/(2 (m^4) )*(1/Sqrt[1 - 4 m^2]*(2 - 10 m^2 + 8 m^4)*
 ArcTanh[Sqrt[1 - 4 m^2]/(1 - 2 m^2)] + 
2*(2 m^2 - 3 m^4 + (2 - 6 m^2) Log[m]))$

Just using

Plot[F2q0overLambdaSimpler3[m], {m, 1/(200*10^3), 1/(100*10^3)}]

But the result looks like this:

enter image description here

Then I plotted this function using matlab:

enter image description here

How do I get mathematica plotting it equally nice? I already tried things like

WorkingPrecision -> 100

or even 1000 what yields a very weird behaviour.... Any suggestions?

  • $\begingroup$ can you post the Matlab code? $\endgroup$
    – Nasser
    Commented May 24, 2014 at 11:39
  • $\begingroup$ fyi, your function has many Indeterminate values. It can't be correct. Try data = Table[{i, F2q0overLambdaSimpler3[i]}, {i, 1/(200*10^3), 1/(100*10^3), .00000001}] // N and you'll see. You Matlab code must be different that the Mathematica code shown. $\endgroup$
    – Nasser
    Commented May 24, 2014 at 11:49
  • $\begingroup$ poss related mathematica.stackexchange.com/questions/47984/… $\endgroup$
    – george2079
    Commented May 24, 2014 at 11:52

1 Answer 1


The reason for the fragmented plot is that the function evaluates to Indeterminate for most of the input values in the plot range, when using machine precision arithmetic. (Specifically, the argument to ArcTanh is equal to 1.0 with machine precision, and ArcTanh[1.0] is Indeterminate).

Even if we didn't have this problem with ArcTanh, there is another reason not to use machine precision, which is that the function contains three terms which almost exactly cancel. For example:

Operate[HoldForm, Expand @ F2q0overLambdaSimpler3[5*^-6]] ~N~ 40

Plus[3.582244801432892462853067372970466380829 * 10^8, 
 1.749005611145337947993200403185346578823 * 10^20, 
-1.749005611148920192794633295648251690568 * 10^20]

(* -5.2044372*10^-12 *)

Therefore it will be essential to increase the WorkingPrecision in Plot. For example:

Plot[F2q0overLambdaSimpler3[m], {m, 5*^-6, 1*^-5}, WorkingPrecision -> 50]

enter image description here

Clearly this is a very different plot to that obtained with Matlab. As a check on the Mathematica result, we can look at the series expansion of the function.

Series[F2q0overLambdaSimpler3[m], {m, 0, 7}]

I won't copy the full result here, but the first term is $\frac{m^2 (12 \log (m)+7)}{48 \sqrt{2} \pi ^2}$:

Evaluating this at the start of the plot range:

((7 + 12 Log[m]) m^2)/(48 Sqrt[2] π^2) /. m -> 5.0*^-6

(* -5.20444*10^-12 *)

This result agrees with what we see in the plot. Of course this doesn't prove anything but perhaps the next step should be to examine the Matlab result more closely. What precision did Matlab use to compute the plot?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.