Repository navigation
Keep the basis family in substitution - #90
Merged
Merged
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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) * qis computed with the three-term recurrence, where multiplication by a variablex p_n = (d p_{n+1} - b p_n - c p_{n-1}) / aalso 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 exactRational{BigInt}computation: