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