05-26-2020, 07:37 PM

This program returns the value of the nth Chebyshev U polynomial at x. Note that the built-in function TCHEBYCHEFF returns the nth Chebyshev T polynomial. Chebyshev T polynomials are also known as Chebyshev polynomials of the first kind, and the U polynomials as Chebyshev polynomials of the second kind. Note also that there are many spellings of Chebyshev!

To use the program, n should be on level 2 and should be an integer. x should be on level 1; if x is an integer the result will be an integer. If x PEVAL in line 6 is removed the program will return the coefficients of the nth polynomials as a list.

To use the program, n should be on level 2 and should be an integer. x should be on level 1; if x is an integer the result will be an integer. If x PEVAL in line 6 is removed the program will return the coefficients of the nth polynomials as a list.

Code:

\<< SWAP I\->R

IF DUP 1. >

THEN \-> x n

\<< { 1 } { 2 0 } 2. n

START { 0 0 } ROT + OVER 2 * 0 + SWAP -

NEXT NIP AXL x PEVAL

\>>

ELSE 1. SAME { 2 * } { DROP 1 } IFTE

END

\>>