\\% Chebyshev polynomials. \\ Author: Joerg Arndt \\ License: GPL version 3 or later \\ online at http://www.jjj.de/pari/ \\ version: 2011-January-19 (12:52) chebyT(n,x)= return( ([1, x]*[0,-1; 1,2*x]^n)[1] ); chebyU(n,x)= return( ([1, 2*x]*[0,-1; 1,2*x]^n)[1] ); chebyTsym(n, x)= { local(b, s); if ( n<0, n = -n ); \\ symmetry if ( n==1, return( x ) ); \\ avoid division by zero b = 2^(n-1); if ( 0==n%2, if ( 0==n%4, s=+1, s=-1 ), s=0 ); forstep (k=n, 1, -2, s += b*x^(k); b *= -(k*(k-1))/((n+k-2)*(n-k+2)); ); return( s ); } /* ----- */ chebyUsym(n, x)= { local(b, s); if ( n<=0, if ( n>=-2, return( n+1 ) ); return( -chebyUsym( -n-2, x ) ); \\ use symmetry ); n += 1; b = 2^(n-1) / n; s = 0; forstep (k=n, 1, -2, s += (k)*b*x^(k-1); b *= -(k*(k-1))/((n+k-2)*(n-k+2)); ); return( s ); } /* ----- */ \\ ==== end of file ====