%STEEPEST DESCENT METHOD FOR COPMUTING MINS of
%f(x,y) = x^2+y^2/2-xy+x^3+x^4/2

clear all

%These initial conditions converge to a max at (0,0)
%x(1) = -0.5
%x(2) = -.3

%These initial conditions converge to a min at (0,0)
%x(1) = .2
%x(2) = 1

%These initial conditions converge to a min at (0,0)
%x(1) = 0.1
%x(2) = 1

%These initial conditions converge to a min at (-1,-1)
%x(1) = -.6
%x(2) = -.7

%These initial conditions converge to a min at (0,0)
x(1) = -.4
x(2) = -.4

x = x'

for k = 1:5000
    
   gf(1) = 2*x(1)-x(2)+3*(x(1))^2+2*(x(1))^3;;
   gf(2) = x(2)-x(1);
  
   x = x -.01*gf'

end


extreme1 = x(1)^2+x(2)^2/2-x(1)*x(2)+x(1)^3+x(1)^4/2
x(1) = x(1)+.01;
x(2) = x(2) + .01;
extreme2 = x(1)^2+x(2)^2/2-x(1)*x(2)+x(1)^3+x(1)^4/2