function y=fg(x)
  y=0
  for i=1:size(x,2)-1  
    y = y+100*(x(i+1)-x(i)^2)^2 + (1-x(i))^2;
  end  
endfunction

//opt = optimset ( "PlotFcns" , optimplotfval );
//opt = optimset ( "MaxIter" , 20 );
//opt = optimset ( "PlotFcns" , optimplotx );
opt = optimset ( "Display" , "iter" );
[x fval] = fminsearch (fg , [3,2],opt);

