Python Forum

Full Version: Can I evaluate a Chebyshev polynomial using a function
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello everyone. I need to evaluate an arbitrary Chebyshev polynomial of order n at a point x. I have done it manually using their definition as

mt.cos(n*mt.acos(x))
However, I am not satisfied by the numerical precision of this, the results are not exact. I have searched the web for a function that does this in a more efficient way and the closest thing I have found is the Chebyshev module. However, inside of it I cannot find what I am looking for.

The first Chebyshev polynomials are P_0=1, P_1=x,P_2=2x^2-1 and so on. I need a function which output is the polynomial of the selected order evaluated at an arbitrary point. i.e. f(n=1, x=0.6)= 0.6, f(n=2, x=0.5)= 2*(0.5)^2-1 and so on.

Can someone tell me if said function exists?
Thanks.
Take a look at SymPy module. This is package for symbolic computations and computations with high precision.