function f=rosenbrockS(x)
   f = 100*(x(2)-x(1)^2)^2 + (1-x(1))^2         // objective function
endfunction

function [f, g, ind]=rosenbrockNG(x, ind)
f = rosenbrockS(x)         // objective function
g(1) = - 400*(x(2)-x(1)^2)*x(1) - 2*(1-x(1)) // components of the gradient
g(2) = 200*(x(2)-x(1)^2)
//g=numderivative(rosenbrockS,x)
endfunction

function [f, g, ind]=rosenbrockG(x, ind)
f = 100*(x(2)-x(1)^2)^2 + (1-x(1))^2         // fctie obiectiv
g(1) = - 400*(x(2)-x(1)^2)*x(1) - 2*(1-x(1)) // componente ale gradientului
g(2) = 200*(x(2)-x(1)^2)
endfunction

x0 = [-10.0 15];
//[ fopt , xopt, gopt] = optim ( rosenbrockG , x0, "gc" ) 
//[ fopt , xopt, gopt ] = optim ( rosenbrockG ,  x0,"qn" )
[ fopt , xopt ] = optim ( rosenbrockG ,  x0,"gc" )

