'***************************************************** '* Program to demonstrate Chebyshev economization * '* ------------------------------------------------- * '* 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: ? 15 * '* * '* What is the degree of the desired economized * '* polynomial: ? 9 * '* * '* What is the range of the input polynomial: ? 1.57 * '* * '* Input the coefficients: * '* C( 0) = ? 0 * '* C( 1) = ? 1 * '* C( 2) = ? 0 * '* C( 3) = ? -.166666666 * '* C( 4) = ? 0 * '* C( 5) = ? .00833333333 * '* C( 6) = ? 0 * '* C( 7) = ? -.0001984127 * '* C( 8) = ? 0 * '* C( 9) = ? .000002755732 * '* C( 10) = ? 0 * '* C( 11) = ? -.000000025052109 * '* C( 12) = ? 0 * '* C( 13) = ? .00000000016059045 * '* C( 14) = ? 0 * '* C( 15) = ? -.00000000000076471635 * '* * '* The Chebyshev series coefficients are: * '* * '* A( 0) = 0.0000000000 * '* A( 1) = 1.1334708982 * '* A( 2) = 0.0000000000 * '* A( 3) = -0.1378841454 * '* A( 4) = 0.0000000000 * '* A( 5) = 0.0044798168 * '* A( 6) = 0.0000000000 * '* A( 7) = -0.0000674667 * '* A( 8) = 0.0000000000 * '* A( 9) = 0.0000005865 * '* A(10) = 0.0000000000 * '* A(11) = -0.0000000033 * '* A(12) = 0.0000000000 * '* A(13) = 0.0000000000 * '* A(14) = 0.0000000000 * '* A(15) = 0.0000000000 * '* * '* The economized polynomial coefficients are: * '* * '* C( 0) = 0.0000000000 * '* C( 1) = 0.9999999767 * '* C( 2) = 0.0000000000 * '* C( 3) = -1.6666647620 * '* C( 4) = 0.0000000000 * '* C( 5) = 0.0083329009 * '* C( 6) = 0.0000000000 * '* C( 7) = -0.0001980098 * '* C( 8) = 0.0000000000 * '* C( 9) = 0.0000025907 * '* * '***************************************************** DEFINT I-N DEFDBL A-H, O-Z CLS PRINT INPUT " What is the degree of the input polynomial: ", m PRINT INPUT " What is the degree of the desired economized polynomial: ", m1 PRINT INPUT " What is the range of input polynomial: ", x0 DIM A(m), B(m, m), C(m) PRINT PRINT " Input the coefficients:" PRINT FOR i = 0 TO m PRINT " C("; i; ") = "; : INPUT C(i) NEXT PRINT GOSUB 2000 PRINT " The Chebyshev series coefficients are:" PRINT FOR i = 0 TO m PRINT USING " A(##) = ##.##########"; i; A(i) NEXT PRINT : input R$ PRINT PRINT " The economized polynomial coefficients are:" PRINT FOR i = 0 TO m1 PRINT USING " C(##) = ##.##########"; i; C(i) NEXT PRINT END '******************************************************** '* Chebyshev series coefficients evaluation subroutine * '* The order of the polynomial is n. The coefficients * '* are returned in the array B(i,j), i is the degree of * '* the polynomial, j is the coefficient order. * '******************************************************** 1000 'Establish t0 and t1 coefficients B(0, 0) = 1: B(1, 0) = 0: B(1, 1) = 1 'Return if order is less than two IF n < 2 THEN RETURN FOR i = 2 TO n FOR j = 1 TO i 'Basic recursion relation B(i, j) = 2 * B(i - 1, j - 1) - B(i - 2, j) NEXT j B(i, 0) = -B(i - 2, 0) NEXT i RETURN '************************************************************ '* Chebyshev economization subroutine. The program takes * '* the input polynomial coefficients, C(i), and returns the * '* Chebyshev series coefficients, A(i). The degree of the * '* series passed to the routine is m. The degree of the * '* series returned is m1. The maximum range of x is x0 used * '* for scaling. Note that the input series coefficients are * '* nulled during the process, and then set equal to the * '* economized series coefficients. * '************************************************************ 'Start by scaling the input coefficients according to C(i) 2000 B = x0 FOR i = 1 TO m C(i) = C(i) * B: B = B * x0 NEXT 'Call Chebyshev series coefficients subroutine FOR n = m TO 0 STEP -1 GOSUB 1000 A(n) = C(n) / B(n, n) FOR l = 0 TO n 'Chebyshev series of order l is substracted out of the polynomial C(l) = C(l) - A(n) * B(n, l) NEXT l NEXT n 'Perform truncation FOR i = 0 TO m1 FOR j = 0 TO i C(j) = C(j) + A(i) * B(i, j) NEXT j NEXT i 'Convert back to the interval X0 B = 1 / x0 FOR i = 1 TO m1 C(i) = C(i) * B B = B / x0 NEXT RETURN 'End of file Chebecon.bas