Search code examples
algorithmnumerical-methods

Algorithms for the error function and its friends (erf, erfc etc)


I've been looking at algorithms used to calculate various functions, such as the CORDIC algorithm for tigonometric functions.

I was wondering how the error function is usually calculated. Wikipedia has a number of approximations, but is there one algorithm that is generally preferred when coding the error functions for numerical computing?


Solution

  • Your best bet is to check what actual implementations do, here is a selection:

    1. Boost: http://www.boost.org/doc/libs/1_55_0/boost/math/special_functions/erf.hpp

    2. GNU Scientific Library: http://www.gnu.org/software/gsl/

    3. GLibc http://www.gnu.org/software/libc/index.html

    There are probably others.