June 24 2002 10:53:00.109 AM DIVDIF_PRB A set of tests for DIVDIF. TEST01 For a divided difference polynomial: DATA_TO_DIF_DISPLAY sets up a difference table and displays intermediate calculations; DIF_APPEND appends a new data point; DIF_ANTIDERIV computes the antiderivative; DIF_DERIV computes the derivative; DIF_SHIFT_ZERO shifts all the abscissas to 0; DIF_VAL evaluates at a point. Divided difference table: 1.00000 2.00000 3.00000 4.00000 0 1.00000 4.00000 9.00000 16.0000 1 3.00000 5.00000 7.00000 2 1.00000 1.00000 3 0.00000 The divided difference polynomial: p(x) = 1.00000 + ( x - 1.00000 ) * ( 3.00000 + ( x - 2.00000 ) * ( 1.00000 + ( x - 3.00000 ) * ( 0.00000 ))) Append the data (5,25) to the table. The divided difference polynomial: p(x) = 25.0000 + ( x - 5.00000 ) * ( 6.00000 + ( x - 1.00000 ) * ( 1.00000 + ( x - 2.00000 ) * ( 0.00000 + ( x - 3.00000 ) * ( 0.00000 )))) Evaluate the table at a point. P( 2.50000 ) = 6.25000 The table, rebased at 0: p(x) = 0.00000 + ( x - 0.00000 ) * ( 0.00000 + ( x - 0.00000 ) * ( 1.00000 + ( x - 0.00000 ) * ( 0.00000 + ( x - 0.00000 ) * ( 0.00000 )))) The derivative: p(x) = 0.00000 + ( x - 0.00000 ) * ( 2.00000 + ( x - 0.00000 ) * ( 0.00000 + ( x - 0.00000 ) * ( 0.00000 ))) The antiderivative: p(x) = 0.00000 + ( x - 0.00000 ) * ( 0.00000 + ( x - 0.00000 ) * ( 0.00000 + ( x - 0.00000 ) * ( 0.333333 + ( x - 0.00000 ) * ( 0.00000 + ( x - 0.00000 ) * ( 0.00000 ))))) TEST02 Approximate Y = EXP(X) using orders 1 to 5 Evaluate at X = 2.50000 where EXP(X)= 12.1825 Order Approximate Y Error 1 1.00000 -11.1825 2 5.29570 -6.88679 3 10.8316 -1.35087 4 12.4170 0.234513 5 12.0765 -0.106004 TEST03 DIF_ROOT seeks a zero of F(x). F(X) = (X+3)*(X+1)*(X-1) Step NTAB XROOT F(XROOT) XDELT 0 2 0.500000 -2.62500 -1.50000 1 3 0.723404 -1.77490 0.223404 2 4 -0.392583 -2.20556 -1.11599 3 5 6.21006 345.975 6.60265 4 6 2.25761 21.5393 -3.95246 5 6 2.18203 19.4910 -0.755732E-01 6 6 0.874211 -0.913368 -1.30782 7 6 0.928059 -0.544848 0.538483E-01 8 6 1.04774 0.395685 0.119679 9 6 1.24007 2.28020 0.192333 10 6 1.55336 6.43362 0.313293 11 6 2.00881 15.2034 0.455451 12 6 0.554434 -2.46181 -1.45438 13 6 0.664293 -2.04730 0.109859 14 6 0.715651 -1.81266 0.513581E-01 15 6 0.728000 -1.75222 0.123489E-01 DIF_ROOT - Nonconvergence! The maximum number of steps was taken. Estimated root = 0.728000 F(X) = -1.75222 TEST04 DIF_BASIS computes Lagrange basis polynomials in difference form. The base points: 1 1.00000 2 2.00000 3 3.00000 4 4.00000 5 5.00000 The table of difference vectors defining the basis polynomials. Each column represents a polynomial. 1.00000 0.00000 0.00000 0.00000 0.00000 -1.00000 1.00000 0.00000 0.00000 0.00000 0.500000 -1.00000 0.500000 0.00000 0.00000 -0.166667 0.500000 -0.500000 0.166667 0.00000 0.416667E-01 -0.166667 0.250000 -0.166667 0.416667E-01 Evaluate basis polynomial #3 at a set of points. X Y 1.00000 0.00000 1.50000 -0.546875 2.00000 0.00000 2.50000 0.703125 3.00000 1.00000 3.50000 0.703125 4.00000 0.00000 4.50000 -0.546875 5.00000 0.00000 TEST05 POLY_BASIS computes Lagrange basis polynomials in standard form. 5.00000 -10.0000 10.0000 -5.00000 1.00000 -6.41667 17.8333 -19.5000 10.1667 -2.08333 2.95833 -9.83333 12.2500 -6.83333 1.45833 -0.583333 2.16667 -3.00000 1.83333 -0.416667 0.416667E-01 -0.166667 0.250000 -0.166667 0.416667E-01 Basis polynomial 3 in standard form: p(x) = 0.250000 * x ^ 4 - 3.00000 * x ^ 3 + 12.2500 * x ^ 2 - 19.5000 * x + 10.0000 Evaluate basis polynomial 3 at a set of points. X Y 1.00000 0.00000 1.50000 -0.546875 2.00000 0.00000 2.50000 0.703125 3.00000 1.00000 3.50000 0.703125 4.00000 0.00000 4.50000 -0.546875 5.00000 0.00000 TEST06 DIF_TO_RPOLY converts a difference table to a polynomial; DIF_SHIFT_ZERO shifts a divided difference table to all zero abscissas; These are equivalent operations! Divided difference table: 1.00000 2.00000 3.00000 4.00000 0 -2.00000 2.00000 14.0000 40.0000 1 4.00000 12.0000 26.0000 2 4.00000 7.00000 3 1.00000 Divided difference table: 1.00000 2.00000 3.00000 4.00000 0 -2.00000 2.00000 14.0000 40.0000 1 4.00000 12.0000 26.0000 2 4.00000 7.00000 3 1.00000 The divided difference polynomial: p(x) = -2.00000 + ( x - 1.00000 ) * ( 4.00000 + ( x - 2.00000 ) * ( 4.00000 + ( x - 3.00000 ) * ( 1.00000 ))) Using DIF_SHIFT_ZERO p(x) = 1.00000 * x ^ 3 - 2.00000 * x ^ 2 + 3.00000 * x - 4.00000 Using DIF_TO_RPOLY p(x) = 1.00000 * x ^ 3 - 2.00000 * x ^ 2 + 3.00000 * x - 4.00000 TEST07 NCC_RULE computes closed Newton Cotes formulas; Newton-Cotes Closed Quadrature Rule: Abscissa Weight 1 -1.00000 0.869211E-01 2 -0.714286 0.414005 3 -0.428571 0.153119 4 -0.142857 0.345945 5 0.142857 0.345944 6 0.428571 0.153125 7 0.714286 0.414004 8 1.00000 0.869213E-01 TEST08 NCO_RULE computes open Newton Cotes formulas. Newton-Cotes Open Quadrature Rule: Abscissa Weight 1 -0.777778 0.797768 2 -0.555556 -1.25133 3 -0.333333 2.21742 4 -0.111111 -0.763823 5 0.111111 -0.763842 6 0.333333 2.21741 7 0.555556 -1.25134 8 0.777778 0.797768 TEST09 RPOLY_ANT_COF computes the coefficients of the antiderivative of a polynomial; RPOLY_ANT_VAL evaluates the antiderivative of a polynomial; RPOLY_DER_COF computes the coefficients of the derivative of a polynomial; RPOLY_DER_VAL evaluates the derivative of a polynomial; RPOLY_PRINT prints a polynomial; RPOLY_VAL evaluates a polynomial. Our initial polynomial: p(x) = 5.00000 * x ^ 4 + 4.00000 * x ^ 3 + 3.00000 * x ^ 2 + 2.00000 * x + 1.00000 The antiderivative polynomial: p(x) = 1.00000 * x ^ 5 + 1.00000 * x ^ 4 + 1.00000 * x ^ 3 + 1.00000 * x ^ 2 + 1.00000 * x The derivative polynomial: p(x) = 20.0000 * x ^ 3 + 12.0000 * x ^ 2 + 6.00000 * x + 2.00000 Evaluate the polynomial, antiderivative and derivative, using only the original polynomial coefficients: X P(X) Anti_P(X) P'(X) 0.00000 1.00000 0.00000 2.00000 1.00000 15.0000 5.00000 40.0000 2.00000 129.000 62.0000 222.000 TEST10 ROOTS_TO_DIF computes the divided difference polynomial with given roots; DIF_TO_RPOLY converts it to a standard form polynomial. The polynomial: p(x) = 1.00000 * x - 3.00000 The polynomial: p(x) = 1.00000 * x ^ 2 - 4.00000 * x + 3.00000 The polynomial: p(x) = 1.00000 * x ^ 3 - 6.00000 * x ^ 2 + 11.0000 * x - 6.00000 The polynomial: p(x) = 1.00000 * x ^ 4 - 10.0000 * x ^ 3 + 35.0000 * x ^ 2 - 50.0000 * x + 24.0000 TEST11 ROOTS_TO_RPOLY computes polynomial coefficients from roots. The polynomial: p(x) = 1.00000 * x - 3.00000 The polynomial: p(x) = 1.00000 * x ^ 2 - 4.00000 * x + 3.00000 The polynomial: p(x) = 1.00000 * x ^ 3 - 6.00000 * x ^ 2 + 11.0000 * x - 6.00000 The polynomial: p(x) = 1.00000 * x ^ 4 - 10.0000 * x ^ 3 + 35.0000 * x ^ 2 - 50.0000 * x + 24.0000 TEST12 POLY_SHIFT shifts polynomial coefficients. Polynomial coefficients for argument X 0 6.00000 1 -1.00000 2 2.00000 SCALE = 2.00000 SHIFT = 3.00000 Polynomial coefficients for argument Z = SCALE * X + SHIFT 0 12.0000 1 -3.50000 2 0.500000 DIVDIF_PRB Normal end of execution.