Faster / more precise logarithm of complimentary error function?
26 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
If there is a way to calculate the logarithm of complimentary error function with better numerical precision (and preferably also faster) than doing it in the straightforward manner, e.g.
log(erfc(-5:5))
ans =
0.6931 0.6931 0.6931 0.6908 0.6112 0 -1.8496 -5.3649 -10.7204 -17.9878 -27.2009
As far as I know, many of numerical approximations involve product that includes exponential in some form e.g. see Wikipedia, so it feels that some potential gain could be achieved through it.
0 Kommentare
Antworten (5)
Walter Roberson
am 23 Sep. 2017
Bearbeitet: Walter Roberson
am 23 Sep. 2017
No, the algorithms involve the sum of exponentiation times another factor, not products that you could potentially turn into sums.
erfc() is a built-in in MATLAB. It is going to call into some built-in library function written in C or C++ . To have any chance of matching the speed, your replacement would also have to be in C or C++.
1 Kommentar
John D'Errico
am 23 Sep. 2017
If you want speed, no, you are not going to beat log(erfc(x)), at least not without writing custom code, preferably in some compiled language.
If you want higher accuracy for large positive x, then yes you could get more accuracy in the upper tail. It won't be incredibly fast though. I'd probably start with the simple asymptotic expansion given on the wikipedia page.
Be careful though, as the classic asymptotic expansion actually diverges if you take too many terms. But for moderately small x, you would need perhaps more terms to get an adequate number of digits. It depends on how many digits of accuracy you need/want. The point is, you need to do some careful work to choose an expansion that will be fast AND highly accurate. The problem will be for intermediate values of x, perhaps on the order of 1 to 2.
0 Kommentare
Shep Bryan
am 31 Mär. 2020
If you are mainly worried about underlow, this is a handy function that avoids numerical issues:
function out = logerfc(X)
out = log(erfcx(X)) - X.^2;
end
0 Kommentare
Siehe auch
Kategorien
Mehr zu Interpolation of 2-D Selections in 3-D Grids finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!