4 ms·
Also pretty easy: import numpy as np p = np.polynomial.Chebyshev.interpolate(f, degree, domain=(xmin, xmax)) # insert your code to print out some C cod
by sfpotter 2y ago
Also pretty easy:
import numpy as np
p = np.polynomial.Chebyshev.interpolate(f, degree, domain=(xmin, xmax))
# insert your code to print out some C code
Also strongly recommend some basic familiarity with the theory. Approximating `Math.abs(x)` to even a few digits of uniform accuracy on any interval containing 0 requires tens if not hundreds of thousands of coefficients.
- lainga 2y agowhat does the # insert your code to print out some C code mean?
- sfpotter 2y agoFor instance, maybe I want to define an array of these coefficients in C. I could do: print('double coef[] = {') for c in p.coef: print(f' {c:0.16g},') print('};') and copy-paste it wherever I need.
- deleted 2y ago[deleted]