Is there a faster version of the matlab function erfi?
Show older comments
I need to call the erfi function for each element in a 3D array in order to compute some anti-derivative. This causes a very slow run of my code. I'm looking for a fast implementation of the erfi function in order to shorten the run time of my code.
Answers (2)
Alan Weiss
on 10 Jun 2015
Edited: Alan Weiss
on 10 Jun 2015
I don't know of any way to speed erfi. You can call erfi on a 3-D array all at once (you don't have to loop through the individual elements), but you probably already knew that.
The only other thing I can suggest is to use approximate asymptotic values in case the elements in your array are real and large in magnitude. I think that an asymptotic expansion for large positive x looks like
erfi(x) = 1/(x*pi^(1/2)) exp(x^2)(1 + O(1/x^2))
I got this by integration by parts. But the absolute error value is quite large. Perhaps you can come up with appropriate approximations in your region of interest.
Here, I just tried it on an example:
1/(20*sqrt(pi))*exp(400)
ans =
1.4729e+172
erfi(20)
ans =
1.4748e+172
Alan Weiss
MATLAB mathematical toolbox documentation
Juan F. Osoiro
on 5 Dec 2019
Edited: Juan F. Osoiro
on 5 Dec 2019
0 votes
Same issue here. erfi from the symbolic toolbox is too slow. The function in python is orders of magnitud faster. https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.erfi.html
Categories
Find more on Solver Outputs and Iterative Display in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!