Skip to content

Fix NaN in th_jac2jac/th_jac2cheb when γ+β+1 == 0 - #271

Merged
dlfivefifty merged 1 commit into
masterfrom
jac2jac-zero-dl
Oct 1, 2026
Merged

dlfivefifty merged 1 commit into
masterfrom
jac2jac-zero-dl

Conversation

@dlfivefifty

Copy link
Copy Markdown
Member

th_jac2cheb(x, -0.25, -0.25) (and similar, e.g. th_jac2jac(x, -0.25, -0.25, 0.5, 0.5)) returned NaN in the first entry for every length.

The conversion is split into two Toeplitz-dot-Hankel steps. With α = β = -0.25, _nearest_jacobi_par gives exactly -1/2 for the intermediate parameters. The left diagonal (2k+λ)Λ(k,λ,μ) therefore has λ = γ+β+1 = 0, so its k = 0 entry is 0*Γ(0)/Γ(μ) = 0*Inf. This PR computes that entry as Γ(λ+1)/Γ(μ), using λΓ(λ) = Γ(λ+1). It is the same value for λ ≠ 0 and the correct limit at λ = 0.

This shows up in ClassicalOrthogonalPolynomials.jl: (ChebyshevT() \\ Ultraspherical(0.25))[1:10,1:10] now goes through th_jac2cheb(·, -0.25, -0.25).

The PR adds regression tests and bumps the version to 0.17.3.

🤖 Generated with Claude Code

e.g. th_jac2cheb(x, -0.25, -0.25) returned NaN in the first entry: the
second Toeplitz-dot-Hankel step converts to (-1/2,-1/2) from β = -1/2 so the
left diagonal is (2k+λ)Λ(k,λ,μ) with λ = 0, which is 0*Inf at k = 0. Use
λΓ(λ) = Γ(λ+1) for that entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dlfivefifty added a commit to JuliaApproximation/ClassicalOrthogonalPolynomials.jl that referenced this pull request Oct 1, 2026
Fixes NaN in the first row of ChebyshevT() \ Ultraspherical(0.25),
which now goes through th_jac2cheb(·, -0.25, -0.25)
(JuliaApproximation/FastTransforms.jl#271).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.48%. Comparing base (5126667) to head (bc9344c).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #271      +/-   ##
==========================================
+ Coverage   77.45%   77.48%   +0.02%     
==========================================
  Files          17       17              
  Lines        3229     3233       +4     
==========================================
+ Hits         2501     2505       +4     
  Misses        728      728              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dlfivefifty
dlfivefifty merged commit e4376f2 into master Oct 1, 2026
19 of 20 checks passed
dlfivefifty added a commit to JuliaApproximation/ClassicalOrthogonalPolynomials.jl that referenced this pull request Oct 1, 2026
* Add ConnectionMatrix for dense conversions using FastTransforms

Conversions between Chebyshev, Legendre, Ultraspherical and Jacobi whose
matrices are dense (non-integer parameter differences) now return a
ConnectionMatrix. Multiplying or dividing coefficients with finitely many
non-zeros applies FastTransforms Toeplitz-dot-Hankel transforms, and finite
sections are computed with a single transform.

This adds support for ChebyshevT \ Ultraspherical(λ) and
Ultraspherical \ Ultraspherical with non-integer differences, and
Jacobi \ Jacobi with non-integer differences, which previously threw.
In particular findall(iszero, diff(f)) now works for Legendre expansions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Add ConnectionMatrix to the docs

Fixes the :missing_docs error in the Documentation build.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* improvements

* Require FastTransforms 0.17.3

Fixes NaN in the first row of ChebyshevT() \ Ultraspherical(0.25),
which now goes through th_jac2cheb(·, -0.25, -0.25)
(JuliaApproximation/FastTransforms.jl#271).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* use explicit formulas for getindex

* Cover remaining ConnectionMatrix lines in tests

Test size/copy, column sections, integer coefficients, a conversion with a
negative integer parameter difference and a directly constructed
Ultraspherical/Jacobi ConnectionMatrix. Remove two unreachable methods.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant