Bottom Page

• 0 Vote(s) - 0 Average
• 1
• 2
• 3
• 4
• 5
 Finding out roots of Chebyshev's polynomials player1681 Unladen Swallow Posts: 3 Threads: 2 Joined: Nov 2019 Reputation: 0 Likes received: 0 #1 Dec-02-2019, 11:48 AM 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) plot([f0,f1,f2,f3,f4],[-1,1]) ```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 ``````Output:[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. Regards. player1681 Unladen Swallow Posts: 3 Threads: 2 Joined: Nov 2019 Reputation: 0 Likes received: 0 #2 Dec-02-2019, 01:56 PM 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 scidam Posts: 582 Threads: 1 Joined: Mar 2018 Reputation: 75 Likes received: 89 #3 Dec-02-2019, 11:53 PM It seems that there is exact formula for Chebyshev polynomial roots/nodes. « Next Oldest | Next Newest »

Top Page

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

Forum Jump:

Users browsing this thread: 1 Guest(s)