28 February 2022 09:21:27 AM
TEST_MIN_TEST
C version
Test the TEST_MIN library.
p00_title_test
p00_title prints the title of any problem.
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|
12 The fuzzy parabola
13 The lazy W
14 Humps
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.30323
F(X_SOL) = 1
Problem 2
Quadratic plus exponential, x^2 + e^(-x).
F(X_START) = 1.08933
F(X_SOL) = 0.827184
Problem 3
Quartic, x^4 + 2x^2 + x + 3.
F(X_START) = 14.0625
F(X_SOL) = 2.87849
Problem 4
Steep valley, e^x + 1/(100x).
F(X_START) = 2.59624
F(X_SOL) = 1.20492
Problem 5
Steep valley, e^x - 2x + 1/(100x) - 1/(1000000x^2).
F(X_START) = 1.48836
F(X_SOL) = 0.628026
Problem 6
line, 2 - x.
F(X_START) = -5.2
F(X_SOL) = -7
Problem 7
The dying snake, ( x + sin(x) ) * e^(-x^2).
F(X_START) = -5.61222e-11
F(X_SOL) = -0.824239
Problem 8
The "Thin Pole", x^2+1+log((pi-x)^2)/pi^4
F(X_START) = 29.7647
F(X_SOL) = -10000
Problem 9
The oscillatory parabola
F(X_START) = 9.36573
F(X_SOL) = -9.97791
Problem 10
The cosine combo
F(X_START) = -1.33593
F(X_SOL) = -13.0797
Problem 11
1 + |3x-1|
F(X_START) = 2.25
F(X_SOL) = 1
Problem 12
The fuzzy parabola
F(X_START) = 1.39593
F(X_SOL) = -0.9921
Problem 13
The lazy W
F(X_START) = 4.6302
F(X_SOL) = -5.24307
Problem 14
Humps
F(X_START) = 47.4483
F(X_SOL) = 11.2528
TEST03
For each problem, compare the exact and
approximate gradients at the starting point.
Problem 1
Simple quadratic, (x-2)^2+1.
X
3.14159
F'(X) (exact)
2.28319
F'(X) (difference)
2.28319
Problem 2
Quadratic plus exponential, x^2 + e^(-x).
X
0.8
F'(X) (exact)
1.15067
F'(X) (difference)
1.15067
Problem 3
Quartic, x^4 + 2x^2 + x + 3.
X
1.5
F'(X) (exact)
20.5
F'(X) (difference)
20.5
Problem 4
Steep valley, e^x + 1/(100x).
X
0.95
F'(X) (exact)
2.57463
F'(X) (difference)
2.57463
Problem 5
Steep valley, e^x - 2x + 1/(100x) - 1/(1000000x^2).
X
1.5
F'(X) (exact)
2.47725
F'(X) (difference)
2.47725
Problem 6
line, 2 - x.
X
7.2
F'(X) (exact)
-1
F'(X) (difference)
-1
Problem 7
The dying snake, ( x + sin(x) ) * e^(-x^2).
X
-5
F'(X) (exact)
-5.43395e-10
F'(X) (difference)
-5.43395e-10
Problem 8
The "Thin Pole", x^2+1+log((pi-x)^2)/pi^4
X
3.1
F'(X) (exact)
18.1064
F'(X) (difference)
18.1064
Problem 9
The oscillatory parabola
X
-2
F'(X) (exact)
55.0698
F'(X) (difference)
55.0698
Problem 10
The cosine combo
X
0.5
F'(X) (exact)
41.2254
F'(X) (difference)
41.2254
Problem 11
1 + |3x-1|
X
0.75
F'(X) (exact)
3
F'(X) (difference)
3
Problem 12
The fuzzy parabola
X
1
F'(X) (exact)
-46.669
F'(X) (difference)
-46.669
Problem 13
The lazy W
X
-0.1
F'(X) (exact)
4.392
F'(X) (difference)
4.392
Problem 14
Humps
X
0.4
F'(X) (exact)
-488.109
F'(X) (difference)
-488.109
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.14159
F"(X) (exact):
2
F"(X) (difference):
2
Problem 2
Quadratic plus exponential, x^2 + e^(-x).
X:
0.8
F"(X) (exact):
2.44933
F"(X) (difference):
2.44933
Problem 3
Quartic, x^4 + 2x^2 + x + 3.
X:
1.5
F"(X) (exact):
31
F"(X) (difference):
31
Problem 4
Steep valley, e^x + 1/(100x).
X:
0.95
F"(X) (exact):
2.60904
F"(X) (difference):
2.60904
Problem 5
Steep valley, e^x - 2x + 1/(100x) - 1/(1000000x^2).
X:
1.5
F"(X) (exact):
4.48761
F"(X) (difference):
4.48762
Problem 6
line, 2 - x.
X:
7.2
F"(X) (exact):
0
F"(X) (difference):
0
Problem 7
The dying snake, ( x + sin(x) ) * e^(-x^2).
X:
-5
F"(X) (exact):
8.39789e-09
F"(X) (difference):
-5.15675e-09
Problem 8
The "Thin Pole", x^2+1+log((pi-x)^2)/pi^4
X:
3.1
F"(X) (exact):
-5.86854
F"(X) (difference):
-5.86855
Problem 9
The oscillatory parabola
X:
-2
F"(X) (exact):
-277.798
F"(X) (difference):
-277.798
Problem 10
The cosine combo
X:
0.5
F"(X) (exact):
177.651
F"(X) (difference):
177.651
Problem 11
1 + |3x-1|
X:
0.75
F"(X) (exact):
0
F"(X) (difference):
0
Problem 12
The fuzzy parabola
X:
1
F"(X) (exact):
-1110.15
F"(X) (difference):
-1110.15
Problem 13
The lazy W
X:
-0.1
F"(X) (exact):
-13.76
F"(X) (difference):
-13.76
Problem 14
Humps
X:
0.4
F"(X) (exact):
5058.22
F"(X) (difference):
5058.22
TEST05
For each problem, take a few steps of
the bisection method.
Problem 1
Simple quadratic, (x-2)^2+1.
0
X: 0 1.5708 3.14159
F: 5 1.18422 2.30323
1
X: 1.5708 2.35619 3.14159
F: 1.18422 1.12687 2.30323
2
X: 1.5708 1.9635 2.35619
F: 1.18422 1.00133 1.12687
3
X: 1.76715 1.9635 2.15984
F: 1.05422 1.00133 1.02555
4
X: 1.86532 1.9635 2.06167
F: 1.01814 1.00133 1.0038
5
X: 1.9635 2.01258 2.06167
F: 1.00133 1.00016 1.0038
6
X: 1.9635 1.98804 2.01258
F: 1.00133 1.00014 1.00016
7
X: 1.98804 2.00031 2.01258
F: 1.00014 1 1.00016
8
X: 1.99418 2.00031 2.00645
F: 1.00003 1 1.00004
9
X: 1.99724 2.00031 2.00338
F: 1.00001 1 1.00001
10
X: 1.99878 2.00031 2.00184
F: 1 1 1
Problem 2
Quadratic plus exponential, x^2 + e^(-x).
0
X: 0 0.5 1
F: 1 0.856531 1.36788
1
X: 0 0.25 0.5
F: 1 0.841301 0.856531
2
X: 0.25 0.375 0.5
F: 0.841301 0.827914 0.856531
3
X: 0.3125 0.375 0.4375
F: 0.829272 0.827914 0.837055
4
X: 0.3125 0.34375 0.375
F: 0.829272 0.82727 0.827914
5
X: 0.34375 0.359375 0.375
F: 0.82727 0.827263 0.827914
6
X: 0.34375 0.351562 0.359375
F: 0.82727 0.827184 0.827263
7
X: 0.347656 0.351562 0.355469
F: 0.827207 0.827184 0.827203
8
X: 0.349609 0.351562 0.353516
F: 0.82719 0.827184 0.827188
9
X: 0.350586 0.351562 0.352539
F: 0.827186 0.827184 0.827185
10
X: 0.351074 0.351562 0.352051
F: 0.827185 0.827184 0.827184
Problem 3
Quartic, x^4 + 2x^2 + x + 3.
0
X: -2 0 2
F: 25 3 29
1
X: -1 0 1
F: 5 3 7
2
X: -0.5 0 0.5
F: 3.0625 3 4.0625
3
X: -0.5 -0.25 0
F: 3.0625 2.87891 3
4
X: -0.375 -0.25 -0.125
F: 2.92603 2.87891 2.90649
5
X: -0.3125 -0.25 -0.1875
F: 2.89235 2.87891 2.88405
6
X: -0.28125 -0.25 -0.21875
F: 2.88321 2.87891 2.87924
7
X: -0.25 -0.234375 -0.218