// 1. Define Rosenbrock for optimization
            function [f, g, ind]=rosenbrock(x, ind)
            f = 100.0 *(x(2) - x(1)^2)^2 + (1 - x(1))^2;
            g(1) = - 400. * ( x(2) - x(1)**2 ) * x(1) -2. * ( 1. - x(1) )
            g(2) = 200. * ( x(2) - x(1)**2 )
            endfunction

            // 2. Define rosenbrock for contouring
            function f=rosenbrockC(x1, x2)
            x = [x1 x2]
            ind = 4
            [ f , g , ind ] = rosenbrock ( x , ind )
            endfunction

            // 3. Define Rosenbrock for plotting
            function [f, g, ind]=rosenbrockPlot(x, ind)
            [ f , g , ind ] = rosenbrock ( x , ind )
            if (ind == 1) then
            plot ( x(1) , x(2) , "g." )
            end
            endfunction

            // 4. Draw the contour of Rosenbrock's function
            x0 = [-12 15];
            xopt = [1.0 1.0];
            xdata = linspace(-20,20,100);
            ydata = linspace(-20,20,100);
            contour ( xdata , ydata , rosenbrockC , [1 10 100 500 1000])
            plot(x0(1) , x0(2) , "b.")
            plot(xopt(1) , xopt(2) , "r*")

            // 5. Plot the optimization process, during optimization
            [fopt, xopt] = optim ( rosenbrockPlot , x0 , imp = -1)
