Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

erfi(::BigFloat) #118

Open
cossio opened this issue Sep 12, 2018 · 11 comments
Open

erfi(::BigFloat) #118

cossio opened this issue Sep 12, 2018 · 11 comments

Comments

@cossio
Copy link
Contributor

cossio commented Sep 12, 2018

julia> SpecialFunctions.erfi(big"1")
ERROR: MethodError: no method matching erfi(::BigFloat)

Since SpecialFunctions.erf works with BigFloat, I suspect that erfi could work too without much hassle?

@simonbyrne
Copy link
Member

For erf we just call the MPFR function (https://www.mpfr.org/mpfr-current/mpfr.html#Special-Functions). It doesn't provide an erfi function, so we would have to write our own.

@cossio
Copy link
Contributor Author

cossio commented Sep 12, 2018

@simonbyrne One (probably inefficient) way of doing it is to rely on erf(::Complex{BigFloat}), which is already defined.

myerfi(x::BigFloat) = imag(erf(x*im))

@simonbyrne
Copy link
Member

Ah, that's not good: it is just converting it to Complex{Float64}:
https://github.com/JuliaMath/SpecialFunctions.jl/blob/master/src/erf.jl#L27

We should change that.

@cossio
Copy link
Contributor Author

cossio commented Sep 12, 2018

new issue #119

@cossio
Copy link
Contributor Author

cossio commented Sep 13, 2018

Now that #119 is closed, perhaps we can add erfi(x::BigFloat) = imag(erf(x*im))?

@simonbyrne
Copy link
Member

We could, but it will just throw a MethodError either way.

@simonbyrne
Copy link
Member

(MPFR doesn't provide a complex erf function)

@flmuk
Copy link

flmuk commented May 22, 2023

any updates on this? a solution to this would be extremely handy

@stevengj
Copy link
Member

Writing special functions is not easy — this would require a from-scratch implementation.

@flmuk
Copy link

flmuk commented May 22, 2023

I understand. Actually I only need $$erfi(x)$$ for real arguments, not complex ones. Is there a workaround for that? I guess I could write the Maclaurin series for that one, are there some pitfalls to avoid?

@stevengj
Copy link
Member

A Taylor–Maclaurin series is generally a very slow way to compute special functions except in a small region of the domain. Usually people use a Taylor series near roots, and otherwise use things like continued-fraction expansions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants