A.1 Example 1

The following code shows a simple example of using mips to solve a 2-dimensional unconstrained optimization of Rosenbrock’s “banana” function58

f(x) = 100(x2 − x21)2 + (1 − x1)2.
(A.7)

First, create a Matlab function that will evaluate the objective function, its gradients and Hessian, for a given value of x  . In this case, the coefficient of the first term is defined as a paramter a.

function [f, df, d2f] = banana(x, a)
f = a*(x(2)-x(1)^2)^2+(1-x(1))^2;
if nargout > 1          %% gradient is required
    df = [  4*a*(x(1)^3 - x(1)*x(2)) + 2*x(1)-2;
            2*a*(x(2) - x(1)^2)                     ];
    if nargout > 2      %% Hessian is required
        d2f = 4*a*[ 3*x(1)^2 - x(2) + 1/(2*a),  -x(1);
                    -x(1)                       1/2 ];
    end
end

Then, create a handle to the function, defining the value of the paramter a to be 100, set up the starting value of x  , and call the mips function to solve it.

>> f_fcn = @(x)banana(x, 100);
>> x0 = [-1.9; 2];
>> [x, f] = mips(f_fcn, x0)

x =

     1
     1


f =

     0