Created
November 30, 2021 23:34
-
-
Save rygorous/344477061813ffa9d9050cdbac728870 to your computer and use it in GitHub Desktop.
Chebyshev evaluation pseudocode
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
# Chebyshev evaluation with interval rescaled to [0,1] | |
xp = 2*x - 1 # remap to [-1,1] that Cheb basis is easier in | |
# Constant and linear terms | |
result = coeffs[0] + xp*coeffs[1] | |
# Recurrence for remaining terms | |
cur, prev = xp, 1 | |
t = xp * 2 | |
for c in coeffs[2:]: | |
# Compute next-higher basis function from two previus ones | |
cur, prev = t * cur - prev , cur | |
# Accumulate contribution | |
result += c * cur | |
return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment