0
$\begingroup$

I have a precision problem with a complicated function in Mathematica. I need to get norm (NIntegrate[f[x],{x,0,1}]) and shape (f[x]/norm) of this function for several values of parameters. When pushing parameters to extremely large or small values, the computation quickly loses precision and breaks. I try to report here the full code to reproduce the problem, unfortunately, the definition of the function is very long

subst = {\[Mu] -> 1.0649627263045793` m\[Chi], 
   m\[Chi] -> m0, \[Mu]F -> 0.126881598`, \[Sigma]0 -> 
    5.137783801543852`*^-18, nn -> 0.0022767242753033053`, 
   B0 -> 0.5801875039070804`, mn -> 0.939`};

The function is defined at this paste (does not fit in here) https://pastebin.com/raw/4b2wHFUA

Here are some example plots that show the problem

(*For values of T and M0 that are not too small/large, the function \
evaluates with good precision*)
T = 1/10^5;
Plot[DGamma[x*T, T] /. subst /. m0 -> 10^3 /. n -> 0, {x, 0, 1}]

(*For values of T and M0 that are not too small/large, the function \
evaluates with good precision*)
T = 1/10^5;
Plot[DGamma[x*T, T] /. subst /. m0 -> 10^5 /. n -> 0, {x, 0, 1}]

(*Pushing m0 and T to very small/large values causes problems, like \
here (the shape should be the same as before, but is not precise...)*)
T = 1/10^7;
Plot[DGamma[x*T, T] /. subst /. m0 -> 10^7 /. n -> 0, {x, 0, 1}]

(*Another issue that can happen are fuzzy plots like this*)
T = 1/10^5;
Plot[DGamma[x*T, T] /. subst /. m0 -> 10^7 /. n -> 0, {x, 0, 1}]

(*Going even more down/up in values, it breaks completely*)
T = 1/10^9;
Plot[DGamma[x*T, T] /. subst /. m0 -> 10^7 /. n -> 0, {x, 0, 1}]

I would need to make it work for m0 up to 10^9 and T down to 1/10^10. Suggestions?

$\endgroup$
3
$\begingroup$

Using exact math works:

subst = SetPrecision[{μ -> 1.0649627263045793` mχ,
                      mχ -> m0,
                      μF -> 0.126881598`,
                      σ0 -> 5.137783801543852`*^-18,
                      nn -> 0.0022767242753033053`,
                      B0 -> 0.5801875039070804`,
                      mn -> 0.939`},
                     ∞];

T = 1/10^9;
ListLinePlot[Table[{x, DGamma[x*T, T] /. subst /. m0 -> 10^7 /. n -> 0}, {x, 0, 1, 1/100}]]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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