'**************************************************** '* Test program for Horner's rule * '* ------------------------------------------------ * '* Reference: BASIC Scientific Subroutines, Vol. II * '* By F.R. Ruckdeschel, BYTE/McGRAWW-HILL, 1981 [1].* '* ------------------------------------------------ * '* SAMPLE RUN: * '* * '* Input the five coefficients: * '* * '* A( 0) = ? 1 * '* A( 1) = ? 4 * '* A( 2) = ? 6 * '* A( 3) = ? 4 * '* A( 4) = ? 1 * '* * '* What is the expansion point: 1 * '* * '* The shifted coefficients are: * '* * '* B( 0) = 16 * '* B( 1) = 32 * '* B( 2) = 24 * '* B( 3) = 8 * '* B( 4) = 1 * '* * '**************************************************** defint i-n defdbl a-h,o-z dim C(4,5) cls print print " Input the five coefficients:" print for i=0 to 4 print " A(";i;") = ";:input A(i) next print input " What is the expansion point: ",x0 print gosub 1000 print print " The shifted coefficients are:" print for i=0 to 4 print " B(";i;") = ";B(i) next print end '*************************************************** '* Horner's shifting rule subroutine * '* ----------------------------------------------- * '* This routine takes a given quartic polynomial * '* and converts it to a Taylor expansion. * '* The input series coefficients are A(i), the * '* expansion point is x0. The shifted coefficients * '* are returned in B(i). * '*************************************************** 1000 for j=0 to 4 C(j,0)=A(4-j) next for i=0 to 4 C(0,i+1)=C(0,i) j=1 1100 if j > 4-i then goto 1200 C(j,i+1)=x0*C(j-1,i+1)+C(j,i) j=j+1 goto 1100 1200 next for i=0 to 4 B(4-i)=C(i,4-i+1) next return 'End of file Horner.bas