'**************************************************** '* Program to demonstrate Legendre coefficients * '* ------------------------------------------------ * '* Reference: BASIC Scientific Subroutines, Vol. II * '* By F.R. Ruckdeschel, BYTE/McGRAWW-HILL, 1981 [1].* '* * '* ------------------------------------------------ * '* SAMPLE RUN: * '* * '* Legendre polynomial coefficients for order 2 * '* * '* A( 0) = -0.500000 * '* A( 1) = 0.000000 * '* A( 2) = 1.500000 * '* * '* to continue... * '* * '* Legendre polynomial coefficients for order 3 * '* * '* A( 0) = 0.000000 * '* A( 1) = -1.500000 * '* A( 2) = 0.000000 * '* A( 3) = 2.500000 * '* * '* to continue... * '* * '* Legendre polynomial coefficients for order 4 * '* * '* A( 0) = 0.375000 * '* A( 1) = 0.000000 * '* A( 2) = -3.750000 * '* A( 3) = 0.000000 * '* A( 4) = 4.375000 * '* * '* to continue... * '* * '* Legendre polynomial coefficients for order 5 * '* * '* A( 0) = 0.000000 * '* A( 1) = 1.875000 * '* A( 2) = 0.000000 * '* A( 3) = -8.750000 * '* A( 4) = 0.000000 * '* A( 5) = 7.875000 * '* * '* to continue... * '* * '* Legendre polynomial coefficients for order 6 * '* * '* A( 0) = -0.312500 * '* A( 1) = 0.000000 * '* A( 2) = 6.562500 * '* A( 3) = 0.000000 * '* A( 4) = -19.687500 * '* A( 5) = 0.000000 * '* A( 6) = 14.437500 * '* * '* to continue... * '* * '* Legendre polynomial coefficients for order 7 * '* * '* A( 0) = 0.000000 * '* A( 1) = -2.187500 * '* A( 2) = 0.000000 * '* A( 3) = 19.687500 * '* A( 4) = 0.000000 * '* A( 5) = -43.312500 * '* A( 6) = 0.000000 * '* A( 7) = 26.812500 * '* * '* to continue... * '* * '* Legendre polynomial coefficients for order 8 * '* * '* A( 0) = 0.273438 * '* A( 1) = 0.000000 * '* A( 2) = -9.843750 * '* A( 3) = 0.000000 * '* A( 4) = 54.140625 * '* A( 5) = 0.000000 * '* A( 6) = -93.843750 * '* A( 7) = 0.000000 * '* A( 8) = 50.273438 * '* * '* to continue... * '* * '* Legendre polynomial coefficients for order 9 * '* * '* A( 0) = 0.000000 * '* A( 1) = 2.460938 * '* A( 2) = 0.000000 * '* A( 3) = -36.093750 * '* A( 4) = 0.000000 * '* A( 5) = 140.765625 * '* A( 6) = 0.000000 * '* A( 7) = -201.093750 * '* A( 8) = 0.000000 * '* A( 9) = 94.960938 * '* * '* to continue... * '* * '* Legendre polynomial coefficients for order 10 * '* * '* A( 0) = -0.246094 * '* A( 1) = 0.000000 * '* A( 2) = 13.535156 * '* A( 3) = 0.000000 * '* A( 4) = -117.304688 * '* A( 5) = 0.000000 * '* A( 6) = 351.914063 * '* A( 7) = 0.000000 * '* A( 8) = -427.324219 * '* A( 9) = 0.000000 * '* A(10) = 180.425781 * '* * '**************************************************** defint i-n defdbl a-h,o-z cls dim A(10),B(10,10) for n=2 to 10 print print " Legendre polynomial coefficients for order"; n print gosub 1000 for k=0 to n print using " A(##) = ####.######"; k; A(k) next k print if n <> 10 then input r$ next n print end '****************************************************** '* Legendre series coefficients evaluation subroutine * '* by means of recursion relation. The order of the * '* polynomial is n. The coefficients are returned in * '* A(i). * '****************************************************** 1000 'Establish p0 and p1 coefficients B(0,0)=1 : B(1,0)=0 : B(1,1)=1 'Return if order is less then 2 if n<2 then return for i=2 to n B(i,0)=-(i-1)*B(i-2,0)/i for j=1 to i 'Basic recursion relation B(i,j)=(i+i-1)*B(i-1,j-1)-(i-1)*B(i-2,j) B(i,j)=B(i,j)/i next j next i for i=0 to n A(i)=B(n,i) next i return 'End of file Legendre.bas