Skip to content

Instantly share code, notes, and snippets.

@rygorous
Created November 30, 2021 23:34
Embed
What would you like to do?
Chebyshev evaluation pseudocode
# 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