# Special function (airy function) with arbitrary precision

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?

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

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.

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

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:

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