3 February 2012 9:59:41.783 PM TEST_MIN_PRB FORTRAN77 version Test the TEST_MIN library. TEST01 For each problem, print the title. Problem Title 1 Simple quadratic, (x-2)^2+1. 2 Quadratic plus exponential, x^2 + e^(-x). 3 Quartic, x^4 + 2x^2 + x + 3. 4 Steep valley, e^x + 1/(100x). 5 Steep valley, e^x - 2x + 1/(100x) - 1/(1000000x^2) 6 line, 2 - x. 7 The dying snake, ( x + sin(x) ) * e^(-x^2). 8 The "Thin Pole", x^2+1+log((pi-x)^2)/pi^4 9 The oscillatory parabola 10 The cosine combo 11 1 + |3x-1| TEST02 For each problem, evaluate the function at the starting point and the solution. Problem 1 Simple quadratic, (x-2)^2+1. F(X_START)= 2.3032338 F(X_SOL)= 1.0000000 Problem 2 Quadratic plus exponential, x^2 + e^(-x). F(X_START)= 1.0893290 F(X_SOL)= 0.82718403 Problem 3 Quartic, x^4 + 2x^2 + x + 3. F(X_START)= 14.062500 F(X_SOL)= 2.8784928 Problem 4 Steep valley, e^x + 1/(100x). F(X_START)= 2.5962360 F(X_SOL)= 1.2049206 Problem 5 Steep valley, e^x - 2x + 1/(100x) - 1/(1000000x^2) F(X_START)= 1.4883553 F(X_SOL)= 0.62802572 Problem 6 line, 2 - x. F(X_START)= -5.2000000 F(X_SOL)= -7.0000000 Problem 7 The dying snake, ( x + sin(x) ) * e^(-x^2). F(X_START)= -0.56122233E-10 F(X_SOL)= -0.82423940 Problem 8 The "Thin Pole", x^2+1+log((pi-x)^2)/pi^4 F(X_START)= 29.764712 F(X_SOL)= -10000.000 Problem 9 The oscillatory parabola F(X_START)= 9.3657292 F(X_SOL)= -9.9779149 Problem 10 The cosine combo F(X_START)= -1.3359272 F(X_SOL)= -13.079734 Problem 11 1 + |3x-1| F(X_START)= 2.2500000 F(X_SOL)= 1.0000000 TEST03 For each problem, compare the exact and approximate gradients at the starting point. Problem 1 Simple quadratic, (x-2)^2+1. X 3.1415927 F'(X) (exact) 2.2831853 F'(X) (difference) 2.2831853 Problem 2 Quadratic plus exponential, x^2 + e^(-x). X 0.80000000 F'(X) (exact) 1.1506710 F'(X) (difference) 1.1506710 Problem 3 Quartic, x^4 + 2x^2 + x + 3. X 1.5000000 F'(X) (exact) 20.500000 F'(X) (difference) 20.500000 Problem 4 Steep valley, e^x + 1/(100x). X 0.95000000 F'(X) (exact) 2.5746293 F'(X) (difference) 2.5746293 Problem 5 Steep valley, e^x - 2x + 1/(100x) - 1/(1000000x^2) X 1.5000000 F'(X) (exact) 2.4772452 F'(X) (difference) 2.4772452 Problem 6 line, 2 - x. X 7.2000000 F'(X) (exact) -1.0000000 F'(X) (difference) -1.0000000 Problem 7 The dying snake, ( x + sin(x) ) * e^(-x^2). X -5.0000000 F'(X) (exact) -0.54339490E-09 F'(X) (difference) -0.54339491E-09 Problem 8 The "Thin Pole", x^2+1+log((pi-x)^2)/pi^4 X 3.1000000 F'(X) (exact) 18.106356 F'(X) (difference) 18.106356 Problem 9 The oscillatory parabola X -2.0000000 F'(X) (exact) 55.069777 F'(X) (difference) 55.069777 Problem 10 The cosine combo X 0.50000000 F'(X) (exact) 41.225360 F'(X) (difference) 41.225360 Problem 11 1 + |3x-1| X 0.75000000 F'(X) (exact) 3.0000000 F'(X) (difference) 3.0000000 TEST04 For each problem, compare the exact and approximate second derivatives at the starting point. Problem 1 Simple quadratic, (x-2)^2+1. X: 3.1415927 F"(X) (exact): 2.0000 F"(X) (difference): 2.0000 Problem 2 Quadratic plus exponential, x^2 + e^(-x). X: 0.80000000 F"(X) (exact): 2.4493 F"(X) (difference): 2.4493 Problem 3 Quartic, x^4 + 2x^2 + x + 3. X: 1.5000000 F"(X) (exact): 31.000 F"(X) (difference): 31.000 Problem 4 Steep valley, e^x + 1/(100x). X: 0.95000000 F"(X) (exact): 2.6090 F"(X) (difference): 2.6090 Problem 5 Steep valley, e^x - 2x + 1/(100x) - 1/(1000000x^2) X: 1.5000000 F"(X) (exact): 4.4876 F"(X) (difference): 4.4876 Problem 6 line, 2 - x. X: 7.2000000 F"(X) (exact): 0.0000 F"(X) (difference): 0.0000 Problem 7 The dying snake, ( x + sin(x) ) * e^(-x^2). X: -5.0000000 F"(X) (exact): 0.83979E-08 F"(X) (difference): -0.51567E-08 Problem 8 The "Thin Pole", x^2+1+log((pi-x)^2)/pi^4 X: 3.1000000 F"(X) (exact): -5.8685 F"(X) (difference): -5.8685 Problem 9 The oscillatory parabola X: -2.0000000 F"(X) (exact): -277.80 F"(X) (difference): -277.80 Problem 10 The cosine combo X: 0.50000000 F"(X) (exact): 177.65 F"(X) (difference): 177.65 Problem 11 1 + |3x-1| X: 0.75000000 F"(X) (exact): 0.0000 F"(X) (difference): 0.0000 TEST05 For each problem, take a few steps of the bisection method. Problem 1 Simple quadratic, (x-2)^2+1. 0 X: 0.0000000 1.5707963 3.1415927 F: 5.0000000 1.1842158 2.3032338 1 X: 1.5707963 2.3561945 3.1415927 F: 1.1842158 1.1268745 2.3032338 2 X: 1.5707963 1.9634954 2.3561945 F: 1.1842158 1.0013326 1.1268745 3 X: 1.7671459 1.9634954 2.1598449 F: 1.0542210 1.0013326 1.0255504 4 X: 1.8653206 1.9634954 2.0616702 F: 1.0181385 1.0013326 1.0038032 5 X: 1.9634954 2.0125828 2.0616702 F: 1.0013326 1.0001583 1.0038032 6 X: 1.9634954 1.9880391 2.0125828 F: 1.0013326 1.0001431 1.0001583 7 X: 1.9880391 2.0003109 2.0125828 F: 1.0001431 1.0000001 1.0001583 8 X: 1.9941750 2.0003109 2.0064469 F: 1.0000339 1.0000001 1.0000416 9 X: 1.9972430 2.0003109 2.0033789 F: 1.0000076 1.0000001 1.0000114 10 X: 1.9987770 2.0003109 2.0018449 F: 1.0000015 1.0000001 1.0000034 Problem 2 Quadratic plus exponential, x^2 + e^(-x). 0 X: 0.0000000 0.50000000 1.0000000 F: 1.0000000 0.85653066 1.3678794 1 X: 0.0000000 0.25000000 0.50000000 F: 1.0000000 0.84130078 0.85653066 2 X: 0.25000000 0.37500000 0.50000000 F: 0.84130078 0.82791428 0.85653066 3 X: 0.31250000 0.37500000 0.43750000 F: 0.82927188 0.82791428 0.83705478 4 X: 0.31250000 0.34375000 0.37500000 F: 0.82927188 0.82727024 0.82791428 5 X: 0.34375000 0.35937500 0.37500000 F: 0.82727024 0.82726290 0.82791428 6 X: 0.34375000 0.35156250 0.35937500 F: 0.82727024 0.82718407 0.82726290 7 X: 0.34765625 0.35156250 0.35546875 F: 0.82720651 0.82718407 0.82720288 8 X: 0.34960938 0.35156250 0.35351563 F: 0.82719013 0.82718407 0.82718832 9 X: 0.35058594 0.35156250 0.35253906 F: 0.82718581 0.82718407 0.82718490 10 X: 0.35107422 0.35156250 0.35205078 F: 0.82718461 0.82718407 0.82718416 Problem 3 Quartic, x^4 + 2x^2 + x + 3. 0 X: -2.0000000 0.0000000 2.0000000 F: 25.000000 3.0000000 29.000000 1 X: -1.0000000 0.0000000 1.0000000 F: 5.0000000 3.0000000 7.0000000 2 X: -0.50000000 0.0000000 0.50000000 F: 3.0625000 3.0000000 4.0625000 3 X: -0.50000000 -0.25000000 0.0000000 F: 3.0625000 2.8789063 3.0000000 4 X: -0.37500000 -0.25000000 -0.12500000 F: 2.9260254 2.8789063 2.9064941 5 X: -0.31250000 -0.25000000 -0.18750000 F: 2.8923492 2.8789063 2.8840485 6 X: -0.28125000 -0.25000000 -0.21875000 F: 2.8832102 2.8789063 2.8792429 7 X: -0.25000000 -0.23437500 -0.21875000 F: 2.8789063 2.8785058 2.8792429 8 X: -0.24218750 -0.23437500 -0.22656250 F: 2.8785625 2.8785058 2.8787335 9 X: -0.24218750 -0.23828125 -0.23437500 F: 2.8785625 2.8784984 2.8785058 10 X: -0.23828125 -0.23632813 -0.23437500 F: 2.8784984 2.8784932 2.8785058 Problem 4 Steep valley, e^x + 1/(100x). 0 X: 0.10000000E-03 0.50005000 1.0000000 F: 101.00010 1.6688017 2.7282818 1 X: 0.10000000E-03 0.25007500 0.50005000 F: 101.00010 1.3241097 1.6688017 2 X: 0.10000000E-03 0.12508750 0.25007500 F: 101.00010 1.2131916 1.3241097 3 X: 0.62593750E-01 0.12508750 0.18758125 F: 1.2243546 1.2131916 1.2596385 4 X: 0.62593750E-01 0.93840625E-01 0.12508750 F: 1.2243546 1.2049483 1.2131916 5 X: 0.78217187E-01 0.93840625E-01 0.10946406 F: 1.2092066 1.2049483 1.2070342 6 X: 0.86028906E-01 0.93840625E-01 0.10165234 F: 1.2060778 1.2049483 1.2053731 7 X: 0.89934766E-01 0.93840625E-01 0.97746484E-01 F: 1.2052946 1.2049483 1.2049887 8 X: 0.93840625E-01 0.95793555E-01 0.97746484E-01 F: 1.2049483 1.2049230 1.2049887 9 X: 0.94817090E-01 0.95793555E-01 0.96770020E-01 F: 1.2049240 1.2049230 1.2049448 10 X: 0.94817090E-01 0.95305322E-01 0.95793555E-01 F: 1.2049240 1.2049206 1.2049230 Problem 5 Steep valley, e^x - 2x + 1/(100x) - 1/(1000000x^2) 0 X: 0.20000000E-03 1.0001000 2.0000000 F: 25.999800 0.72835167 3.3940558 1 X: 0.20000000E-03 0.50015000 1.0001000 F: 25.999800 0.66865860 0.72835167 2 X: 0.50015000 0.75012500 1.0001000 F: 0.66865860 0.63034399 0.72835167 3 X: 0.62513750 0.75012500 0.87511250 F: 0.63422178 0.63034399 0.66034598 4 X: 0.62513750 0.68763125 0.75012500 F: 0.63422178 0.62827657 0.63034399 5 X: 0.65638437 0.68763125 0.71887812 F: 0.63027339 0.62827657 0.62828206 6 X: 0.68763125 0.70325469 0.71887812 F: 0.62827657 0.62802572 0.62828206 7 X: 0.69544297 0.70325469 0.71106641 F: 0.62808817 0.62802572 0.62809007 8 X: 0.69934883 0.70325469 0.70716055 F: 0.62804115 0.62802572 0.62804199 9 X: 0.70130176 0.70325469 0.70520762 F: 0.62802948 0.62802572 0.62802989 10 X: 0.70227822 0.70325469 0.70423115 F: 0.62802661 0.62802572 0.62802682 Problem 6 line, 2 - x. 0 X: 7.0000000 8.0000000 9.0000000 F: -5.0000000 -6.0000000 -7.0000000 1 X: 8.0000000 8.5000000 9.0000000 F: -6.0000000 -6.5000000 -7.0000000 2 X: 8.5000000 8.7500000 9.0000000 F: -6.5000000 -6.7500000 -7.0000000 3 X: 8.7500000 8.8750000 9.0000000 F: -6.7500000 -6.8750000 -7.0000000 4 X: 8.8750000 8.9375000 9.0000000 F: -6.8750000 -6.9375000 -7.0000000 5 X: 8.9375000 8.9687500 9.0000000 F: -6.9375000 -6.9687500 -7.0000000 6 X: 8.9687500 8.9843750 9.0000000 F: -6.9687500 -6.9843750 -7.0000000 7 X: 8.9843750 8.9921875 9.0000000 F: -6.9843750 -6.9921875 -7.0000000 8 X: 8.9921875 8.9960938 9.0000000 F: -6.9921875 -6.9960938 -7.0000000 9 X: 8.9960938 8.9980469 9.0000000 F: -6.9960938 -6.9980469 -7.0000000 10 X: 8.9980469 8.9990234 9.0000000 F: -6.9980469 -6.9990234 -7.0000000 Problem 7 The dying snake, ( x + sin(x) ) * e^(-x^2). 0 X: -10.000000 0.0000000 10.000000 F: -0.35176960E-42 0.0000000 0.35176960E-42 1 X: -10.000000 -5.0000000 0.0000000 F: -0.35176960E-42 -0.56122233E-10 0.0000000 2 X: -5.0000000 -2.5000000 0.0000000 F: -0.56122233E-10 -0.59814584E-02 0.0000000 3 X: -2.5000000 -1.2500000 0.0000000 F: -0.59814584E-02 -0.46093222 0.0000000 4 X: -1.2500000 -0.62500000 0.0000000 F: -0.46093222 -0.81879277 0.0000000 5 X: -0.93750000 -0.62500000 -0.31250000 F: -0.72399909 -0.81879277 -0.56225982 6 X: -0.78125000 -0.62500000 -0.46875000 F: -0.80681920 -0.81879277 -0.73893781 7 X: -0.78125000 -0.70312500 -0.62500000 F: -0.80681920 -0.82326228 -0.81879277 8 X: -0.70312500 -0.66406250 -0.62500000 F: -0.82326228 -0.82380678 -0.81879277 9 X: -0.70312500 -0.68359375 -0.66406250 F: -0.82326228 -0.82421070 -0.82380678 10 X: -0.69335938 -0.68359375 -0.67382813 F: -0.82390302 -0.82421070 -0.82418025 Problem 8 The "Thin Pole", x^2+1+log((pi-x)^2)/pi^4 0 X: 2.0000000 3.0000000 4.0000000 F: 13.002719 27.959864 48.996865 1 X: 2.0000000 2.5000000 3.0000000 F: 13.002719 19.740888 27.959864 2 X: 2.0000000 2.2500000 2.5000000 F: 13.002719 16.185144 19.740888 3 X: 2.0000000 2.1250000 2.2500000 F: 13.002719 14.547213 16.185144 4 X: 2.0000000 2.0625000 2.1250000 F: 13.002719 13.763282 14.547213 5 X: 2.0000000 2.0312500 2.0625000 F: 13.002719 13.380079 13.763282 6 X: 2.0000000 2.0156250 2.0312500 F: 13.002719 13.190668 13.380079 7 X: 2.0000000 2.0078125 2.0156250 F: 13.002719 13.096511 13.190668 8 X: 2.0000000 2.0039063 2.0078125 F: 13.002719 13.049569 13.096511 9 X: 2.0000000 2.0019531 2.0039063 F: 13.002719 13.026133 13.049569 10 X: 2.0000000 2.0009766 2.0019531 F: 13.002719 13.014423 13.026133 Problem 9 The oscillatory parabola 0 X: -5.0000000 0.0000000 5.0000000 F: 34.165215 -9.0929743 30.365729 1 X: -2.5000000 0.0000000 2.5000000 F: 6.6702435 -9.0929743 -0.56638760 2 X: -1.2500000 0.0000000 1.2500000 F: -7.0069598 -9.0929743 3.4265330 3 X: -0.62500000 0.0000000 0.62500000 F: 9.4091244 -9.0929743 -4.5401619 4 X: -0.31250000 0.0000000 0.31250000 F: -0.96469928 -9.0929743 -9.0709987 5 X: 0.0000000 0.15625000 0.31250000 F: -9.0929743 -9.9744410 -9.0709987 6 X: 0.78125000E-01 0.15625000 0.23437500 F: -9.7927060 -9.9744410 -9.7062427 7 X: 0.11718750 0.15625000 0.19531250 F: -9.9445500 -9.9744410 -9.8916212 8 X: 0.13671875 0.15625000 0.17578125 F: -9.9741875 -9.9744410 -9.9465027 9 X: 0.13671875 0.14648438 0.15625000 F: -9.9741875 -9.9779142 -9.9744410 10 X: 0.14160156 0.14648438 0.15136719 F: -9.9769601 -9.9779142 -9.9770683 Problem 10 The cosine combo 0 X: 0.0000000 3.5000000 7.0000000 F: 16.000000 3.4132606 13.379068 1 X: 0.0000000 1.7500000 3.5000000 F: 16.000000 -10.115345 3.4132606 2 X: 0.87500000 1.7500000 2.6250000 F: -1.7979768 -10.115345 -0.25866382 3 X: 1.3125000 1.7500000 2.1875000 F: 9.2225180 -10.115345 -4.4831755 4 X: 1.5312500 1.7500000 1.9687500 F: 4.7268375 -10.115345 -5.2284309 5 X: 1.6406250 1.7500000 1.8593750 F: -4.2824255 -10.115345 -9.6194386 6 X: 1.7500000 1.8046875 1.8593750 F: -10.115345 -10.630465 -9.6194386 7 X: 1.7773438 1.8046875 1.8320313 F: -10.582450 -10.630465 -10.291399 8 X: 1.7773438 1.7910156 1.8046875 F: -10.582450 -10.657398 -10.630465 9 X: 1.7841797 1.7910156 1.7978516 F: -10.632899 -10.657398 -10.656403 10 X: 1.7910156 1.7944336 1.7978516 F: -10.657398 -10.660054 -10.656403 Problem 11 1 + |3x-1| 0 X: 0.0000000 0.50000000 1.0000000 F: 2.0000000 1.5000000 3.0000000 1 X: 0.0000000 0.25000000 0.50000000 F: 2.0000000 1.2500000 1.5000000 2 X: 0.25000000 0.37500000 0.50000000 F: 1.2500000 1.1250000 1.5000000 3 X: 0.25000000 0.31250000 0.37500000 F: 1.2500000 1.0625000 1.1250000 4 X: 0.31250000 0.34375000 0.37500000 F: 1.0625000 1.0312500 1.1250000 5 X: 0.31250000 0.32812500 0.34375000 F: 1.0625000 1.0156250 1.0312500 6 X: 0.32812500 0.33593750 0.34375000 F: 1.0156250 1.0078125 1.0312500 7 X: 0.32812500 0.33203125 0.33593750 F: 1.0156250 1.0039063 1.0078125 8 X: 0.33203125 0.33398438 0.33593750 F: 1.0039063 1.0019531 1.0078125 9 X: 0.33203125 0.33300781 0.33398438 F: 1.0039063 1.0009766 1.0019531 10 X: 0.33300781 0.33349609 0.33398438 F: 1.0009766 1.0004883 1.0019531 TEST06 For each problem, use Brent's method. Problem 1 Simple quadratic, (x-2)^2+1. Initial interval [A,B]: A, B: 0.0000000 3.1415927 FA, FB: 5.0000000 2.3032338 Final interval [A,X*,B]: A, X*, B: 1.9999996 2.0000000 2.0000004 FA, FX*, FB: 1.0000000 1.0000000 1.0000000 Problem 2 Quadratic plus exponential, x^2 + e^(-x). Initial interval [A,B]: A, B: 0.0000000 1.0000000 FA, FB: 1.0000000 1.3678794 Final interval [A,X*,B]: A, X*, B: 0.35173337 0.35173370 0.35173404 FA, FX*, FB: 0.82718403 0.82718403 0.82718403 Problem 3 Quartic, x^4 + 2x^2 + x + 3. Initial interval [A,B]: A, B: -2.0000000 2.0000000 FA, FB: 25.000000 29.000000 Final interval [A,X*,B]: A, X*, B: -0.23673324 -0.23673291 -0.23673257 FA, FX*, FB: 2.8784928 2.8784928 2.8784928 Problem 4 Steep valley, e^x + 1/(100x). Initial interval [A,B]: A, B: 0.10000000E-03 1.0000000 FA, FB: 101.00010 2.7282818 Final interval [A,X*,B]: A, X*, B: 0.95344301E-01 0.95344636E-01 0.95344971E-01 FA, FX*, FB: 1.2049206 1.2049206 1.2049206 Problem 5 Steep valley, e^x - 2x + 1/(100x) - 1/(1000000x^2) Initial interval [A,B]: A, B: 0.20000000E-03 2.0000000 FA, FB: 25.999800 3.3940558 Final interval [A,X*,B]: A, X*, B: 0.70320453 0.70320487 0.70320521 FA, FX*, FB: 0.62802572 0.62802572 0.62802572 Problem 6 line, 2 - x. Initial interval [A,B]: A, B: 7.0000000 9.0000000 FA, FB: -5.0000000 -7.0000000 Final interval [A,X*,B]: A, X*, B: 8.9999989 8.9999994 9.0000000 FA, FX*, FB: -6.9999989 -6.9999994 -7.0000000 Problem 7 The dying snake, ( x + sin(x) ) * e^(-x^2). Initial interval [A,B]: A, B: -10.000000 10.000000 FA, FB: -0.35176960E-42 0.35176960E-42 Final interval [A,X*,B]: A, X*, B: -0.67957911 -0.67957876 -0.67957842 FA, FX*, FB: -0.82423940 -0.82423940 -0.82423940 Problem 8 The "Thin Pole", x^2+1+log((pi-x)^2)/pi^4 Initial interval [A,B]: A, B: 2.0000000 4.0000000 FA, FB: 13.002719 48.996865 Final interval [A,X*,B]: A, X*, B: 2.0000000 2.0000007 2.0000011 FA, FX*, FB: 13.002719 13.002727 13.002732 Problem 9 The oscillatory parabola Initial interval [A,B]: A, B: -5.0000000 5.0000000 FA, FB: 34.165215 30.365729 Final interval [A,X*,B]: A, X*, B: -1.3384524 -1.3384521 -1.3384517 FA, FX*, FB: -8.1974224 -8.1974224 -8.1974224 Problem 10 The cosine combo Initial interval [A,B]: A, B: 0.0000000 7.0000000 FA, FB: 16.000000 13.379068 Final interval [A,X*,B]: A, X*, B: 1.0167817 1.0167821 1.0167824 FA, FX*, FB: -6.2827509 -6.2827509 -6.2827509 Problem 11 1 + |3x-1| Initial interval [A,B]: A, B: 0.0000000 1.0000000 FA, FB: 2.0000000 3.0000000 Final interval [A,X*,B]: A, X*, B: 0.33333299 0.33333351 0.33333385 FA, FX*, FB: 1.0000010 1.0000005 1.0000015 TEST_MIN_PRB Normal end of execution. 3 February 2012 9:59:41.787 PM