10 December 2023 8:08:51.305 PM test_interp_fun_test(): Fortran77 version Test test_interp_fun(). TEST01 Demonstrate some of the bookkeeping routines. P00_PROB_NUM returns the number of problems. P00_TITLE returns the problem title. P00_LIMIT returns the problem limits. Number of problems = 5 Problem 1 Problem TITLE = "Runge example, f(x) = 1 / ( x * x + 1 ), [-5,5]". Problem lower limit A = -5.00000 Problem upper limit B = 5.00000 Problem 2 Problem TITLE = "Bernstein example, f(x) = abs ( x ), [-1,1]". Problem lower limit A = -1.00000 Problem upper limit B = 1.00000 Problem 3 Problem TITLE = "Step function, f jumps from 0 to 1 at 0.". Problem lower limit A = -1.00000 Problem upper limit B = 1.00000 Problem 4 Problem TITLE = "Doppler function, highly oscillatory near X = 0.". Problem lower limit A = 0.00000 Problem upper limit B = 1.00000 Problem 5 Problem TITLE = "Rabbit ears, f(x) = max(sin(x)+sin(x^2),1-abs(x-5)/5), [0,10]". Problem lower limit A = 0.00000 Problem upper limit B = 10.0000 TEST02 P00_STORY prints the problem "story". Problem 1 This is a famous example, due to Runge. If equally spaced abscissas are used, the sequence of interpolating polynomials Pn(X) diverges, in the sense that the max norm of the difference between Pn(X) and F(X) becomes arbitrarily large as N increases. Problem 2 This example is due to Bernstein. If equally spaced abscissas are used, the sequence of interpolating polynomials Pn(X) only converges to F(X) at -1, 0, and 1. Problem 3 The step function is discontinuous. Attempts to approximate this function by high degree polynomials will rapidly diverge. Problem 4 The Doppler function is continuous, but highly oscillatory near the value X = 0. Problem 5 This example is very difficult to interpolate. It is essentially defined as a piecewise function, alternating between a straight line and a sinusoidal curve. TEST03 Equally spaced polynomial interpolation. Evaluate the function at N equally spaced points. Determine the N-1 degre polynomial interpolant. Estimate the maximum difference between the function and the interpolant. Problem 1 Runge example, f(x) = 1 / ( x * x + 1 ), [-5,5] N Max ||Error|| 1 0.961538 5 0.438134 9 1.04517 13 3.60527 17 14.0515 21 58.2781 Problem 2 Bernstein example, f(x) = abs ( x ), [-1,1] N Max ||Error|| 1 1.00000 5 0.147200 9 0.315753 13 1.54906 17 10.8772 21 92.6992 Problem 3 Step function, f jumps from 0 to 1 at 0. N Max ||Error|| 1 1.00000 5 0.975672 9 1.33140 13 9.48697 17 88.0671 21 933.226 Problem 4 Doppler function, highly oscillatory near X = 0. N Max ||Error|| 1 0.761400 5 0.784056 9 0.599198 13 16.0925 17 34.2374 21 476.344 Problem 5 Rabbit ears, f(x) = max(sin(x)+sin(x^2),1-abs(x-5)/5), [0,10] N Max ||Error|| 1 1.00000 5 1.73130 9 2.07062 13 5.67344 17 44.8345 21 194.825 TEST04 Bernstein polynomial approximation. Evaluate the function at N equally spaced points. Determine the N-1 degree Bernstein polynomial approximant. Estimate the maximum difference between the function and the approximant. Problem 1 Runge example, f(x) = 1 / ( x * x + 1 ), [-5,5] N Max ||Error|| 1 0.961538 5 0.551227 9 0.521209 13 0.464392 17 0.418159 21 0.381911 Problem 2 Bernstein example, f(x) = abs ( x ), [-1,1] N Max ||Error|| 1 1.00000 5 0.375000 9 0.273438 13 0.225586 17 0.196381 21 0.176197 Problem 3 Step function, f jumps from 0 to 1 at 0. N Max ||Error|| 1 1.00000 5 0.672352 9 0.614634 13 0.585470 17 0.566485 21 0.552550 Problem 4 Doppler function, highly oscillatory near X = 0. N Max ||Error|| 1 0.761400 5 0.518564 9 0.533793 13 0.577633 17 0.521372 21 0.548845 Problem 5 Rabbit ears, f(x) = max(sin(x)+sin(x^2),1-abs(x-5)/5), [0,10] N Max ||Error|| 1 1.00000 5 1.68122 9 1.01700 13 1.04237 17 1.06321 21 1.02580 TEST05 Linear spline interpolation. Problem 1 Runge example, f(x) = 1 / ( x * x + 1 ), [-5,5] N Max ||Error|| 2 0.961538 6 0.500000 10 0.235849 14 0.128866 18 0.796178E-01 Problem 2 Bernstein example, f(x) = abs ( x ), [-1,1] N Max ||Error|| 2 1.00000 6 0.200000 10 0.111111 14 0.769231E-01 18 0.588235E-01 Problem 3 Step function, f jumps from 0 to 1 at 0. N Max ||Error|| 2 0.500000 6 0.500000 10 0.500000 14 0.500000 18 0.500000 Problem 4 Doppler function, highly oscillatory near X = 0. N Max ||Error|| 2 0.497494 6 0.877526 10 0.822932 14 0.734273 18 0.706998 Problem 5 Rabbit ears, f(x) = max(sin(x)+sin(x^2),1-abs(x-5)/5), [0,10] N Max ||Error|| 2 1.95646 6 1.69646 10 1.52669 14 1.09013 18 1.25701 TEST06 Overhauser spline interpolation. Problem 1 Runge example, f(x) = 1 / ( x * x + 1 ), [-5,5] X Y * -5.00000 0.384615E-01 -4.50000 0.460407E-01 * -4.00000 0.588235E-01 -3.50000 0.744344E-01 * -3.00000 0.100000 -2.50000 0.133824 * -2.00000 0.200000 -1.50000 0.325000 * -1.00000 0.500000 -0.500000 0.800000 * 0.00000 1.00000 0.500000 0.800000 * 1.00000 0.500000 1.50000 0.325000 * 2.00000 0.200000 2.50000 0.133824 * 3.00000 0.100000 3.50000 0.744344E-01 * 4.00000 0.588235E-01 4.50000 0.460407E-01 * 5.00000 0.384615E-01 Problem 2 Bernstein example, f(x) = abs ( x ), [-1,1] X Y * -1.00000 1.00000 -0.900000 0.900000 * -0.800000 0.800000 -0.700000 0.700000 * -0.600000 0.600000 -0.500000 0.500000 * -0.400000 0.400000 -0.300000 0.300000 * -0.200000 0.200000 -0.100000 0.750000E-01 * 0.00000 0.00000 0.100000 0.750000E-01 * 0.200000 0.200000 0.300000 0.300000 * 0.400000 0.400000 0.500000 0.500000 * 0.600000 0.600000 0.700000 0.700000 * 0.800000 0.800000 0.900000 0.900000 * 1.00000 1.00000 Problem 3 Step function, f jumps from 0 to 1 at 0. X Y * -1.00000 0.00000 -0.900000 0.00000 * -0.800000 0.00000 -0.700000 0.00000 * -0.600000 0.00000 -0.500000 0.00000 * -0.400000 0.00000 -0.300000 -0.625000E-01 * -0.200000 0.00000 -0.100000 0.500000 * 0.00000 1.00000 0.100000 1.06250 * 0.200000 1.00000 0.300000 1.00000 * 0.400000 1.00000 0.500000 1.00000 * 0.600000 1.00000 0.700000 1.00000 * 0.800000 1.00000 0.900000 1.00000 * 1.00000 1.00000 Problem 4 Doppler function, highly oscillatory near X = 0. X Y * 0.00000 -0.00000 0.500000E-01 -0.475528E-01 * 0.100000 -0.264598E-14 0.150000 0.213988 * 0.200000 0.380423 0.250000 0.187471 * 0.300000 -0.333067E-15 0.350000 0.231767 * 0.400000 0.424264 0.450000 0.106897 * 0.500000 -0.270320 0.550000 -0.378142 * 0.600000 -0.324862 0.650000 -0.392201E-01 * 0.700000 0.269357 0.750000 0.384341 * 0.800000 0.398294 0.850000 0.310854 * 0.900000 0.184264 0.950000 0.884112E-01 * 1.00000 0.00000 Problem 5 Rabbit ears, f(x) = max(sin(x)+sin(x^2),1-abs(x-5)/5), [0,10] X Y * 0.00000 0.00000 0.500000 1.21221 * 1.00000 1.68294 1.50000 1.13415 * 2.00000 0.400000 2.50000 0.407316 * 3.00000 0.600000 3.50000 0.700000 * 4.00000 0.800000 4.50000 0.925000 * 5.00000 1.00000 5.50000 0.925000 * 6.00000 0.800000 6.50000 0.605663 * 7.00000 0.600000 7.50000 1.34903 * 8.00000 1.90938 8.50000 1.14903 * 9.00000 0.200000 9.50000 -0.886730E-01 * 10.0000 0.00000 TEST07 Cubic spline interpolation. Problem 1 Runge example, f(x) = 1 / ( x * x + 1 ), [-5,5] X Y * -5.00000 0.384615E-01 -4.50000 0.470256E-01 * -4.00000 0.588235E-01 -3.50000 0.748403E-01 * -3.00000 0.100000 -2.50000 0.140039 * -2.00000 0.200000 -1.50000 0.297358 * -1.00000 0.500000 -0.500000 0.820528 * 0.00000 1.00000 0.500000 0.820528 * 1.00000 0.500000 1.50000 0.297358 * 2.00000 0.200000 2.50000 0.140039 * 3.00000 0.100000 3.50000 0.748403E-01 * 4.00000 0.588235E-01 4.50000 0.470256E-01 * 5.00000 0.384615E-01 Problem 2 Bernstein example, f(x) = abs ( x ), [-1,1] X Y * -1.00000 1.00000 -0.900000 0.899673 * -0.800000 0.800000 -0.700000 0.700654 * -0.600000 0.600000 -0.500000 0.497712 * -0.400000 0.400000 -0.300000 0.308497 * -0.200000 0.200000 -0.100000 0.683007E-01 * 0.00000 0.00000 0.100000 0.683007E-01 * 0.200000 0.200000 0.300000 0.308497 * 0.400000 0.400000 0.500000 0.497712 * 0.600000 0.600000 0.700000 0.700654 * 0.800000 0.800000 0.900000 0.899673 * 1.00000 1.00000 Problem 3 Step function, f jumps from 0 to 1 at 0. X Y * -1.00000 0.00000 -0.900000 0.386607E-02 * -0.800000 0.00000 -0.700000 -0.773215E-02 * -0.600000 0.00000 -0.500000 0.270625E-01 * -0.400000 0.00000 -0.300000 -0.100518 * -0.200000 0.00000 -0.100000 0.500009 * 0.00000 1.00000 0.100000 1.10048 * 0.200000 1.00000 0.300000 0.973067 * 0.400000 1.00000 0.500000 1.00725 * 0.600000 1.00000 0.700000 0.997928 * 0.800000 1.00000 0.900000 1.00104 * 1.00000 1.00000 Problem 4 Doppler function, highly oscillatory near X = 0. X Y * 0.00000 -0.00000 0.500000E-01 -0.105534 * 0.100000 -0.264598E-14 0.150000 0.258620 * 0.200000 0.380423 0.250000 0.164768 * 0.300000 -0.336722E-15 0.350000 0.229054 * 0.400000 0.424264 0.450000 0.152536 * 0.500000 -0.270320 0.550000 -0.437220 * 0.600000 -0.324862 0.650000 -0.281049E-01 * 0.700000 0.269357 0.750000 0.406058 * 0.800000 0.398294 0.850000 0.305793 * 0.900000 0.184264 0.950000 0.792939E-01 * 1.00000 0.00000 Problem 5 Rabbit ears, f(x) = max(sin(x)+sin(x^2),1-abs(x-5)/5), [0,10] X Y * 0.00000 0.00000 0.500000 1.37471 * 1.00000 1.68294 1.50000 1.08720 * 2.00000 0.400000 2.50000 0.339950 * 3.00000 0.600000 3.50000 0.738369 * 4.00000 0.800000 4.50000 0.906573 * 5.00000 1.00000 5.50000 0.985340 * 6.00000 0.800000 6.50000 0.502068 * 7.00000 0.600000 7.50000 1.39506 * 8.00000 1.90938 8.50000 1.25717 * 9.00000 0.200000 9.50000 -0.284247 * 10.0000 0.00000 TEST08 B spline approximation. Problem 1 Runge example, f(x) = 1 / ( x * x + 1 ), [-5,5] X Y * -5.00000 0.384615E-01 -4.50000 0.490762E-01 * -4.00000 0.622926E-01 -3.50000 0.810709E-01 * -3.00000 0.109804 -2.50000 0.155392 * -2.00000 0.233333 -1.50000 0.358333 * -1.00000 0.533333 -0.500000 0.733333 * 0.00000 0.833333 0.500000 0.733333 * 1.00000 0.533333 1.50000 0.358333 * 2.00000 0.233333 2.50000 0.155392 * 3.00000 0.109804 3.50000 0.810709E-01 * 4.00000 0.622926E-01 4.50000 0.490762E-01 * 5.00000 0.384615E-01 Problem 2 Bernstein example, f(x) = abs ( x ), [-1,1] X Y * -1.00000 1.00000 -0.900000 0.900000 * -0.800000 0.800000 -0.700000 0.700000 * -0.600000 0.600000 -0.500000 0.500000 * -0.400000 0.400000 -0.300000 0.300000 * -0.200000 0.200000 -0.100000 0.108333 * 0.00000 0.666667E-01 0.100000 0.108333 * 0.200000 0.200000 0.300000 0.300000 * 0.400000 0.400000 0.500000 0.500000 * 0.600000 0.600000 0.700000 0.700000 * 0.800000 0.800000 0.900000 0.900000 * 1.00000 1.00000 Problem 3 Step function, f jumps from 0 to 1 at 0. X Y * -1.00000 0.00000 -0.900000 0.00000 * -0.800000 0.00000 -0.700000 0.00000 * -0.600000 0.00000 -0.500000 0.00000 * -0.400000 0.00000 -0.300000 0.208333E-01 * -0.200000 0.166667 -0.100000 0.500000 * 0.00000 0.833333 0.100000 0.979167 * 0.200000 1.00000 0.300000 1.00000 * 0.400000 1.00000 0.500000 1.00000 * 0.600000 1.00000 0.700000 1.00000 * 0.800000 1.00000 0.900000 1.00000 * 1.00000 1.00000 Problem 4 Doppler function, highly oscillatory near X = 0. X Y * 0.00000 0.00000 0.500000E-01 0.792547E-02 * 0.100000 0.634038E-01 0.150000 0.182286 * 0.200000 0.253615 0.250000 0.191125 * 0.300000 0.134114 0.350000 0.205587 * 0.400000 0.237789 0.450000 0.669967E-01 * 0.500000 -0.163647 0.550000 -0.270741 * 0.600000 -0.216736 0.650000 -0.239302E-01 * 0.700000 0.191810 0.750000 0.316987 * 0.800000 0.341133 0.850000 0.284754 * 0.900000 0.189225 0.950000 0.927520E-01 * 1.00000 0.00000 Problem 5 Rabbit ears, f(x) = max(sin(x)+sin(x^2),1-abs(x-5)/5), [0,10] X Y * 0.00000 0.00000 0.500000 0.779682 * 1.00000 1.18863 1.50000 1.01058 * 2.00000 0.647157 2.50000 0.530895 * 3.00000 0.600000 3.50000 0.700000 * 4.00000 0.800000 4.50000 0.891667 * 5.00000 0.933333 5.50000 0.891667 * 6.00000 0.800000 6.50000 0.731446 * 7.00000 0.851564 7.50000 1.22325 * 8.00000 1.40626 8.50000 1.02325 * 9.00000 0.451564 9.50000 0.131446 * 10.0000 0.00000 test_interp_fun_test(): Normal end of execution. 10 December 2023 8:08:51.308 PM