01-23-2022, 07:52 PM
The three programs listed here compute the values of the Gegenbauer polynomials C(n, a, x), renormalized Gegenbauer polynomials C(n, x) and Jacobi polynomials P(n, a, b, x) at x. The Jacobi polynomials are a generalization of the Gegenbauer polynomials, which in turn are generalizations of Chebyshev and Legendre polynomials.
The value of n must be an integer; a, b, and x may be any numeric or symbolic data type. If the value of x is 'X' the programs will return an expression in X similar to the built-in polynomial functions.
The programs can be run on the HP48 if NIP is replaced by SWAP DROP, UNROT is replaced by ROT ROT, PICK3 is replaced by 3 PICK and I\->R removed. Also in RGEGEN, \oo (infinity) can be replaced by MAXR.
The programs are listed as a directory object for convenience but there are no dependencies between them.
The value of n must be an integer; a, b, and x may be any numeric or symbolic data type. If the value of x is 'X' the programs will return an expression in X similar to the built-in polynomial functions.
The programs can be run on the HP48 if NIP is replaced by SWAP DROP, UNROT is replaced by ROT ROT, PICK3 is replaced by 3 PICK and I\->R removed. Also in RGEGEN, \oo (infinity) can be replaced by MAXR.
The programs are listed as a directory object for convenience but there are no dependencies between them.
Code:
DIR
GEGEN
\<< UNROT DUP2 2 * EVAL SWAP I\->R \-> x n a a2 r
\<< 1 a2 x * EVAL
IF r 1. >
THEN 2 n
FOR k DUP k a + 1 - * x 2 * * EVAL
ROT k a2 + 2 - * - k / EVAL
NEXT NIP
ELSE r 1. SAME { NIP } { DROP } IFTE
END
\>>
\>>
RGEGEN
\<< DUP2 2 * EVAL SWAP I\->R \-> n x x2 r
\<<
IF r 1. >
THEN 2 x2 2 n
START DUP x2 * ROT - EVAL
NEXT NIP n / EVAL
ELSE r 1. SAME x2 \oo IFTE
END
\>>
\>>
JACPOLY
\<< PICK3 SQ PICK3 SQ - 0 \-> n a b x c m
\<< 1 a b + 2 + x 1 - * 2 / a 1 + + EVAL
IF n I\->R 1. >
THEN 2 n
FOR k k 2 * a + b + EVAL 'm' STO
DUP m DUP 2 - * x * c + m 1 - * * EVAL
ROT k 1 - DUP a + SWAP b + * 2 * m * * - EVAL
m 2 - k a + b + * k 2 * * / EVAL
NEXT NIP
ELSE n I\->R 1. SAME { NIP } { DROP } IFTE
END
\>>
\>>
END