문제

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?

도움이 되었습니까?

해결책

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.

다른 팁

If you are looking for basic ideas on how these algorithms work instead of the exact details, then you should know that the Taylor expansion for these functions usually provides the asymptotic optimal way to compute them (either directly or with a re-expression), so it basically just boils down to how you refine the computation of the Taylor expansion. If you are unfamiliar with Taylor expansions and how they relate to functions like erf, see http://en.wikipedia.org/wiki/Taylor_series and http://en.wikipedia.org/wiki/Error_function#Taylor_series

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top