Skip to content

Commit 38a2707

Browse files
authored
Normalized jacobi conversion for alpha=beta=-0.5 (#227)
* Normalized jacobi conversion for alpha=beta=-0.5 * bump version to v0.6.22
1 parent 5aad10e commit 38a2707

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ApproxFunOrthogonalPolynomials"
22
uuid = "b70543e2-c0d9-56b8-a290-0d4d6d4de211"
3-
version = "0.6.21"
3+
version = "0.6.22"
44

55
[deps]
66
ApproxFunBase = "fbd15aa5-315a-5a7d-a8a4-24992e37be05"

src/Spaces/Jacobi/Jacobi.jl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,19 @@ const NormalizedJacobi{D<:Domain,R,T} = NormalizedPolynomialSpace{Jacobi{D,R,T},
2222
NormalizedJacobi(s...) = NormalizedPolynomialSpace(Jacobi(s...))
2323
NormalizedLegendre(d...) = NormalizedPolynomialSpace(Legendre(d...))
2424

25-
normalization(::Type{T}, sp::Jacobi, k::Int) where T = FastTransforms.Anαβ(k, sp.a, sp.b)
25+
function normalization(::Type{T}, sp::Jacobi, k::Int) where T
26+
if sp.a == sp.b == -0.5 && k == 0
27+
# In this case, the expression for Anαβ has a division by zero, so we evaluate this using Mathematica
28+
# In principle this may be generalized to arbitrary α + β = -1
29+
# The exact expression from Mathematica in terms of the hypergeometric 2F1 function
30+
# \fbox{$\frac{\, _2F_1(1,-\alpha ;\beta +2;-1)}{\beta +1}+\frac{\, _2F_1(1,-\beta ;\alpha +2;-1)}{\alpha +1}\text{ if }\alpha >-1\land \beta >-1$}
31+
# or, by eliminating β and expressed in terms of the polygamma function,
32+
# \fbox{$\frac{1}{2} \left(\psi ^{(0)}\left(\frac{1}{2}-\frac{\alpha }{2}\right)-\psi ^{(0)}\left(-\frac{\alpha }{2}\right)\right)+\frac{1}{2} \left(\psi ^{(0)}\left(\frac{\alpha }{2}+1\right)-\psi ^{(0)}\left(\frac{\alpha }{2}+\frac{1}{2}\right)\right)\text{ if }-1<\alpha <0$}
33+
T(pi)
34+
else
35+
FastTransforms.Anαβ(T(k), T(sp.a), T(sp.b))
36+
end
37+
end
2638

2739
function Ultraspherical(J::Jacobi)
2840
if J.a == J.b

test/JacobiTest.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ using Static
5555

5656
@testset "Conversion" begin
5757
testtransforms(Jacobi(-0.5,-0.5))
58-
@test norm(Fun(Fun(exp),Jacobi(-.5,-.5))-Fun(exp,Jacobi(-.5,-.5))) < 300eps()
58+
@test norm(Fun(Fun(exp),Jacobi(-0.5,-0.5))-Fun(exp,Jacobi(-0.5,-0.5))) < 300eps()
5959

6060
@testset for d in (-1..1, 0..1, ChebyshevInterval())
6161
@testset "Chebyshev" begin
@@ -70,6 +70,11 @@ using Static
7070
end
7171
end
7272
end
73+
# Jacobi(-0.5, -0.5) to NormalizedJacobi(-0.5, -0.5) can have a NaN in the (1,1) index
74+
# if the normalization is not carefully implemented,
75+
# so this test checks that this is not the case
76+
g = Conversion(Jacobi(-0.5,-0.5), NormalizedJacobi(-0.5,-0.5)) * Fun(x->x^3, Jacobi(-0.5, -0.5))
77+
@test coefficients(g) coefficients(Fun(x->x^3, NormalizedChebyshev()))
7378
end
7479
@testset "legendre" begin
7580
f = Fun(x->x^2, Legendre(d))

0 commit comments

Comments
 (0)