1

Let $\displaystyle \Phi(x)=\frac{2}{\sqrt{\pi}}\sum_{k=0}^{\infty}(-1)^k\frac{x^{2k+1}}{k!(2k+1)}$, i.e $\Phi$ is the MacLaurin series of the function $\displaystyle \frac{2}{\sqrt{\pi}}\int\limits_{0}^{x}e^{-t^2}dt$. Why using partial sums of the series gives us a bad computation for $\Phi(20)$, when the operations are done in floating point arithmetic?

Thanks a lot for the help!

1 Answers1

3

The error with exact evaluation is bounded by the next term. So the partial sum up to $k=N-1$ has an error of about $$ \frac{(20)^{2N+1}}{N!(2N+1)}\sim\frac{20}{2N+1}\left(\frac{400·e}{N}\right)^N $$ As one can see, it takes about $N=400$ to start seeing decreasing terms and about $N=1200$ to get small remainder terms. The maximum term at $N=400$ has size $e^{400}$ which provides for extremely catastrophic cancellation errors.

The way to go is to find estimates for $\int_x^{\infty}e^{-t^2}\,dt$. See the wikipedia page on the error function to get computation and approximation methods.

Lutz Lehmann
  • 131,652