フィルターのクリア

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 Center および File ExchangeCalculus についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by