 
 clear
 close

 disp('     Using Contour Maps to find critical points  ')
 disp(' ')
 disp(' Look at the graph of  ')
 disp('  f(x,y) =   2*exp(-(x-1)^2 -(y-1)^2)  ')
 disp('                  + 1.8*exp(-5((x+1)^2 -3*y^2)  ')
 disp('                        - exp(-2*(x-1)^2 -2*(y+.5)^2)  ') 


 f1 = '2*exp(-(x-1).^2 -(y-1).^2)' ;
 f2 = '+1.8*exp(-5*(x+1).^2 -3*y.^2)' ;
 f3 = '- exp(-2*(x-1).^2 -2*(y+.5).^2)' ;
 f = inline([f1,f2,f3],'x', 'y');

 x = linspace(-2,2, 51); y = x;
 [X,Y] = meshgrid(x,y);
 surf(X,Y,f(X,Y))
 pause

 disp(' Next do a contour plot  ')

 levels = linspace(-1,2, 21);
 contour(X,Y,f(X,Y), levels)
 pause

 disp(' ')
 disp(' Now use "findcrit" to find the critical points  ')
 disp(' You do this three times ')
 
 corners = [-2,2 -2 2];
 findcrit(f,corners)

 disp(' Move on to another critical point ')
 pause

 findcrit(f,corners)
 disp(' Move on to another critical point ')
 pause


 findcrit(f, corners)
 pause
 close






