Skip to content

Commit c169983

Browse files
committed
add airy
1 parent 6dfcf3d commit c169983

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed

src/Bessels.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ include("besselj.jl")
3131
include("besselk.jl")
3232
include("bessely.jl")
3333
include("hankel.jl")
34+
include("airy.jl")
3435

3536
include("Float128/besseli.jl")
3637
include("Float128/besselj.jl")

src/airy.jl

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
"""
2+
airyai(x)
3+
Airy function of the first kind ``\\operatorname{Ai}(x)``.
4+
External links: [DLMF](https://dlmf.nist.gov/9.2), [Wikipedia](https://en.wikipedia.org/wiki/Airy_function)
5+
See also: [`airyaix`](@ref), [`airyaiprime`](@ref), [`airybi`](@ref)
6+
"""
7+
function airyai(x::T) where T
8+
if x > zero(T)
9+
z = 2 * x^(T(3)/2) / 3
10+
return sqrt(x / 3) * besselk(one(T)/3, z) / π
11+
elseif x < zero(T)
12+
x_abs = abs(x)
13+
z = 2 * x_abs^(T(3)/2) / 3
14+
Jv, Yv = besseljy_positive_args(one(T)/3, z)
15+
Jmv = (Jv - sqrt(T(3)) * Yv) / 2
16+
return sqrt(x_abs) * (Jmv + Jv) / 3
17+
elseif iszero(x)
18+
return inv(3^(T(2)/3) * GAMMA_TWO_THIRDS(T))
19+
end
20+
end
21+
22+
"""
23+
airyaiprime(x)
24+
Derivative of the Airy function of the first kind ``\\operatorname{Ai}'(x)``.
25+
External links: [DLMF](https://dlmf.nist.gov/9.2), [Wikipedia](https://en.wikipedia.org/wiki/Airy_function)
26+
See also: [`airyaiprimex`](@ref), [`airyai`](@ref), [`airybi`](@ref)
27+
"""
28+
function airyaiprime(x::T) where T
29+
if x > zero(T)
30+
z = 2 * x^(T(3)/2) / 3
31+
return -x * besselk(T(2)/3, z) / (sqrt(T(3)) * π)
32+
elseif x < zero(T)
33+
x_abs = abs(x)
34+
z = 2 * x_abs^(T(3)/2) / 3
35+
Jv, Yv = besseljy_positive_args(T(2)/3, z)
36+
Jmv = -(Jv + sqrt(T(3))*Yv) / 2
37+
return x_abs * (Jv - Jmv) / 3
38+
elseif iszero(x)
39+
return T(-0.2588194037928068)
40+
end
41+
end
42+
"""
43+
airybi(x)
44+
Airy function of the second kind ``\\operatorname{Bi}(x)``.
45+
External links: [DLMF](https://dlmf.nist.gov/9.2), [Wikipedia](https://en.wikipedia.org/wiki/Airy_function)
46+
See also: [`airybix`](@ref), [`airybiprime`](@ref), [`airyai`](@ref)
47+
"""
48+
function airybi(x::T) where T
49+
if x > zero(T)
50+
z = 2 * x^(T(3)/2) / 3
51+
return sqrt(x / 3) * (besseli(-one(T)/3, z) + besseli(one(T)/3, z))
52+
elseif x < zero(T)
53+
x_abs = abs(x)
54+
z = 2 * x_abs^(T(3)/2) / 3
55+
Jv, Yv = besseljy_positive_args(one(T)/3, z)
56+
Jmv = (Jv - sqrt(T(3)) * Yv) / 2
57+
return sqrt(x_abs/3) * (Jmv - Jv)
58+
elseif iszero(x)
59+
return inv(3^(T(1)/6) * GAMMA_TWO_THIRDS(T))
60+
end
61+
end
62+
63+
"""
64+
airybiprime(x)
65+
Derivative of the Airy function of the second kind ``\\operatorname{Bi}'(x)``.
66+
External links: [DLMF](https://dlmf.nist.gov/9.2), [Wikipedia](https://en.wikipedia.org/wiki/Airy_function)
67+
See also: [`airybiprimex`](@ref), [`airybi`](@ref), [`airyai`](@ref)
68+
"""
69+
function airybiprime(x::T) where T
70+
if x > zero(T)
71+
z = 2 * x^(T(3)/2) / 3
72+
return x * (besseli(T(2)/3, z) + besseli(-T(2)/3, z)) / sqrt(T(3))
73+
elseif x < zero(T)
74+
x_abs = abs(x)
75+
z = 2 * x_abs^(T(3)/2) / 3
76+
Jv, Yv = besseljy_positive_args(T(2)/3, z)
77+
Jmv = -(Jv + sqrt(T(3))*Yv) / 2
78+
return x_abs * (Jv + Jmv) / sqrt(T(3))
79+
elseif iszero(x)
80+
return T(0.4482883573538264)
81+
end
82+
end
83+
84+
const GAMMA_TWO_THIRDS(::Type{Float64}) = 1.3541179394264005
85+
const GAMMA_TWO_THIRDS(::Type{Float32}) = 1.3541179394264005f0
86+
87+
const GAMMA_ONE_THIRD(::Type{Float64}) = 2.6789385347077475
88+
const GAMMA_ONE_THIRD(::Type{Float64}) = 2.6789385347077475f0

0 commit comments

Comments
 (0)