Simple error function approximation
I recently ran across the fact that
is a remarkably good approximation for -1 x 1.
Since the integral above defines the error function erf(x), modulo a constant, this says we have a good approximation for the error function
again provided -1 x 1.
The error function is closely related to the Gaussian integral, i.e. the normal probability distribution CDF . The relation between erf and is simple but error-prone. I wrote up some a page notes for myself a few years ago so I wouldn't make a mistake again moving between these functions and their inverses.
Update: This post makes the connection to probability explicit.
You can derive the approximation by writing out the power series for exp(t), substituting -t^2 for t, and integrating term-by-term from 0 to x. You'll see that the result is the same as the power series for sine until you get to the x5 term, so the error is on the order of x5. Here's a plot of the error.
The error is extremely small near 0, which is what you'd expect since the error is on the order of x5.
The post Simple error function approximation first appeared on John D. Cook.