                  /**  Orthogonal polynomials  **/
 
/*K: special functions; orthogonal polynomials; Her; Lag; LegP; CheT; 
        CheU; Geg; JacP; Hermite; Laguerre; Legendre; Chebyshef; 
        Gegenbauer; ultraspherical; Jacobi; polynomials */
/*A: G.Beall */
/*S: Inference Corp. */
/*D: March 1985 */
/*U: November 1985 */
/*QV: XOp1; XOp2; XOp3; XOpR */
 
/*R: Abramowitz,M. and I.Stegun, Handbook of Mathematical Functions, 
        Ch.22, Dover Publications, Inc., New York, 1964 */
 
/* The Associated Laguerre polynomials were incorrectly defined. */

/* This file produces explicit Hermite, Laguerre, Legendre, Chebyshef,
        Gegenbauer (ultraspherical), and Jacobi polynomials.  The functions 
        are named by appending a 'P' to the normal SMP names and accept the 
        same syntax as the SMP internal functions. */
 
/*E:
 
SMP 1.5.0   (May 14 1986)
Mon Feb 16 16:10:31 1987


#I[1]::  <XOp

#I[2]::  HerP[4,x]

		  2       4
#O[2]:   12 - 48 x  + 16 x

#I[3]::  LagP[3,x]

		      2    3
#O[3]:   6 - 18x + 9 x  - x

#I[4]::  LagP[4,2,x]

			2         4
		    15 x     3   x
#O[4]:   15 - 20x + ----- - x  + --
		      2 	 24

#I[5]::  LegPP[5,x]

		   3       5
	 15x - 70 x  + 63 x
#O[5]:   -------------------
		  8

#I[6]::  LegPP[3,1,x]

		 2 1/2  	2
	 - (1 - x )    (3 - 15 x )
#O[6]:   -------------------------
		     2

#I[7]::  CheTP[5,x]

		  3       5
#O[7]:   5x - 20 x  + 16 x

#I[8]::  CheUP[7,x]

		   3        5        7
#O[8]:   -8x + 80 x  - 192 x  + 128 x

#I[9]::  GegP[4,3,x]

		  2        4
#O[9]:   6 - 120 x  + 240 x

#I[10]::  JacPP[5,4,3,x]

			    2        3        4 	5
			91 x    455 x    455 x    1547 x
#O[10]:   7/8 + 91x/8 - ----- - ------ + ------ + -------
			  4       4        8         8

#I[11]::  <end>
*/
 
<XComb

/*: HerP[$n,$x]
        produces an explicit Hermite polynomial */
 
        HerP_: Tier     
        HerP[$n_=Natp[$n]|$n=0,$x] :: Ex[$n!*Sum[(-1)^%#m/(%#m!*($n-2%#m)!)* \
                                        (2x)^($n-2%#m),{%#m,0,Floor[$n/2]}]]
 
/*: LagP[$n,($a:0),$x]
        produces an explicit (Associated) Laguerre polynomial */
 
        LagP_: Tier     
        LagP[$n_=Natp[$n]|$n=0,$a_=Symbp[$a]|$a>-1,$x] :: \
                        Sum[(-1)^%#m Comb[$n+$a,$n-%#m]/%#m!*$x^%#m, \
                                {%#m,0,$n}]
        LagP[$n_=Natp[$n]|$n=0,$x] :: \
                        Sum[(-1)^%#m Comb[$n,$n-%#m]$n!/%#m!*$x^%#m,{%#m,0,$n}]
 
/*: LegPP[$l,($m:0),$x]
        produces an explicit (Associated) Legendre polynomial */
 
        LegPP_: Tier
        LegPP[$n_=Natp[$n]|$n=0,$x] :: Ncfac[1/2^($n) Sum[(-1)^%#m Comb[$n,%#m]\
                                        Comb[2$n-2%#m,$n]*$x^($n-2%#m), \
                                        {%#m,0,Floor[$n/2]}]]
        LegPP[$n_=Natp[$n]|$n=0,$m_=Natp[$m]&$m<=$n,$x] :: \
                        (1-$x^2)^($m/2) D[LegPP[$n,$x],{$x,$m}]
	LegPP[$n,0,$x] :: LegPP[$n,$x]

/*: CheTP[$n,$x]
        produces an explicit Chebyshef polynomial of the 1st kind */
 
        CheTP_: Tier
        CheTP[0,$x] : 1
        CheTP[$n_=Natp[$n]|$n=0,$x] :: Ex[$n/2 Sum[(-1)^%#m ($n-%#m-1)!/ \
                        (%#m!*($n-2%#m)!) (2x)^($n-2%#m),{%#m,0,Floor[$n/2]}]]
 
/*: CheUP[$n,$x]
        produces an explicit Chebyshef polynomial of the 2nd kind */
 
        CheUP_: Tier
        CheUP[$n_=Natp[$n]|$n=0,$x] :: Sum[(-1)^%#m ($n-%#m)!/(%#m!*($n-2%#m)!)* \
                         (2x)^($n-2%#m),{%#m,0,Floor[$n/2]}]
 
/*: GegP[$n,($a:0),$x]
        produces an explicit Gegenbauer (ultraspherical) polynomial */
 
        GegP_: Tier
        GegP[$n,$x] :: Geg[$n,0,$x]
        GegP[0,0,$x] :: 1
        GegP[$n_=Natp[$n],0,$x] :: Sum[(-1)^%#m ($n-%#m-1)!/(%#m!*($n-2%#m)!)*\
                                (2$x)^($n-2%#m),{%#m,0,Floor[$n/2]}]
        GegP[$n_=Natp[$n]|$n=0,$a_=Natp[$a],$x] :: Ex[1/($a-1)!*Sum[(-1)^%#m \
                                ($n-%#m+$a-1)!/(%#m!*($n-2%#m)!)(2$x)^($n-2%#m), \
                                {%#m,0,Floor[$n/2]}]]
        GegP[$n_=Natp[$n]|$n=0,$a_=~Intp[$a]&$a>-1/2,$x] :: Ex[1/Gamma[$a] \
                                Sum[(-1)^%#m Gamma[$a+$n-%#m]/ \
                                (%#m!*($n-2%#m)!) (2$x)^($n-2%#m), \
                                {%#m,0,Floor[$n/2]}]]
 
/*: JacPP[$n,$a,$b,$x]
        produces an explicit Jacobi polynomial */
 
        JacPP_: Tier    
        JacPP[$n_=Natp[$n]|$n=0,$a_=Natp[$a]|$a=0,$b_=Natp[$b]|$b=0,$x] :: \ 
                        Ex[($n+$a)!/($n!*($n+$a+$b)!) \
                        Sum[Comb[$n,%#m] ($a+$b+$n+%#m)!/(2^%#m ($a+%#m)!)* \
                        ($x-1)^%#m,{%#m,0,$n}],,,,0]                  
        JacPP[$n_=Natp[$n]|$n=0,$a_=$a>-1,$b_=$b>-1,$x] :: \ 
                        Ex[Gamma[$n+$a+1]/($n!*Gamma[$n+$a+$b+1]) \
                        Sum[Comb[$n,%#m] Gamma[$a+$b+$n+%#m+1]/ \
                        (2^%#m Gamma[$a+%#m+1])($x-1)^%#m,{%#m,0,$n}],,,,1]  
 
 
/* factorial simplification rules */
/*$x/($y_=Nc[$y]<0)! : 0
$x/(($y_=Nc[$y]<0)!*$$y) : 0
($x_=Nc[$x])!/$y : 0*/

/*B: The restriction of Comb to integer values is unneccessary. The definition
in XComb overcomes this and hence the orthogonal polynomials may be directly 
copied from Abramowitz and Stegun. The LagP,GegP and JacPP should be rewritten.
The factorial simplification rules are also dangerous in that they would force
(-1/2)!: 0 */
