07-Jan-2023 12:56:56 hermite_interpolant_test(): MATLAB/Octave version 4.2.2 Test hermite_interpolant(). hermite_interpolant_test01() hermite_demo() computes the Hermite interpolant to data. Here, f(x) = 1 + 2x + 3x^2. HERMITE_DEMO Compute coefficients CD of the Hermite polynomial interpolant to given data (x,y,yp). Data: X Y Y' 1 0 1 2 2 1 6 8 3 2 17 14 Difference table: XD YD 1 0 1 2 0 2 3 1 3 4 1 0 5 2 0 6 2 0 Hermite interpolating polynomial: = +3.000000 * x^2 +2.000000 * x +1.000000 Data Versus Interpolant: X Y H YP HP 1 0 1 1 2 2 2 1 6 6 8 8 3 2 17 17 14 14 hermite_interpolant_test02 hermite() computes the Hermite interpolant to data. Here, f(x) = 6 + 5x + 4x^2 + 3x^3 + 2x^4 + x^5. HERMITE_DEMO Compute coefficients CD of the Hermite polynomial interpolant to given data (x,y,yp). Data: X Y Y' 1 0 6 5 2 1 21 35 3 2 120 201 Difference table: XD YD 1 0 6 2 0 5 3 1 10 4 1 10 5 2 6 6 2 1 Hermite interpolating polynomial: = +1.000000 * x^5 +2.000000 * x^4 +3.000000 * x^3 +4.000000 * x^2 +5.000000 * x +6.000000 Data Versus Interpolant: X Y H YP HP 1 0 6 6 5 5 2 1 21 21 35 35 3 2 120 120 201 201 hermite_interpolant_test03(): hermite() computes the Hermite interpolant to data. Here, f(x) is a fifth order polynomial with random coefficients, and the abscissas are random. Random abscissas 1: 0.346582 2: 0.754820 3: 0.235388 Random polynomial coefficients. 1: 0.231569 2: 0.117346 3: 0.419670 4: 0.177764 5: 0.524204 6: 0.557549 HERMITE_DEMO Compute coefficients CD of the Hermite polynomial interpolant to given data (x,y,yp). Data: X Y Y' 1 0.346582 0.340402 0.599822 2 0.75482 0.942484 2.86145 3 0.235388 0.286775 0.380371 Difference table: XD YD 1 0.346582 0.340402 2 0.346582 0.599822 3 0.75482 2.14338 4 0.75482 3.06983 5 0.235388 1.88361 6 0.235388 0.557549 Hermite interpolating polynomial: = +0.557549 * x^5 +0.524204 * x^4 +0.177764 * x^3 +0.419670 * x^2 +0.117346 * x +0.231569 Data Versus Interpolant: X Y H YP HP 1 0.346582 0.340402 0.340402 0.599822 0.599822 2 0.75482 0.942484 0.942484 2.86145 2.86145 3 0.235388 0.286775 0.286775 0.380371 0.380371 hermite_interpolant_test04(): hermite() computes the Hermite interpolant to data. Here, f(x) is the Runge function and the data is evaluated at equally spaced points. As N increases, the maximum error grows. N Max | F(X) - H(F(X)) | 3 0.530048 5 0.223403 7 0.390862 9 1.13792 11 3.83581 13 13.9642 15 53.4249 hermite_interpolant_test045(): hermite() computes the Hermite interpolant to data. Here, f(x) is the Runge function and the data is evaluated at Chebyshev spaced points. As N increases, the maximum error decreases. N Max | F(X) - H(F(X)) | 3 0.530048 5 0.325238 7 0.180448 9 0.0950617 11 0.0480707 13 0.0237723 15 0.0114442 hermite_interpolant_test05(): hermite() computes the Hermite interpolant to data. Here, f(x) is the Runge function and the data is evaluated at Chebyshev spaced points. As N increases, the maximum error decreases. N Max | F(X) - H(F(X)) | 3 0.530048 5 0.325238 7 0.180448 9 0.0950617 11 0.0480707 13 0.0237723 15 0.0114442 hermite_interpolant_test06(): hermite_basis_0() and hermite_basis_1() evaluate the Hermite global polynomial basis functions of type 0: associated with function values, and of type 1: associated with derivative values. Interpolate y = x^3 + x^2 + x + 1. XD Y(XD) Y'(XD) 0.0000 1.0000 1.0000 10.0000 1111.0000 321.0000 XV Y(XV) H(XV) 0.0000 1.0000 1.0000 1.0000 4.0000 4.0000 2.0000 15.0000 15.0000 3.0000 40.0000 40.0000 4.0000 85.0000 85.0000 5.0000 156.0000 156.0000 6.0000 259.0000 259.0000 7.0000 400.0000 400.0000 8.0000 585.0000 585.0000 9.0000 820.0000 820.0000 10.0000 1111.0000 1111.0000 hermite_interpolant_test07(): hermite_interpolant_rule() is given a set of N abscissas for a Hermite interpolant and returns N pairs of quadrature weights for function and derivative values at the abscissas. I X W(F(X)) W(F'(X)) 1 0 -66.6667 -150 2 5 53.3333 -266.667 3 10 23.3333 -33.3333 Use the quadrature rule over interval 0.000000 to 10.000000 Estimate integral of 1 = 10.000000 Estimate integral of X = 50.000000 Estimate integral of X^2 = 333.333333 Estimate integral of SIN(X) = -261.510652 I X W(F(X)) W(F'(X)) 1 0 -6.66667 -1.5 2 0.5 5.33333 -2.66667 3 1 2.33333 -0.333333 Use the quadrature rule over interval 0.000000 to 1.000000 Estimate integral of 1 = 1.000000 Estimate integral of X = 0.500000 Estimate integral of X^2 = 0.333333 Estimate integral of SIN(X) = 0.500048 I X W(F(X)) W(F'(X)) 1 0 -2.60271e+10 -4.61959e+09 2 1 -1.2973e+12 -3.74681e+11 3 2 -1.43117e+13 -6.31919e+12 4 3 -5.24034e+13 -3.8283e+13 5 4 -6.11016e+13 -1.01787e+14 6 5 1.53665e+13 -1.29255e+14 7 6 6.73925e+13 -8.01827e+13 8 7 3.82127e+13 -2.36405e+13 9 8 7.64733e+12 -3.02886e+12 10 9 5.13565e+11 -1.37316e+11 11 10 7.52948e+09 -1.26888e+09 Use the quadrature rule over interval 0.000000 to 10.000000 Estimate integral of 1 = 9.989637 Estimate integral of X = 49.772762 Estimate integral of X^2 = 331.017441 Estimate integral of SIN(X) = 1147.596236 I X W(F(X)) W(F'(X)) 1 0 -2.60271e+09 -4.61959e+07 2 0.1 -1.2973e+11 -3.74681e+09 3 0.2 -1.43117e+12 -6.31919e+10 4 0.3 -5.24034e+12 -3.8283e+11 5 0.4 -6.11016e+12 -1.01787e+12 6 0.5 1.53665e+12 -1.29255e+12 7 0.6 6.73925e+12 -8.01827e+11 8 0.7 3.82127e+12 -2.36405e+11 9 0.8 7.64733e+11 -3.02886e+10 10 0.9 5.13565e+10 -1.37316e+09 11 1 7.52948e+08 -1.26888e+07 Use the quadrature rule over interval 0.000000 to 1.000000 Estimate integral of 1 = 0.996308 Estimate integral of X = 0.497902 Estimate integral of X^2 = 0.331521 Estimate integral of SIN(X) = 0.458202 I X W(F(X)) W(F'(X)) 1 0 -3.06432e+11 -2.33178e+09 2 0.0244717 1.96461e+11 -8.7651e+09 3 0.0954915 5.13319e+10 -7.40794e+09 4 0.206107 2.18086e+10 -5.89147e+09 5 0.345492 1.04125e+10 -4.63078e+09 6 0.5 4.78847e+09 -3.7192e+09 7 0.654508 1.24726e+09 -3.09863e+09 8 0.793893 -2.27985e+09 -2.69011e+09 9 0.904508 -9.30372e+09 -2.43423e+09 10 0.975528 -4.38263e+10 -2.29381e+09 11 1 7.57919e+10 -5.62265e+08 Use the quadrature rule over interval 0.000000 to 1.000000 Estimate integral of 1 = 1.000015 Estimate integral of X = 0.499958 Estimate integral of X^2 = 0.333275 Estimate integral of SIN(X) = 0.459672 hermite_interpolant_test08(): hermite_interpolant() sets up the Hermite interpolant. hermite_interpolant_value() evaluates it. Consider data for y=sin(x) at x=0,1,2,3,4. In the following table, there should be perfect agreement between F and H, and F' and H' at the data points X = 0, 1, 2, 3, and 4. In between, H and H' approximate F and F'. I X(I) F(X(I)) H(X(I)) F'(X(I)) H'(X(I)) 1 0 0 0 1 1 2 0.25 0.247404 0.247407 0.968912 0.968921 3 0.5 0.479426 0.479428 0.877583 0.877575 4 0.75 0.681639 0.681639 0.731689 0.731683 5 1 0.841471 0.841471 0.540302 0.540302 6 1.25 0.948985 0.948985 0.315322 0.315324 7 1.5 0.997495 0.997495 0.0707372 0.0707368 8 1.75 0.983986 0.983986 -0.178246 -0.178247 9 2 0.909297 0.909297 -0.416147 -0.416147 10 2.25 0.778073 0.778073 -0.628174 -0.628172 11 2.5 0.598472 0.598473 -0.801144 -0.801143 12 2.75 0.381661 0.381661 -0.924302 -0.924304 13 3 0.14112 0.14112 -0.989992 -0.989992 14 3.25 -0.108195 -0.108194 -0.99413 -0.994124 15 3.5 -0.350783 -0.350781 -0.936457 -0.936451 16 3.75 -0.571561 -0.571559 -0.820559 -0.820567 17 4 -0.756802 -0.756802 -0.653644 -0.653644 hermite_interpolant_test(): Normal end of execution. 07-Jan-2023 12:56:57