Mon Oct 7 13:35:54 2024 divdif_test(): python version: 3.10.12 numpy version: 1.26.4 Test divdif() cheby_t_zero_test(): cheby_t_zero() computes the zeros of T(n,x); N X 0 0.0000 0 0.7071 1 -0.7071 0 0.8660 1 0.0000 2 -0.8660 0 0.9239 1 0.3827 2 -0.3827 3 -0.9239 0 0.9511 1 0.5878 2 0.0000 3 -0.5878 4 -0.9511 cheby_u_zero_test(): cheby_u_zero() computes the zeros of U(n,x); N X 0 0.0000 0 0.5000 1 -0.5000 0 0.7071 1 0.0000 2 -0.7071 0 0.8090 1 0.3090 2 -0.3090 3 -0.8090 0 0.8660 1 0.5000 2 0.0000 3 -0.5000 4 -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: 0: 1 2.71828 1: 2 7.38906 2: 3 20.0855 3: 4 54.5982 The divided difference polynomial: p(x) = 2.71828183 + ( x - 1.00000000) * ( 4.67077427 + ( x - 2.00000000) * ( 4.01285328 + ( x - 3.00000000) * ( 2.29840429 ))) data_to_dif_display_test(): data_to_dif_display() sets up a difference table and displays intermediate calculations The data to be processed: 0: 1 2.71828 1: 2 7.38906 2: 3 20.0855 3: 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.71828183 + ( x - 1.00000000) * ( 4.67077427 + ( x - 2.00000000) * ( 4.01285328 + ( x - 3.00000000) * ( 2.29840429 ))) data_to_r8poly_test(): data_to_r8poly() computes the standard polynomial coefficients for an interpolant, from data The data to be processed: 0: 1 2.71828 1: 2 7.38906 2: 3 20.0855 3: 4 54.5982 The interpolating polynomial: p(x) = 2.2984 * x^3 - 9.77757 * x^2 + 17.9147 * x - 7.71721 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: 0: 0 0 1: 1 1 2: 2 8 3: 3 27 Divided difference table: Col: 0 1 2 3 Row 0 : 0 1 3 1 1 : 1 7 6 0 2 : 8 19 0 0 3 : 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.00000000 + ( x - 0.00000000) * ( 6.00000000 + ( x - 1.00000000) * ( 5.00000000 + ( x - 2.00000000) * ( 1.00000000 ))) The antiderivative: p(x) = 0.00000000 + ( x - 0.00000000) * ( 4.00000000 + ( x - 0.00000000) * ( 1.50000000 + ( x - 0.00000000) * ( 0.66666667 + ( x - 0.00000000) * ( 0.25000000 )))) dif_append_test(): dif_append() updates a divided difference polynomial to include a new data item The divided difference polynomial: p(x) = 2.71828183 + ( x - 1.00000000) * ( 4.67077427 + ( x - 2.00000000) * ( 4.01285328 + ( x - 3.00000000) * ( 2.29840429 ))) Append the data (5,exp(5)) to the table. The augmented divided difference polynomial: p(x) = 148.41315910 + ( x - 5.00000000) * ( 36.42371932 + ( x - 1.00000000) * ( 10.58431502 + ( x - 2.00000000) * ( 3.28573087 + ( x - 3.00000000) * ( 0.98732658 )))) dif_basis_test(): dif_basis() computes Lagrange basis polynomials in difference form. The base points: 0: 1 1: 2 2: 3 3: 4 4: 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 #2 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: 0 1 Col 0 : -0.285714 0.0952381 1 : 0.25 -0.166667 2 : 0.0357143 0.0714286 P1=-(2x-6)/21 p(x) = 0.0952381 * x - 0.285714 P2=-(2x-3)/12 p(x) = - 0.166667 * x + 0.25 P3=(2x+1)/28 p(x) = 0.0714286 * x + 0.0357143 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: 0 1 2 Col 0 : 5.91667 -3.5 0.5 1 : -19.6667 13 -2 2 : 24.5 -18 3 3 : -13.6667 11 -2 4 : 2.91667 -2.5 0.5 P0'=(12x^2-84x+142)/24 p(x) = 0.5 * x^2 - 3.5 * x + 5.91667 P1'=-2x^2+13x-59/3 p(x) = - 2 * x^2 + 13 * x - 19.6667 P2'=3x^2-18x+49/2 p(x) = 3 * x^2 - 18 * x + 24.5 P3'=-2x^2+11x-41/3 p(x) = - 2 * x^2 + 11 * x - 13.6667 P4'=(6x^2-30x+35)/12 p(x) = 0.5 * x^2 - 2.5 * x + 2.91667 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.00000000 + ( x - 0.00000000) * ( 6.00000000 + ( x - 1.00000000) * ( 5.00000000 + ( x - 2.00000000) * ( 1.00000000 ))) The derivative: p(x) = 3.00000000 + ( x - 0.00000000) * ( 4.00000000 + ( x - 0.00000000) * ( 3.00000000 )) 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.33333333 + ( x - -2.00000000) * ( 0.04166667 + ( x - -1.00000000) * ( 0.29166667 + ( x - 0.00000000) * ( 0.08333333 + ( x - 1.00000000) * ( 0.04166667 )))) Using DIF_TO_R8POLY p(x) = 0.0416667 * x^4 + 0.166667 * x^3 + 0.5 * x^2 + 1 * x + 1 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: 0: 1 2.71828 1: 2 7.38906 2: 3 20.0855 3: 4 54.5982 The divided difference polynomial: p(x) = 2.71828183 + ( x - 1.00000000) * ( 4.67077427 + ( x - 2.00000000) * ( 4.01285328 + ( x - 3.00000000) * ( 2.29840429 ))) 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.00000000 + ( x - 1.00000000) * ( 4.00000000 + ( x - 2.00000000) * ( 4.00000000 + ( x - 3.00000000) * ( 1.00000000 ))) Using dif_shift_zero() p(x) = 1 * x^3 - 2 * x^2 + 3 * x - 4 Using dif_to_r8poly() p(x) = 1 * x^3 - 2 * x^2 + 3 * x - 4 dif_to_r8poly_test(): dif_to_r8poly() converts a divided difference polynomial to the standard power form The roots: 0: 3 The polynomial: p(x) = 1 * x - 3 The roots: 0: 3 1: 1 The polynomial: p(x) = 1 * x^2 - 4 * x + 3 The roots: 0: 3 1: 1 2: 2 The polynomial: p(x) = 1 * x^3 - 6 * x^2 + 11 * x - 6 The roots: 0: 3 1: 1 2: 2 3: 4 The polynomial: p(x) = 1 * x^4 - 10 * x^3 + 35 * x^2 - 50 * x + 24 dif_value_test(): dif_value() evaluates a divided difference polynomial. The data to be processed: 0: 1 2.71828 1: 2 7.38906 2: 3 20.0855 3: 4 54.5982 The divided difference polynomial: p(x) = 2.71828183 + ( x - 1.00000000) * ( 4.67077427 + ( x - 2.00000000) * ( 4.01285328 + ( x - 3.00000000) * ( 2.29840429 ))) Polynomial values: 0: 2 7.38906 1: 2.1 8.07001 2: 2.2 8.845 3: 2.3 9.72784 4: 2.4 10.7323 5: 2.5 11.8722 6: 2.6 13.1613 7: 2.7 14.6134 8: 2.8 16.2422 9: 2.9 18.0617 10: 3 20.0855 lagrange_rule_test(): lagrange_rule() computes weights for a Lagrange rule (X,W) Lagrange rule weights 0: 1 0.000198413 1: 2 -0.00138889 2: 3 0.00416667 3: 4 -0.00694444 4: 5 0.00694444 5: 6 -0.00416667 6: 7 0.00138889 7: 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 0 -1.000000 0.086921 1 -0.714286 0.414005 2 -0.428571 0.153125 3 -0.142857 0.345949 4 0.142857 0.345949 5 0.428571 0.153125 6 0.714286 0.414005 7 1.000000 0.086921 nco_rule_test(): nco_rule() computes open Newton Cotes formulas. Newton-Cotes Open Quadrature Rule: Abscissa Weight 0 -0.777778 0.797768 1 -0.555556 -1.251339 2 -0.333333 2.217411 3 -0.111111 -0.763839 4 0.111111 -0.763839 5 0.333333 2.217411 6 0.555556 -1.251339 7 0.777778 0.797768 r8mat_print_test(): r8mat_print() prints an R8MAT. Here is an R8MAT: Col: 0 1 2 3 4 Row 0 : 11 12 13 14 15 1 : 21 22 23 24 25 2 : 31 32 33 34 35 3 : 41 42 43 44 45 Col: 5 Row 0 : 16 1 : 26 2 : 36 3 : 46 r8mat_transpose_print_test(): r8mat_transpose_print() prints an R8MAT. Here is an R8MAT, transposed: Row: 0 1 2 3 Col 0 : 11 21 31 41 1 : 12 22 32 42 2 : 13 23 33 43 r8poly_ant_coef_test(): r8poly_ant_coef() computes the coefficients of the antiderivative of a polynomial Polynomial p(x): p(x) = 5 * x^4 + 4 * x^3 + 3 * x^2 + 2 * x + 1 Antideriv(p(x)): p(x) = 1 * x^5 + 1 * x^4 + 1 * x^3 + 1 * x^2 + 1 * x r8poly_ant_value_test(): r8poly_ant_value() evaluates the antiderivative of a polynomial at a point using a naive method. The polynomial coefficients: p(x) = 1 * x^4 - 10 * x^3 + 35 * x^2 - 50 * x + 24 I X antiP(X) 0 0.0000 0 1 0.3333 5.62428 2 0.6667 7.87819 3 1.0000 8.36667 4 1.3333 8.15144 5 1.6667 7.84979 6 2.0000 7.73333 7 2.3333 7.82675 8 2.6667 8.00658 9 3.0000 8.1 10 3.3333 7.98354 11 3.6667 7.68189 12 4.0000 7.46667 13 4.3333 7.95514 14 4.6667 10.2091 15 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 2 in standard form: p(x) = 0.25 * x^4 - 3 * x^3 + 12.25 * x^2 - 19.5 * x + 10 Evaluate basis polynomial 2 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() computes the coefficients of the derivative of a polynomial. The initial polynomial p(x) = 1 * x^4 - 10 * x^3 + 35 * x^2 - 50 * x + 24 The derivative of order 0 p(x) = 1 * x^4 - 10 * x^3 + 35 * x^2 - 50 * x + 24 The derivative of order 1 p(x) = 4 * x^3 - 30 * x^2 + 70 * x - 50 The derivative of order 2 p(x) = 12 * x^2 - 60 * x + 70 The derivative of order 3 p(x) = 24 * x - 60 The derivative of order 4 p(x) = 0 r8poly_deriv_value_test(): r8poly_deriv_value() evaluates the derivative of a polynomial. The polynomial p(x) = 1 * x^4 - 10 * x^3 + 35 * x^2 - 50 * x + 24 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: p(x) = 9 * x^5 + 0.78 * x^4 + 56 * x^2 - 3.4 * x + 12 The R8POLY: p(x) = 0.78 * x^4 + 56 * x^2 - 3.4 * x + 12 The R8POLY: p(x) = 12 The R8POLY: p(x) = 1 * x^5 The R8POLY: p(x) = 0 r8poly_shift_test(): r8poly_shift() shifts an R8POLY p(x) to q(z) where z=scale*x+shift. p(x): p(x) = 2 * x^2 - 1 * x + 6 z = scale * x + shift Scale = 2.0 Shift = 3.0 q(z): p(x) = 0.5 * x^2 - 3.5 * x + 12 Expected q(z): p(x) = 0.5 * x^2 - 3.5 * x + 12 r8poly_value_horner_test(): r8poly_value_horner() evaluates a polynomial at a point using Horners method. The polynomial coefficients: p(x) = 1 * x^4 - 10 * x^3 + 35 * x^2 - 50 * x + 24 I X P(X) 0 0.0000 24 1 0.3333 10.8642 2 0.6667 3.45679 3 1.0000 0 4 1.3333 -0.987654 5 1.6667 -0.691358 6 2.0000 0 7 2.3333 0.493827 8 2.6667 0.493827 9 3.0000 0 10 3.3333 -0.691358 11 3.6667 -0.987654 12 4.0000 0 13 4.3333 3.45679 14 4.6667 10.8642 15 5.0000 24 r8vec_indicator1_test(): r8vec_indicator1() returns the 1-based indicator matrix. The 1-based indicator vector: 0: 1 1: 2 2: 3 3: 4 4: 5 5: 6 6: 7 7: 8 8: 9 9: 10 r8vec_is_distinct_test(): r8vec_is_distinct() computes the maximum entry in an R8VEC. Input vector: 0: 1 1: 2 2: 5 3: 3 4: 4 Array entries are distinct. Input vector: 0: 1 1: 2 2: 5 3: 2 4: 4 Array entries are NOT distinct. roots_to_dif_test(): roots_to_dif() computes the divided difference polynomial from the set of roots. The roots: 0: 3 The polynomial: p(x) = 0.00000000 + ( x - 3.00000000) * ( 1.00000000 ) The roots: 0: 3 1: 1 The polynomial: p(x) = 0.00000000 + ( x - 3.00000000) * ( 0.00000000 + ( x - 1.00000000) * ( 1.00000000 )) The roots: 0: 3 1: 1 2: 2 The polynomial: p(x) = 0.00000000 + ( x - 3.00000000) * ( 0.00000000 + ( x - 1.00000000) * ( 0.00000000 + ( x - 2.00000000) * ( 1.00000000 ))) The roots: 0: 3 1: 1 2: 2 3: 4 The polynomial: p(x) = 0.00000000 + ( x - 3.00000000) * ( 0.00000000 + ( x - 1.00000000) * ( 0.00000000 + ( x - 2.00000000) * ( 0.00000000 + ( x - 4.00000000) * ( 1.00000000 )))) roots_to_r8poly_test(): roots_to_r8poly() is given N real roots, and constructs the coefficient vector of the corresponding polynomial. N real roots: 0: 1 1: -4 2: 3 3: 0 4: 3 The polynomial: p(x) = 1 * x^5 - 3 * x^4 - 13 * x^3 + 51 * x^2 - 36 * x divdif_test(): Normal end of execution. Mon Oct 7 13:35:54 2024