|
| 1 | +# Formulas from the Digital Library of Mathematical Functions. |
| 2 | + |
| 3 | +""" |
| 4 | +Pochhammer's Symbol. |
| 5 | +
|
| 6 | +See [DLMF](https://dlmf.nist.gov/5.2#iii) formula (5.2.4). |
| 7 | +""" |
| 8 | +pochhammer(a, n) = n == 0 ? one(a) : prod(a+i for i in 0:n-1) |
| 9 | +# or in terms of the gamma function (DLMF, 5.2.5): gamma(n+a) / gamma(a) |
| 10 | + |
| 11 | +############################## |
| 12 | +# DLMF Table 18.3.1 |
| 13 | +# https://dlmf.nist.gov/18.3 |
| 14 | +############################## |
| 15 | +# Formulas for squared norm hn and leading order coefficient kn |
| 16 | + |
| 17 | +# The formula for An and A0 |
| 18 | +dlmf_18d3d1_A(α, β, n) = 2^(α+β+1)*gamma(n+α+1)*gamma(n+β+1) / (factorial(n)*(2n+α+β+1)*gamma(n+α+β+1)) |
| 19 | +dlmf_18d3d1_A0(α, β) = 2^(α+β+1)*gamma(α+1)*gamma(β+1) / gamma(α+β+2) |
| 20 | + |
| 21 | +jacobi_hn(α, β, n) = n == 0 ? dlmf_18d3d1_A0(α, β) : dlmf_18d3d1_A(α, β, n) |
| 22 | +jacobi_kn(α, β, n) = pochhammer(n+α+β+1, n) / (2^n * factorial(n)) |
| 23 | + |
| 24 | +ultraspherical_hn(λ::T, n) where T = 2^(1-2λ)*T(π)*gamma(n+2λ) / ((n+λ)*gamma(λ)^2*factorial(n)) |
| 25 | +ultraspherical_kn(λ, n) = 2^n*pochhammer(λ, n) / factorial(n) |
| 26 | + |
| 27 | +chebyshev_1st_hn(::Type{T}, n) where T = n == 0 ? T(π) : T(π)/2 |
| 28 | +chebyshev_1st_kn(::Type{T}, n) where T = n == 0 ? one(T) : T(2)^(n-1) |
| 29 | + |
| 30 | +chebyshev_2nd_hn(::Type{T}, n) where T = T(π)/2 |
| 31 | +chebyshev_2nd_kn(::Type{T}, n) where T = T(2)^n |
| 32 | + |
| 33 | +chebyshev_3rd_hn(::Type{T}, n) where T = T(π) |
| 34 | +chebyshev_3rd_kn(::Type{T}, n) where T = T(2)^n |
| 35 | + |
| 36 | +chebyshev_4rd_hn(::Type{T}, n) where T = T(π) |
| 37 | +chebyshev_4rd_kn(::Type{T}, n) where T = T(2)^n |
| 38 | + |
| 39 | +legendre_hn(::Type{T}, n) where T = 2 / T(2n+1) |
| 40 | +legendre_kn(::Type{T}, n) where T = 2^n*pochhammer(one(T)/2, n) / factorial(n) |
| 41 | + |
| 42 | +laguerre_hn(α, n) = gamma(n+α+1) / factorial(n) |
| 43 | +laguerre_kn(α::T, n) where T = (-one(T))^n / factorial(n) |
| 44 | + |
| 45 | +hermite_hn(::Type{T}, n) where T = sqrt(T(π)) * 2^n * factorial(n) |
| 46 | +hermite_kn(::Type{T}, n) where T = T(2)^n |
| 47 | + |
| 48 | + |
| 49 | +############################## |
| 50 | +# DLMF Table 18.9.1 |
| 51 | +# http://dlmf.nist.gov/18.9#i |
| 52 | +############################## |
| 53 | +# Recurrence coefficients in the form |
| 54 | +# p_{n+1}(x) = (A_n x + B_n) p_n(x) - C_n p_{n-1}(x) |
| 55 | +# with initial values |
| 56 | +# p_0(x) = 1 and p_1(x) = A_0x + B_0 |
| 57 | + |
| 58 | + |
| 59 | +# Jacobi, (18.9.2) |
| 60 | +function jacobi_rec_An(α, β, n) |
| 61 | + if (n == 0) && (α + β + 1 == 0) |
| 62 | + (α+β)/2+1 |
| 63 | + else |
| 64 | + (2*n + α + β + 1) * (2n + α + β + 2) / (2 * (n+1) * (n + α + β + 1)) |
| 65 | + end |
| 66 | +end |
| 67 | +function jacobi_rec_Bn(α, β, n) |
| 68 | + if (n == 0) && ((α + β + 1 == 0) || (α+β == 0)) |
| 69 | + (α-β)/2 |
| 70 | + else |
| 71 | + (α^2 - β^2) * (2*n + α + β + 1) / (2 * (n+1) * (n + α + β + 1) * (2*n + α + β)) |
| 72 | + end |
| 73 | +end |
| 74 | +function jacobi_rec_Cn(α, β, n) |
| 75 | + (n + α) * (n + β) * (2*n + α + β + 2) / ((n+1) * (n + α + β + 1) * (2*n + α + β)) |
| 76 | +end |
| 77 | + |
| 78 | +# Legendre |
| 79 | +legendre_rec_An(::Type{T}, n) where T = (2*n+1)/T(n+1) |
| 80 | +legendre_rec_Bn(::Type{T}, n) where T = zero(T) |
| 81 | +legendre_rec_Cn(::Type{T}, n) where T = n/T(n+1) |
| 82 | + |
| 83 | +# Ultraspherical |
| 84 | +ultraspherical_rec_An(λ, n) = 2(n+λ) / (n+1) |
| 85 | +ultraspherical_rec_Bn(λ, n) = zero(λ) |
| 86 | +ultraspherical_rec_Cn(λ, n) = (n+2λ-1) / (n+1) |
| 87 | + |
| 88 | +# Chebyshev |
| 89 | +chebyshev_1st_rec_An(::Type{T}, n) where T = n == 0 ? one(T) : T(2) |
| 90 | +chebyshev_1st_rec_Bn(::Type{T}, n) where T = zero(T) |
| 91 | +chebyshev_1st_rec_Cn(::Type{T}, n) where T = one(T) |
| 92 | +chebyshev_2nd_rec_An(::Type{T}, n) where T = T(2) |
| 93 | +chebyshev_2nd_rec_Bn(::Type{T}, n) where T = zero(T) |
| 94 | +chebyshev_2nd_rec_Cn(::Type{T}, n) where T = one(T) |
| 95 | + |
| 96 | +# Laguerre |
| 97 | +laguerre_rec_An(α::T, n) where T = -one(T)/(n+1) |
| 98 | +laguerre_rec_Bn(α, n) = (2n+α+1) / (n+1) |
| 99 | +laguerre_rec_Cn(α, n) = (n+α) / (n+1) |
| 100 | + |
| 101 | +# Hermite |
| 102 | +hermite_rec_An(::Type{T}, n) where T = T(2) |
| 103 | +hermite_rec_Bn(::Type{T}, n) where T = zero(T) |
| 104 | +hermite_rec_Cn(::Type{T}, n) where T = T(2n) |
0 commit comments