## The gradient should be zero at the optimal point. for m = [ 1 : 10 ] x = repmat([0;0;0;0], m, 1); msg = sprintf("extended_powell_gradient1([0;0;0;0;...]) == 0 (m = %d)", m); unit_test_equals(msg, 0, extended_powell_gradient1(x)); end ## It should fail with the wrong number of coordinates. g = extended_powell_gradient1([1;2;3]); msg = "extended_powell_gradient1 fails when length(x) is odd"; unit_test_equals(msg, true, isna(g));