next up previous
Next: Fortran Implementation Up: Truncated Power Series Previous: Truncated Power Series

Mathematical Background

In this worksheet, you will write a Fortran program that will evaluate the error function of a real or complex number. You will use $\emph{Mathematica}$to check your answers, because it has this function built in.

For small argument x, a good and efficient way to evaluate erf(x) is to use the truncated power series (this is easily derived from the integral (1) by expanding the integral as a power series and integrating term by term. Note that we have changed x^2 -> 2 x^2 in going from (1) to (2) below):

 \begin{displaymath}erf(x)=\frac{2x}{\sqrt{\pi }}\sum_{k=0}^{\infty }\frac{\left(...
...{N-1}\frac{\left( -1\right) ^{k}}{\left( 2k+1\right) k!}x^{2k}
\end{displaymath} (2)

Equation 2 is a so called alternating power series and is theoretically convergent for all x. If one truncates the series at some high order term N-1, the error $\varepsilon $that is made is smaller than the first discarded term. If x is significantly larger than 1 (5 or larger) then the series in 2 will converge very slowly. Other series expansions (asymptotic series) can be used in that case. You need not worry about this. If $\left\vert
x\right\vert >5$, assume that $erf(x)\approx 1$ and return this value without calculating the sum!



Phil Duxbury
2000-09-11