'**************************************************** '* Program to demonstrate the series inversion * '* ------------------------------------------------ * '* Reference: BASIC Scientific Subroutines, Vol. II * '* By F.R. Ruckdeschel, BYTE/McGRAWW-HILL, 1981 [1].* '* ------------------------------------------------ * '* SAMPLE RUN: * '* * '* What is the degree of the input polynomial: 2 * '* * '* What is the degree of the inverted polynomial: 6 * '* * '* Input the polynomial coefficients: * '* * '* A( 0) = ? 1 * '* A( 1) = ? .1 * '* A( 2) = ? .01 * '* * '* The inverted polynomial coefficients are: * '* * '* B( 0) = 1.000000 * '* B( 1) = -0.100000 * '* B( 2) = 0.000000 * '* B( 3) = 0.001000 * '* B( 4) = -0.000100 * '* B( 5) = 0.000000 * '* B( 6) = 0.000001 * '* * '**************************************************** DEFINT I-N DEFDBL A-H, O-Z CLS PRINT INPUT " What is the degree of the input polynomial: ", n PRINT INPUT " What is the degree of the inverted polynomial: ", m PRINT DIM A(m), B(m) PRINT " Input the polynomial coefficients:" PRINT FOR i = 0 TO n PRINT " A("; i; ") = "; : INPUT A(i) NEXT GOSUB 1000 PRINT PRINT " The inverted polynomial coefficients are:" PRINT FOR i = 0 TO m PRINT USING " B(##) = ##.######"; i; B(i) NEXT PRINT END '****************************************************** '* Reciprocal power series subroutine * '* -------------------------------------------------- * '* The input series coefficients are A(i). The output * '* series coefficients are B(i). The degree of the * '* input polynomial is n. The degree of the inverted * '* polynomial is m. The routine takes care of norma- * '* lization using l = A(0). * '* -------------------------------------------------- * '* Reference: Computational analysis by Henrici * ' ***************************************************** 1000 l = A(0) FOR i = 0 TO n A(i) = A(i) / l: B(i) = 0 NEXT 'Clear arrays FOR i = n + 1 TO m A(i) = 0: B(i) = 0 NEXT 'Calculate the B(i) coefficients B(0) = 1 FOR i = 1 TO m j = 1 1100 B(i) = B(i) - A(j) * B(i - j) j = j + 1 IF j <= i THEN GOTO 1100 NEXT 'Un-normalize the A(i) and B(i) FOR i = 0 TO m A(i) = A(i) * l B(i) = B(i) / l NEXT RETURN 'End of file recipro.bas