필터 지우기
필터 지우기

What method does Matlab use to compute the erf function?

조회 수: 5 (최근 30일)
Julie
Julie 2015년 4월 8일
답변: John D'Errico 2015년 4월 8일
I have a quadrature integration technique that I wish to test by comparing to "truth" for integrating a Gaussian, so I'm using the erf function to generate the "truth" integral of the Gaussian. What method does Matlab use to compute erf? Some sort of quadrature? Another method? Also, how accurate is it?

답변 (1개)

John D'Errico
John D'Errico 2015년 4월 8일
It will NOT be quadrature.
Instead, I'd look first at a reference like Abramowitz and Stegun, where you will find approximations for erf. A quick check of A&S shows some rational polynomial approximations 7.1.25, 7.1.26, 7.1.27, and 7.1.28 that are decent, but not truly sufficiently accurate for double precision.
So next I looked at the classic by Hart, "Computer Approximations". It offers a variety of approximations that yield as much as 23 digits of accuracy, so entirely adequate for double precision work (essentially 16 digits.)
The help docs for erf and erfc do not indicate exactly which one they use, but I can assure you that it will be something along those lines.
As a test, lets see how well erf does. At the top end, we can see more by looking at erfc, its cousin, since erf will block up at 1 there.
vpa(erfc(sym(12)))
ans =
1.3562611692059042127803061565904e-64
format long
erfc(12)
ans =
1.356261169205904e-64
which to me looks like a pretty good job. Of course, if you also have the symbolic toolbox, then just use that, as I have done above. There you will get as much accuracy as anyone can want.

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by