Skip to content

Instantly share code, notes, and snippets.

@rygorous
Created November 30, 2021 23:34
Show Gist options
  • Save rygorous/344477061813ffa9d9050cdbac728870 to your computer and use it in GitHub Desktop.
Save rygorous/344477061813ffa9d9050cdbac728870 to your computer and use it in GitHub Desktop.
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