Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Finding out roots of Chebyshev's polynomials
Hello everyone.

I am constructing Chebyshev polinomials as specified here. I have replicated the fisrt part of the code succesfully as:

import numpy as np 
import sympy as sp
import mpmath as mp
from mpmath import *

f0 = lambda x: chebyt(0,x)
f1 = lambda x: chebyt(1,x)
f2 = lambda x: chebyt(2,x)
f3 = lambda x: chebyt(3,x)
f4 = lambda x: chebyt(4,x)
Now, I need to calculate the roots of said polynomials. I have found the function roots. To use it, I need to calculate the coefficients of the polynomial, that I do using the function dps as defined in the first link; the results are succesful and the coefficients are printed. However, I cannot send said output to roots.

This is my code
mp.dps = 25; mp.pretty = True 
for n in range(3):
   nprint(chop(taylor(lambda x: chebyt(n, x), 0, n)))
   nprint(np.roots(chop(taylor(lambda x: chebyt(n, x), 0, n))))
This returns

[1.0] [] [0.0, 1.0] [] [-1.0, 0.0, 2.0] [ 1.41421356 -1.41421356]
Which means that the coefficients are propperly calculated, but np.roots doesn't return the roots. Aditionally, I have found the following thread, which indicates that roots eventually fails if the order of the polynomial reaches a high enough number.

Can someone please advice me on how to proceed to calculate the roots of a Chebyshev polynomial of order n with some guarantee of doing it well enough?

Any answer is welcome.
I have figured out how to do this. My new code is as follows:

for n in range(10):
    nprint(chop(taylor(lambda x: chebyt(n, x), 0, n)))
    print(np.roots(chop(taylor(lambda x: chebyt(n, x), 0, n))[::-1]))
It seems that there was some issue with the function nprint.

I hope this is helpful
It seems that there is exact formula for Chebyshev polynomial roots/nodes.

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Can I evaluate a Chebyshev polynomial using a function player1681 1 357 Nov-22-2019, 06:33 AM
Last Post: scidam

Forum Jump:

Users browsing this thread: 1 Guest(s)