Skip to content

Commit f0b71c6

Browse files
add coefficients of the right sizes
fix output sizes
1 parent 78c98fb commit f0b71c6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

examples/halfrange.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ qvals = k-> ichebyshevtransform(q(k))
4343

4444
# With the symmetric Jacobi matrix for $P_n^{(-\frac{1}{2}, 0)}(y)$ and the modified plan, we may compute the modified Jacobi matrix and the corresponding roots (as eigenvalues):
4545
XP = SymTridiagonal([-inv((4n-1)*(4n-5)) for n in 1:n+1], [4n*(2n-1)/(4n-1)/sqrt((4n-3)*(4n+1)) for n in 1:n])
46-
XQ = FastTransforms.modified_jacobi_matrix(P, XP);
46+
XQ = FastTransforms.modified_jacobi_matrix(P, XP)
47+
SymTridiagonal(XQ.dv[1:10], XQ.ev[1:9])
4748

4849
# And we plot:
4950
x = (chebyshevpoints(Float64, n+1, Val(1)) .+ 1 ) ./ 2
@@ -62,7 +63,7 @@ savefig(joinpath(GENFIGS, "halfrange.html"))
6263
###```
6364

6465
# By [Theorem 2.20](https://arxiv.org/abs/2302.08448) it turns out that the *derivatives* of the half-range Chebyshev polynomials are a linear combination of at most two polynomials orthogonal with respect to $\sqrt{(3+y)(1-y)}(1+y)$ on $(-1,1)$. This fact enables us to compute the banded differentiation matrix:
65-
= 3*u+XP[1:N+1,1:N]*u
66+
= 3*[u; 0]+XP[1:N+1, 1:N]*u
6667
v = jac2jac(v̂, -0.5, 0.0, 0.5, 1.0; norm1 = true, norm2 = true)
6768
function threshold!(A::AbstractArray, ϵ)
6869
for i in eachindex(A)
@@ -73,3 +74,4 @@ end
7374
P′ = plan_modifiedjac2jac(Float64, n+1, 0.5, 1.0, v)
7475
DP = UpperTriangular(diagm(1=>[sqrt(n*(n+1/2)) for n in 1:n])) # The classical differentiation matrix representing 𝒟 P^{(-1/2,0)}(y) = P^{(1/2,1)}(y) D_P.
7576
DQ = UpperTriangular(threshold!(P′\(DP*(P*I)), 100eps())) # The semi-classical differentiation matrix representing 𝒟 Q(y) = Q̂(y) D_Q.
77+
UpperTriangular(DQ[1:10,1:10])

0 commit comments

Comments
 (0)