I am solving equations which requires to evaluate Airy function and its derivative at high precision.
Although the package SpecialFunctions
provides airyai
and airyaiprime
function,
the airyaiprime
does not accept BigFloat
as parameter.
I have also tried ArbNumerics
. But when I do
>>>using ArbNumerics
>>>airyai(ArbFloat(0.0))
the program simply collapse and quit.
Is there any other packages which provides Airy functions (or more generally, special functions) with arbitrary precision?
Dan
January 9, 2024, 4:30am
2
It seems to take BigFloat alright in 1.10
| | |_| | | | (_| | | Version 1.10.0 (2023-12-25)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
julia> using SpecialFunctions
julia> airyai(BigFloat(0.5))
0.2316936064808334897691252545099217396183864753577499817922638265232339844931842
(@v1.10) pkg> status SpecialFunctions
[276daf66] SpecialFunctions v2.3.1
1 Like
Thank you for your reply.
sorry I made a mistake.
The airyai
does accept BigFloat
.
However, I also need to calculate its derivative, using airyaiprime
.
It is airyaiprime
that cannot calculate BigFloat.
I have already updated to julia v1.10 and SpecialFunction v2.3.1,
but it still doesn’t work.
I have modified the main post.
Dan
January 9, 2024, 5:33am
4
Works with ArbNumerics (perhaps the setprecision
is needed):
julia> using ArbNumerics
julia> setprecision(ArbFloat, precision(BigFloat))
256
julia> a = ArbFloat(0.0)
0
julia> result = airyaiprime(a)
-0.25881940379280679840518356018920396347909113835493458221000181385610277267679
(@v1.10) pkg> status ArbNumerics
Status `~/.julia/environments/v1.10/Project.toml`
[7e558dbc] ArbNumerics v1.3.3
1 Like
Thank you.
After more test, I found that ArbNumerics
works fine on my Mac.
However, on my win11 laptop, airyaiprime(ArbFloat(0.0))
will lead to crash.
I think this is a bug of the package.
1 Like
Dan
January 9, 2024, 11:21pm
7
baizhan:
lead to crash
Yeah, probably is a bug. Can you show the printout of the crash? Opening an issue is definitely needed.
My guess is that this is likely related to differences in Int
type lengths in C (specifically, windows makes long
and thus Julia’s CInt
32 bits, while on mac and linux, long
is 64 bits).
Also it looks like this issue is at least reported:
opened 04:49AM - 05 Aug 23 UTC
Maybe I'm doing it wrong, but it looks like there is a problem with airyaiprime … and BigFloats:
```
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.9.0 (2023-05-07)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
julia @v1.9> using ArbNumerics
[ Info: Precompiling ArbNumerics [7e558dbc-694d-5a72-987c-6f4ebed21442]
julia @v1.9> ArbNumerics.airyai(BigFloat(0))
0.3550280538878172392600631860041831763979791741991772405833265103008100424501266
julia @v1.9> ArbNumerics.airyaiprime(BigFloat(0))
ERROR: MethodError: no method matching airyaiprime(::Complex{BigFloat})
Closest candidates are:
airyaiprime(::Complex{<:AbstractFloat})
@ SpecialFunctions ~/julia-versions/dot_julia/packages/SpecialFunctions/sKqs4/src/bessel.jl:168
airyaiprime(::Complex)
@ SpecialFunctions ~/julia-versions/dot_julia/packages/SpecialFunctions/sKqs4/src/bessel.jl:165
airyaiprime(::ArbComplex{P}) where P
@ ArbNumerics ~/julia-versions/dot_julia/packages/ArbNumerics/OJfxd/src/float/airy.jl:53
...
Stacktrace:
[1] airyaiprime(z::Complex{BigFloat})
@ SpecialFunctions ~/julia-versions/dot_julia/packages/SpecialFunctions/sKqs4/src/bessel.jl:168
[2] airyaiprime(x::BigFloat)
@ SpecialFunctions ~/julia-versions/dot_julia/packages/SpecialFunctions/sKqs4/src/bessel.jl:173
[3] top-level scope
@ REPL[3]:1
```
baizhan
January 10, 2024, 2:19am
10
The problem is, there is no printout at all.
The julia REPL simply quit without any warning.
1 Like
If you can’t get around the crash you could also consider using Arblib.jl instead. In that case you could also compute the value and derivative (and higher order derivatives) simultaneously using ArbSeries
.
julia> using Arblib, SpecialFunctions
julia> airyai(Arb(0))
[0.35502805388781723926006318600418317639797917419917724058332651030081004245013 +/- 7.76e-78]
julia> airyaiprime(Arb(0))
[-0.25881940379280679840518356018920396347909113835493458221000181385610277267679 +/- 7.31e-78]
julia> airyai(ArbSeries((0, 1)))
[0.35502805388781723926006318600418317639797917419917724058332651030081004245013 +/- 7.76e-78] + [-0.25881940379280679840518356018920396347909113835493458221000181385610277267679 +/- 7.31e-78]â‹…x + đť’Ş(x^2)
If you don’t need the ball enclosure provided by the Arb
type you can convert it to BigFloat
after computing the Airy-function of course!
1 Like