Faster / more precise logarithm of complimentary error function?
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (5)
Walter Roberson
el 23 de Sept. de 2017
Editada: Walter Roberson
el 23 de Sept. de 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 comentario
John D'Errico
el 23 de Sept. de 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 comentarios
Shep Bryan
el 31 de Mzo. de 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 comentarios
Ver también
Categorías
Más información sobre Interpolation of 2-D Selections in 3-D Grids en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!