HP Forums
(49g 50g) Chebyshev U Polynomials - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (49g 50g) Chebyshev U Polynomials (/thread-15068.html)



(49g 50g) Chebyshev U Polynomials - John Keith - 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.

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
\>>