Home License -- for personal use only. Not for government, academic, research, commercial, or other organizational use. 13-May-2025 13:21:58 divdif_test(): MATLAB/Octave version 9.11.0.2358333 (R2021b) Update 7 Test divdif() cheby_t_zero_test(): cheby_t_zero() computes the zeros of T(n,x); N X 1 0.0000 1 0.7071 2 -0.7071 1 0.8660 2 0.0000 3 -0.8660 1 0.9239 2 0.3827 3 -0.3827 4 -0.9239 1 0.9511 2 0.5878 3 0.0000 4 -0.5878 5 -0.9511 cheby_u_zero_test(): cheby_u_zero() computes the zeros of U(n,x); N X 1 0.0000 1 0.5000 2 -0.5000 1 0.7071 2 0.0000 3 -0.7071 1 0.8090 2 0.3090 3 -0.3090 4 -0.8090 1 0.8660 2 0.5000 3 0.0000 4 -0.5000 5 -0.8660 data_to_dif_test(): data_to_dif() computes the Newton polynomial coefficients for a divided difference interpolant, from data; The data to be processed: 1: 1 2.71828 2: 2 7.38906 3: 3 20.0855 4: 4 54.5982 The divided difference polynomial: p(x) = 2.718282 + ( x - 1.000000) * ( 4.670774 + ( x - 2.000000) * ( 4.012853 + ( x - 3.000000) * ( 2.298404 ))) data_to_dif_display_test(): data_to_dif_display() sets up a difference table and displays intermediate calculations; The data to be processed: 1: 1 2.71828 2: 2 7.38906 3: 3 20.0855 4: 4 54.5982 Divided difference table: 1.000000 2.000000 3.000000 4.000000 0 2.718282 7.389056 20.085537 54.598150 1 4.670774 12.696481 34.512613 2 4.012853 10.908066 3 2.298404 The divided difference polynomial: p(x) = 2.718282 + ( x - 1.000000) * ( 4.670774 + ( x - 2.000000) * ( 4.012853 + ( x - 3.000000) * ( 2.298404 ))) data_to_r8poly_test(): data_to_r8poly() computes the standard polynomial coefficients for an interpolant, from data; The data to be processed: 1: 1 2.71828 2: 2 7.38906 3: 3 20.0855 4: 4 54.5982 The interpolating polynomial: = +2.298404 * x^3 -9.777572 * x^2 +17.914662 * x -7.717212 data_to_table_test() data_to_table() computes the full divided difference table for a given set of data. The usual divided difference vector is the first row. Data to be processed: 1: 0 0 2: 1 1 3: 2 8 4: 3 27 Divided difference table: Col: 1 2 3 4 Row 1 : 0 1 3 1 2 : 1 7 6 0 3 : 8 19 0 0 4 : 27 0 0 0 dif_antideriv_test(): dif_antideriv() computes the difference form of the antiderivative; Divided difference table: 0.000000 1.000000 2.000000 3.000000 0 4.000000 10.000000 26.000000 58.000000 1 6.000000 16.000000 32.000000 2 5.000000 8.000000 3 1.000000 The divided difference polynomial: p(x) = 4.000000 + ( x - 0.000000) * ( 6.000000 + ( x - 1.000000) * ( 5.000000 + ( x - 2.000000) * ( 1.000000 ))) The antiderivative: p(x) = 0.000000 + ( x - 0.000000) * ( 4.000000 + ( x - 0.000000) * ( 1.500000 + ( x - 0.000000) * ( 0.666667 + ( x - 0.000000) * ( 0.250000 )))) dif_append_test(): dif_append() updates a divided difference polynomial; to include a new data item; The divided difference polynomial: p(x) = 2.718282 + ( x - 1.000000) * ( 4.670774 + ( x - 2.000000) * ( 4.012853 + ( x - 3.000000) * ( 2.298404 ))) Append the data (5,exp(5)) to the table. The augmented divided difference polynomial: p(x) = 148.413159 + ( x - 5.000000) * ( 36.423719 + ( x - 1.000000) * ( 10.584315 + ( x - 2.000000) * ( 3.285731 + ( x - 3.000000) * ( 0.987327 )))) dif_basis_test(): dif_basis() computes Lagrange basis polynomials in difference form. The base points: 1: 1 2: 2 3: 3 4: 4 5: 5 The table of difference vectors defining the basis polynomials. Each column represents a polynomial. 1.000000 0.000000 0.000000 0.000000 0.000000 -1.000000 1.000000 0.000000 0.000000 0.000000 0.500000 -1.000000 0.500000 0.000000 0.000000 -0.166667 0.500000 -0.500000 0.166667 0.000000 0.041667 -0.166667 0.250000 -0.166667 0.041667 Evaluate basis polynomial #3 at a set of points. X Y 1.000000 0.000000 1.500000 -0.546875 2.000000 0.000000 2.500000 0.703125 3.000000 1.000000 3.500000 0.703125 4.000000 0.000000 4.500000 -0.546875 5.000000 0.000000 dif_basis_deriv_test(): dif_basis_deriv() computes difference tables for the first derivative of each Lagrange basis. Lagrange basis derivative polynomial coefficients: Row: 1 2 Col 1: -0.285714 0.0952381 2: 0.25 -0.166667 3: 0.0357143 0.0714286 P1'=-(2x-6)/21 = +0.095238 * x -0.285714 P2'=-(2x-3)/12 = -0.166667 * x +0.250000 P3'=(2x+1)/28 = +0.071429 * x +0.035714 dif_basis_derivk_test(): dif_basis_derivk() computes difference tables for the K-th derivative of each Lagrange basis. Lagrange basis K-derivative polynomial coefficients: Row: 1 2 3 Col 1: 5.91667 -3.5 0.5 2: -19.6667 13 -2 3: 24.5 -18 3 4: -13.6667 11 -2 5: 2.91667 -2.5 0.5 P1'=(12x^2-84x+142)/24 = +0.500000 * x^2 -3.500000 * x +5.916667 P2'=-2x^2+13x-59/3 = -2.000000 * x^2 +13.000000 * x -19.666667 P3'=3x^2-18x+49/2 = +3.000000 * x^2 -18.000000 * x +24.500000 P4'=-2x^2+11x-41/3 = -2.000000 * x^2 +11.000000 * x -13.666667 P5'=(6x^2-30x+35)/12 = +0.500000 * x^2 -2.500000 * x +2.916667 dif_deriv_test(): dif_deriv() computes the difference form of the derivative; Divided difference table: 0.000000 1.000000 2.000000 3.000000 0 4.000000 10.000000 26.000000 58.000000 1 6.000000 16.000000 32.000000 2 5.000000 8.000000 3 1.000000 The divided difference polynomial: p(x) = 4.000000 + ( x - 0.000000) * ( 6.000000 + ( x - 1.000000) * ( 5.000000 + ( x - 2.000000) * ( 1.000000 ))) The derivative: p(x) = 3.000000 + ( x - 0.000000) * ( 4.000000 + ( x - 0.000000) * ( 3.000000 )) dif_derivk_table_test(): dif_derivk_table() computes the K-th derivative for a divided difference table. The divided difference polynomial P0: p(x) = 0.333333 + ( x - -2.000000) * ( 0.041667 + ( x - -1.000000) * ( 0.291667 + ( x - 0.000000) * ( 0.083333 + ( x - 1.000000) * ( 0.041667 )))) Using DIF_TO_R8POLY = +0.041667 * x^4 +0.166667 * x^3 +0.500000 * x^2 +1.000000 * x +1.000000 Evaluate difference tables for the function P0 and its first four derivatives, P1...P4. X P0 P1 P2 P3 P4 0.0000 1.0000 1.0000 1.0000 1.0000 1.0000 0.2000 1.2214 1.2213 1.2200 1.2000 1.0000 0.4000 1.4917 1.4907 1.4800 1.4000 1.0000 0.6000 1.8214 1.8160 1.7800 1.6000 1.0000 0.8000 2.2224 2.2053 2.1200 1.8000 1.0000 1.0000 2.7083 2.6667 2.5000 2.0000 1.0000 1.2000 3.2944 3.2080 2.9200 2.2000 1.0000 1.4000 3.9974 3.8373 3.3800 2.4000 1.0000 1.6000 4.8357 4.5627 3.8800 2.6000 1.0000 1.8000 5.8294 5.3920 4.4200 2.8000 1.0000 2.0000 7.0000 6.3333 5.0000 3.0000 1.0000 dif_print_test(): dif_print() prints a Newton polynomial; The data to be processed: 1: 1 2.71828 2: 2 7.38906 3: 3 20.0855 4: 4 54.5982 The divided difference polynomial: p(x) = 2.718282 + ( x - 1.000000) * ( 4.670774 + ( x - 2.000000) * ( 4.012853 + ( x - 3.000000) * ( 2.298404 ))) dif_shift_zero_test(): dif_shift_zero() shifts a divided difference table to all zero abscissas; These are equivalent operations! Divided difference table: 1.000000 2.000000 3.000000 4.000000 0 -2.000000 2.000000 14.000000 40.000000 1 4.000000 12.000000 26.000000 2 4.000000 7.000000 3 1.000000 Divided difference table: 1.000000 2.000000 3.000000 4.000000 0 -2.000000 2.000000 14.000000 40.000000 1 4.000000 12.000000 26.000000 2 4.000000 7.000000 3 1.000000 The divided difference polynomial: p(x) = -2.000000 + ( x - 1.000000) * ( 4.000000 + ( x - 2.000000) * ( 4.000000 + ( x - 3.000000) * ( 1.000000 ))) Using DIF_SHIFT_ZERO = +1.000000 * x^3 -2.000000 * x^2 +3.000000 * x -4.000000 Using DIF_TO_R8POLY = +1.000000 * x^3 -2.000000 * x^2 +3.000000 * x -4.000000 dif_to_r8poly_test(): dif_to_r8poly() converts a divided difference polynomial to the standard power form The roots: 1: 3 The polynomial: = +1.000000 * x -3.000000 The roots: 1: 3 2: 1 The polynomial: = +1.000000 * x^2 -4.000000 * x +3.000000 The roots: 1: 3 2: 1 3: 2 The polynomial: = +1.000000 * x^3 -6.000000 * x^2 +11.000000 * x -6.000000 The roots: 1: 3 2: 1 3: 2 4: 4 The polynomial: = +1.000000 * x^4 -10.000000 * x^3 +35.000000 * x^2 -50.000000 * x +24.000000 dif_value_test(): dif_value() evaluates a divided difference polynomial. The data to be processed: 1: 1 2.71828 2: 2 7.38906 3: 3 20.0855 4: 4 54.5982 The divided difference polynomial: p(x) = 2.718282 + ( x - 1.000000) * ( 4.670774 + ( x - 2.000000) * ( 4.012853 + ( x - 3.000000) * ( 2.298404 ))) Polynomial values: 1: 2 7.38906 2: 2.1 8.07001 3: 2.2 8.845 4: 2.3 9.72784 5: 2.4 10.7323 6: 2.5 11.8722 7: 2.6 13.1613 8: 2.7 14.6134 9: 2.8 16.2422 10: 2.9 18.0617 11: 3 20.0855 lagrange_rule_test(): lagrange_rule() computes weights for a Lagrange rule; (X,W) Lagrange rule weights 1: 1 0.000198413 2: 2 -0.00138889 3: 3 0.00416667 4: 4 -0.00694444 5: 5 0.00694444 6: 6 -0.00416667 7: 7 0.00138889 8: 8 -0.000198413 lagrange_sum_test(): lagrange_sum() evaluates a Lagrange interpolant. x f(x) Interp 0.0000 -28 -28 1.0000 0 -1.249e-15 2.0000 10 10 3.0000 8 8 4.0000 0 -6.66134e-16 5.0000 -8 -8 6.0000 -10 -10 7.0000 0 0 8.0000 28 28 9.0000 80 80 10.0000 162 162 lagrange_value_test(): lagrange_value() evaluates a Lagrange 1D interpolant. x f(x) Interp 0.0000 -28 -28 0.5000 -11.375 -11.375 1.0000 0 0 1.5000 6.875 6.875 2.0000 10 10 2.5000 10.125 10.125 3.0000 8 8 3.5000 4.375 4.375 4.0000 0 8.88178e-16 4.5000 -4.375 -4.375 5.0000 -8 -8 5.5000 -10.125 -10.125 6.0000 -10 -10 6.5000 -6.875 -6.875 7.0000 0 0 7.5000 11.375 11.375 8.0000 28 28 8.5000 50.625 50.625 9.0000 80 80 9.5000 116.875 116.875 10.0000 162 162 ncc_rule_test(): ncc_rule() computes closed Newton Cotes formulas; Newton-Cotes Closed Quadrature Rule: Abscissa Weight 1 -1.000000 0.086921 2 -0.714286 0.414005 3 -0.428571 0.153125 4 -0.142857 0.345949 5 0.142857 0.345949 6 0.428571 0.153125 7 0.714286 0.414005 8 1.000000 0.086921 nco_rule_test(): nco_rule() computes open Newton Cotes formulas. Newton-Cotes Open Quadrature Rule: Abscissa Weight 1 -0.777778 0.797768 2 -0.555556 -1.251339 3 -0.333333 2.217411 4 -0.111111 -0.763839 5 0.111111 -0.763839 6 0.333333 2.217411 7 0.555556 -1.251339 8 0.777778 0.797768 r8poly_ant_coef_test(): r8poly_ant_coef() computes the coefficients of the antiderivative of a polynomial; Polynomial p(x): = +5.000000 * x^4 +4.000000 * x^3 +3.000000 * x^2 +2.000000 * x +1.000000 Antideriv(p(x)): = +1.000000 * x^5 +1.000000 * x^4 +1.000000 * x^3 +1.000000 * x^2 +1.000000 * x r8poly_ant_value_test(): r8poly_ant_value() evaluates the antiderivative of a polynomial at one point. The polynomial coefficients: = +1.000000 * x^4 -10.000000 * x^3 +35.000000 * x^2 -50.000000 * x +24.000000 I X antiP(X) 1 0.0000 0 2 0.3333 5.62428 3 0.6667 7.87819 4 1.0000 8.36667 5 1.3333 8.15144 6 1.6667 7.84979 7 2.0000 7.73333 8 2.3333 7.82675 9 2.6667 8.00658 10 3.0000 8.1 11 3.3333 7.98354 12 3.6667 7.68189 13 4.0000 7.46667 14 4.3333 7.95514 15 4.6667 10.2091 16 5.0000 15.8333 r8poly_basis_test(): r8poly_basis() computes Lagrange basis polynomials in standard form. 5.000000 -10.000000 10.000000 -5.000000 1.000000 -6.416667 17.833333 -19.500000 10.166667 -2.083333 2.958333 -9.833333 12.250000 -6.833333 1.458333 -0.583333 2.166667 -3.000000 1.833333 -0.416667 0.041667 -0.166667 0.250000 -0.166667 0.041667 Basis polynomial 3 in standard form: = +0.250000 * x^4 -3.000000 * x^3 +12.250000 * x^2 -19.500000 * x +10.000000 Evaluate basis polynomial 3 at a set of points. X Y 1.000000 0.000000 1.500000 -0.546875 2.000000 0.000000 2.500000 0.703125 3.000000 1.000000 3.500000 0.703125 4.000000 0.000000 4.500000 -0.546875 5.000000 0.000000 r8poly_deriv_coef_test(): r8poly_deriv_coef() computes the coefficients of the derivative of a polynomial. The initial polynomial = +1.000000 * x^4 -10.000000 * x^3 +35.000000 * x^2 -50.000000 * x +24.000000 The derivative of order 0 = +1.000000 * x^4 -10.000000 * x^3 +35.000000 * x^2 -50.000000 * x +24.000000 The derivative of order 1 = +4.000000 * x^3 -30.000000 * x^2 +70.000000 * x -50.000000 The derivative of order 2 = +12.000000 * x^2 -60.000000 * x +70.000000 The derivative of order 3 = +24.000000 * x -60.000000 The derivative of order 4 = +24.000000 The derivative of order 5 = 0 r8poly_deriv_value_test(): r8poly_deriv_value() evaluates the derivative of a polynomial. The polynomial = +1.000000 * x^4 -10.000000 * x^3 +35.000000 * x^2 -50.000000 * x +24.000000 A table of derivative values: 0.0000 -50.0000 0.5000 -22.0000 1.0000 -6.0000 1.5000 1.0000 2.0000 2.0000 2.5000 0.0000 3.0000 -2.0000 3.5000 -1.0000 4.0000 6.0000 r8poly_print_test(): r8poly_print() prints an R8POLY. The R8POLY: = +9.000000 * x^5 +0.780000 * x^4 +56.000000 * x^2 -3.400000 * x +12.000000 The R8POLY: = +0.780000 * x^4 +56.000000 * x^2 -3.400000 * x +12.000000 The R8POLY: = +1.000000 * x^5 +0.780000 * x^4 +56.000000 * x^2 +12.000000 The R8POLY: = 0 r8poly_shift_test(): r8poly_shift() shifts an R8POLY p(x) to q(z) where z=scale*x+shift. p(x): = +2.000000 * x^2 -1.000000 * x +6.000000 z = scale * x + shift Scale = 2 Shift = 3 q(z): = +0.500000 * x^2 -3.500000 * x +12.000000 Expected q(z): = +0.500000 * x^2 -3.500000 * x +12.000000 r8poly_value_horner_test() r8poly_value_horner() evaluates a polynomial at one point, using Horner's method. The polynomial coefficients: = +1.000000 * x^4 -10.000000 * x^3 +35.000000 * x^2 -50.000000 * x +24.000000 I X P(X) 1 0.0000 24 2 0.3333 10.8642 3 0.6667 3.45679 4 1.0000 0 5 1.3333 -0.987654 6 1.6667 -0.691358 7 2.0000 0 8 2.3333 0.493827 9 2.6667 0.493827 10 3.0000 0 11 3.3333 -0.691358 12 3.6667 -0.987654 13 4.0000 0 14 4.3333 3.45679 15 4.6667 10.8642 16 5.0000 24 r8vec_is_distinct_test() r8vec_is_distinct() is true if an R8VEC only contains distinct entries. X: 0 1 3 X is distinct X: 1.5 1.6 1.5 X is NOT distinct. X: -1 1 10 X is distinct roots_to_dif_test(): roots_to_dif() computes the divided difference polynomial from the set of roots. The roots: 1: 3 The polynomial: p(x) = 0.000000 + ( x - 3.000000) * ( 1.000000 ) The roots: 1: 3 2: 1 The polynomial: p(x) = 0.000000 + ( x - 3.000000) * ( 0.000000 + ( x - 1.000000) * ( 1.000000 )) The roots: 1: 3 2: 1 3: 2 The polynomial: p(x) = 0.000000 + ( x - 3.000000) * ( 0.000000 + ( x - 1.000000) * ( 0.000000 + ( x - 2.000000) * ( 1.000000 ))) The roots: 1: 3 2: 1 3: 2 4: 4 The polynomial: p(x) = 0.000000 + ( x - 3.000000) * ( 0.000000 + ( x - 1.000000) * ( 0.000000 + ( x - 2.000000) * ( 0.000000 + ( x - 4.000000) * ( 1.000000 )))) roots_to_r8poly_test(): roots_to_r8poly() is given N real roots, and constructs the coefficient vector of the corresponding polynomial. N real roots: 1: 1 2: -4 3: 3 4: 0 5: 3 Corresponding polynomial: = +1.000000 * x^5 -3.000000 * x^4 -13.000000 * x^3 +51.000000 * x^2 -36.000000 * x divdif_test(): Normal end of execution. 13-May-2025 13:21:59