Skip to content

Keep the basis family in substitution - #90

Merged
blegat merged 1 commit into
masterfrom
bl/subs_basis
Nov 9, 2026
Merged

blegat merged 1 commit into
masterfrom
bl/subs_basis

Conversation

@blegat

@blegat blegat commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Substituting into a polynomial in a ScaledMonomial or orthogonal basis returned a polynomial in the monomial basis, so p - p(x => A * x) errored as basis families are no longer silently promoted.

For ScaledMonomial, the substitution is still computed in the monomial basis and the result is converted back, which is a diagonal scaling.

For orthogonal bases, going through the monomial basis is ill-conditioned, so the substitution is now computed in the orthogonal basis itself: p_n(v) * q is computed with the three-term recurrence, where multiplication by a variable x p_n = (d p_{n+1} - b p_n - c p_{n-1}) / a also follows from the recurrence. This works for every AbstractMultipleOrthogonal family with recurrence coefficients, while converting from the monomial basis is only implemented for Chebyshev. Evaluation at numbers also uses the recurrence now.

Relative error on the coefficients of T_n(0.3x + 0.1) in the Chebyshev basis, compared to an exact Rational{BigInt} computation:

degree n old (monomial round trip) new (recurrence)
5 1.2e-16 3.2e-17
10 1.0e-15 2.1e-16
20 7.7e-15 2.5e-16
30 5.6e-13 3.3e-16
40 4.4e-12 5.9e-16

Substituting into a polynomial in a ScaledMonomial or orthogonal basis
returned a polynomial in the monomial basis, so `p - p(x => A * x)`
errored as basis families are no longer silently promoted.

For ScaledMonomial, the substitution is still computed in the monomial
basis and the result is converted back, which is a diagonal scaling.

For orthogonal bases, going through the monomial basis is
ill-conditioned, so the substitution is now computed in the orthogonal
basis itself: `p_n(v) * q` is computed with the three-term recurrence,
where multiplication by a variable `x p_n = (d p_{n+1} - b p_n - c p_{n-1}) / a`
also follows from the recurrence. This works for every
AbstractMultipleOrthogonal family with recurrence coefficients, while
converting from the monomial basis is only implemented for Chebyshev.
Evaluation at numbers also uses the recurrence now.

Relative error on the coefficients of `T_n(0.3x + 0.1)` in the
Chebyshev basis, compared to an exact `Rational{BigInt}` computation:

| degree n | old (monomial round trip) | new (recurrence) |
|---|---|---|
| 5 | 1.2e-16 | 3.2e-17 |
| 10 | 1.0e-15 | 2.1e-16 |
| 20 | 7.7e-15 | 2.5e-16 |
| 30 | 5.6e-13 | 3.3e-16 |
| 40 | 4.4e-12 | 5.9e-16 |
@codecov

codecov Bot commented Nov 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.75%. Comparing base (27847ac) to head (e381f3b).

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #90      +/-   ##
==========================================
+ Coverage   90.20%   91.75%   +1.54%     
==========================================
  Files          12       12              
  Lines         480      570      +90     
==========================================
+ Hits          433      523      +90     
  Misses         47       47              

☔ 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.

@blegat
blegat merged commit ef43159 into master Nov 9, 2026
6 checks passed
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