clear all
echo on
%alpha=1;
alpha=100;
xx = [-2:0.125:2]';
yy = [-2:0.125:3]';
[x,y]=meshgrid(xx',yy') ;
meshd = alpha.*(y-x.*x).^2 + (1-x).^2; 
mesh(meshd);
z=meshd;
disp('hit any key to continue')
pause
s=surf(x,y,z);
disp('hit any key to continue')
pause
x=-1;y=-1;
grad=[ 2* alpha*(y-x^2)*(-2*x)-2*(1-x);2*alpha*(y-x^2)];  % at [x;y]
d= -grad;    % negative gradient 
%t=0:.01:5;
t=0:.0001:.003;
fd= alpha.*( (y+(t*d(2))) - ( x+(t*d(1)) ).^2 ).^2 + (1-  (  x+(t*d(1)) )  ).^2; 
plot(t,fd)
disp('hit any key to continue')
pause
disp('now we start optdemo')
optdemo
