Skip to content

Commit 9761850

Browse files
add more modified Chebyshev moments
change log-chebyshev sign
1 parent 39c65a2 commit 9761850

File tree

2 files changed

+51
-5
lines changed

2 files changed

+51
-5
lines changed

src/specialfunctions.jl

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,34 @@ function chebyshevmoments1(::Type{T}, N::Int) where T
268268
μ
269269
end
270270

271+
"""
272+
Modified Chebyshev moments of the first kind:
273+
274+
```math
275+
\\int_^a T_n(x) {\\rm\\,d}x.
276+
```
277+
"""
278+
function chebyshevmoments1(::Type{T}, N::Int, a::T) where T
279+
μ = zeros(T, N)
280+
μ[1] = a
281+
μ[2] = a^2/2
282+
θ = acos(a)
283+
for i = 2:N-1
284+
@inbounds μ[i+1] = (cos((i+1)*θ)/(i+1) - cos((i-1)*θ)/(i-1))/2
285+
end
286+
μ
287+
end
288+
289+
function chebyshevmoments1(::Type{T}, N::Int, a::NTuple{L, T}, w::NTuple{M, T}) where {T, L, M}
290+
@assert L == M+1
291+
@assert M > 0
292+
μ = zeros(T, N)
293+
for k in 1:M
294+
μ .+= w[k]*(chebyshevmoments1(T, N, a[k+1]) - chebyshevmoments1(T, N, a[k]))
295+
end
296+
μ
297+
end
298+
271299
"""
272300
Modified Chebyshev moments of the first kind with respect to the Jacobi weight:
273301
@@ -291,22 +319,40 @@ end
291319
Modified Chebyshev moments of the first kind with respect to the logarithmic weight:
292320
293321
```math
294-
\\int_{-1}^{+1} T_n(x) \\log\\left(\\frac{1-x}{2}\\right){\\rm\\,d}x.
322+
\\int_{-1}^{+1} T_n(x) \\log\\left(\\frac{2}{1-x}\\right){\\rm\\,d}x.
295323
```
296324
"""
297325
function chebyshevlogmoments1(::Type{T}, N::Int) where T
298326
μ = zeros(T, N)
299-
N > 0 && (μ[1] = -two(T))
327+
N > 0 && (μ[1] = two(T))
300328
if N > 1
301-
μ[2] = -one(T)
329+
μ[2] = one(T)
302330
for i=1:N-2
303-
cst = isodd(i) ? T(4)/T(i^2-4) : T(4)/T(i^2-1)
331+
cst = isodd(i) ? T(4)/T(4-i^2) : T(4)/T(1-i^2)
304332
@inbounds μ[i+2] = ((i-2)*μ[i]+cst)/(i+2)
305333
end
306334
end
307335
μ
308336
end
309337

338+
"""
339+
Modified Chebyshev moments of the first kind with respect to the log-Chebyshev weight:
340+
341+
```math
342+
\\int_{-1}^{+1} T_n(x) \\log\\left(\\frac{2}{1-x}\\right)\\frac{{\\rm d}x}{\\sqrt{1-x^2}}.
343+
```
344+
"""
345+
function chebyshevlogchebyshevmoments1(::Type{T}, N::Int) where T
346+
μ = zeros(T, N)
347+
N > 0 && (μ[1] = 2*log(T(2))*π)
348+
if N > 1
349+
for i=1:N-1
350+
@inbounds μ[i+1] = T(π)/i
351+
end
352+
end
353+
μ
354+
end
355+
310356
"""
311357
Modified Chebyshev moments of the first kind with respect to the absolute value weight:
312358

test/grammatrixtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ end
6464
R = plan_cheb2jac(T, n, α, β; normjac=true)*I
6565
@test F.U R
6666

67-
μ = -FastTransforms.chebyshevlogmoments1(T, 2n-1)
67+
μ = FastTransforms.chebyshevlogmoments1(T, 2n-1)
6868
G = ChebyshevGramMatrix(μ)
6969
F = cholesky(G)
7070
@test F.L*F.L' G

0 commit comments

Comments
 (0)