Add the Himmelblau function, as defined in Applied Nonlinear Programming.
[octave.git] / tests / himmelblau_tests.m
1 ## Test the optimal points.
2
3 unit_test_equals("himmelblau(3,2) == 0", ...
4 0, ...
5 himmelblau(3,2));
6
7 x1 = -2.805118086952745;
8 x2 = 3.131312518250573;
9 msg = sprintf("himmelblau(%f, %f) == 0", x1, x2);
10 unit_test_equals(msg, ...
11 true, ...
12 norm(himmelblau(x1, x2)) < 1e-12);
13
14 x1 = -3.779310253377747;
15 x2 = -3.283185991286170;
16 msg = sprintf("himmelblau(%f, %f) == 0", x1, x2);
17 unit_test_equals(msg, ...
18 true, ...
19 norm(himmelblau(x1, x2)) < 1e-12);
20
21 x1 = 3.584428340330492;
22 x2 = -1.848126526964404;
23 msg = sprintf("himmelblau(%f, %f) == 0", x1, x2);
24 unit_test_equals(msg, ...
25 true, ...
26 norm(himmelblau(x1, x2)) < 1e-12);