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

Could return complex values for real inputs if argument is negative #30

Closed
heltonmc opened this issue Aug 4, 2022 · 0 comments · Fixed by #32
Closed

Could return complex values for real inputs if argument is negative #30

heltonmc opened this issue Aug 4, 2022 · 0 comments · Fixed by #32

Comments

@heltonmc
Copy link
Member

heltonmc commented Aug 4, 2022

If called with negative arguments the routines could return imaginary values.

julia> besselj(0.4, 2.5)
0.24183102113825858

julia> besselj(0.4, -2.5)
0.07472989529876903 + 0.22999496849585185im

It appears the Julia standard is to return a domain error here unless called with complex. SpecialFunctions.jl will return error unless explicitly defined.

julia> using SpecialFunctions
julia> besselj(0.4, 2.5)
0.241831021138255

julia> besselj(0.4, -2.5)
ERROR: DomainError with -2.5:
`x` must be nonnegative.
Stacktrace:
 [1] besselj(nu::Float64, x::Float64)
   @ SpecialFunctions ~/.julia/packages/SpecialFunctions/NBIqR/src/bessel.jl:488
 [2] top-level scope
   @ REPL[5]:1

julia> besselj(0.4, -Complex(2.5))
0.07472989529876822 + 0.22999496849584836im

However, we do not yet support arguments with non zero imaginary components.

Edit: the answer in higher precision is `0.07472989529876900979841 +0.2299949684958517462472im

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

Successfully merging a pull request may close this issue.

1 participant