            function f=rosenbrock(x)
                f=0
                //n=size(x,2)
                for i=1:n-1
                    f=f+100.0*(x(i+1)-x(i))^2+(1-x(i))^2;
                end
            endfunction

            function [f, g, ind]=rosenbrockCost(x, ind)
            f = rosenbrock ( x );
            g = numderivative ( rosenbrock , x );
            endfunction
            n=500
            x0 = 100*rand(1,n)-50; disp(x0,"x0=");
            [ fopt , xopt ] = optim (rosenbrockCost , x0,"gc" )
