0
$\begingroup$

I was trying to plot the asymptotic expansion of erfc(x) for some value of x:

exact[x_] := 1/Sqrt[\[Pi]]*Gamma[1/2, x^2];
seriesz[x_, n_] := 
Exp[-x^2]/(x*Sqrt[\[Pi]])
Sum[(-1)^m* (2 m - 1)!! /(2^m *x^(2 m)), {m, 1, n}];

x = 2;
mmax = 5*x;

Print[StringForm["Exact answer: ``", exact[1.0*x]]]
Show[Plot[{exact[x]}, {m, 0, mmax}, PlotStyle -> {Dashed, Red}], ListPlot[Table[{m, seriesz[x, m]}, {m, 0, mmax}]]]

but the series is always ends up much lower on the plot than the actual value. Instead of getting something where the series oscillates around the exact value, what I'm getting when I run this code is:

Exact answer: 0.0046777349810472645`

enter image description here

When what I'm looking for is this (which I get when I make this alteration to the code):

seriesz[x_, n_] := 0.00517 + Exp[-x^2]/(x*Sqrt[\[Pi]])*Sum[(-1)^m* (2 m - 1)!! /(2^m *x^(2 m)), {m, 1, n}];

enter image description here

Any advice what I'm doing wrong that the series isn't centered around the exact value and instead is centered around some smaller value?

$\endgroup$
1
$\begingroup$

Could be an error in your expression? Mathematica can do asymptotic expansions using Series, I believe. Consider this:

f[x_] = 1/Sqrt[π]*Gamma[1/2, x^2];
ListPlot[
  Table[Normal@Series[f[x], {x, ∞, n}] /. x -> 2, {n, 1, 20, 2}]
  , PlotRange -> All
  , Epilog -> {Line[{{0, f[2]}, {25, f[2]}}]}
 ]

results in the following:

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ I did not realise Mathematica had that capability! And I see in your code that to change x, you changed f(2). Useful, thank you! $\endgroup$ – Jomy Blue Sep 21 '17 at 5:31
  • $\begingroup$ Could you just explain what the purpose of {n, 1, 20, 2} in the above code segment is? $\endgroup$ – Jomy Blue Sep 21 '17 at 5:34
  • 1
    $\begingroup$ The table index n (which is the order of the expansion, essentially), goes from 1 to 20 in steps of 2. I did this because the expansion had only odd parts of x. $\endgroup$ – march Sep 21 '17 at 5:36

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.