Skip to content

Commit

Permalink
Define methods for airyai, airyaiprime, airybi, airybiprime
Browse files Browse the repository at this point in the history
In Julia 0.6 Airy functions have been reorganized, see
JuliaLang/julia#18050.

I will keep a method for `airy' until support for Julia 0.5 will be
dropped.
  • Loading branch information
giordano committed Dec 30, 2016
1 parent 872a8af commit 0ed88ca
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
18 changes: 18 additions & 0 deletions src/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,7 @@ end
lbeta(a::Real, b::Measurement) = lbeta(b, a)

# Airy functions
# TOOD: Remove method for `airy' when support for Julia 0.5 will be dropped.
import Base: airy

function airy(k::Integer, a::Measurement)
Expand All @@ -777,6 +778,23 @@ function airy(k::Integer, a::Measurement)
end
end

import Base: airyai, airyaiprime, airybi, airybiprime

for f in (:airyai, :airybi)
der = Symbol(string(f) * "prime")
@eval begin
function $f(a::Measurement)
x = a.val
return result($f(x), $der(x), a)
end
function $der(a::Measurement)
x = a.val
# Use Airy equation: y'' - xy = 0 => y'' = xy
return result($der(x), x * $f(x), a)
end
end
end

# Bessel functions
import Base: besselj0, besselj1, besselj, bessely0, bessely1, bessely, besselh,
besseli, besselix, besselk, besselkx
Expand Down
8 changes: 4 additions & 4 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,10 @@ for a in (x, y); test_approx_eq(lbeta(a, pi), log(beta(a, pi))); end
for a in (x, y); test_approx_eq(lbeta(e, a), log(beta(e, a))); end

# Airy functions
test_approx_eq(airy(0, x), 0.006591139357460721 ± 0.0011912976705951322)
test_approx_eq(airy(1, x), -0.01191297670595132 ± 0.0019773418072382165)
test_approx_eq(airy(2, x), 14.037328963730136 ± 2.2922214966382017)
test_approx_eq(airy(3, x), 22.922214966382015 ± 4.211198689119041)
test_approx_eq(airyai(x), 0.006591139357460721 ± 0.0011912976705951322)
test_approx_eq(airyaiprime(x), -0.01191297670595132 ± 0.0019773418072382165)
test_approx_eq(airybi(x), 14.037328963730136 ± 2.2922214966382017)
test_approx_eq(airybiprime(x), 22.922214966382015 ± 4.211198689119041)
for a in (w, x, y); test_approx_eq(airy(a), airy(0, a)); end
for a in (w, x, y); test_approx_eq(airyai(a), airy(0, a)); end
for a in (w, x, y); test_approx_eq(airyprime(a), airy(1, a)); end
Expand Down

0 comments on commit 0ed88ca

Please sign in to comment.