 disp('  Graph of the function f(x,y) = x^2 + y^2 - y^3/3 over the')
 disp(' rectangle R = [-1,1] x [ -1 3].  There is a saddle at ( 0,2)')
 disp('  and a local min at ( 0,0), f(0,0) = 0 ')
 disp(' ')
 
   x = linspace( -1,1, 51);
   y = linspace( -1, 3, 51);
   f = inline(' x.^2 + y.^2 -(1/3)*y.^3','x', 'y');
   [X,Y] = meshgrid(x,y);
   subplot(2,1,1)
      surf(X,Y,f(X,Y)); shading flat;
      rotate3d on
      
   disp(' To find the max and min of f over R we will need to look at')
   disp('  the values of f on the boundary of R ')
   pause
   disp(' From the graph of the boundary curves, it is clear that the ')
   disp(' minimum value is attained at ( 0,3), f(0,3) = 0, and the max value')
   disp(' is attained at ( 1,1) and (-1,1),and at ( -1,2) and (1,2). The ')
   disp('value at all four points is f(1,1) = f(-1,1) = 7/3 .')
   subplot(2,1,2)
      plot3(x,-1+0*y, f(x,-1))
      hold on
      plot3(1+0*x, y, f(1,y))
      plot3(-1+0*x, y, f(-1,y))
      plot3(x, 3+0*y, f( x,3))
      
      plot3([-1 1 1 -1 -1], [ -1 -1 3 3 -1], [0 0 0 0 0], 'r')
      plot3(0,3,0, '*')
      plot3(-1,-1, 7/3, '*')
      plot3(1,-1, 7/3, '*')
      plot3(-1,2, 7/3, '*')
      plot3(1,2, 7/3, '*')
      plot3(0,0,0, '*')
      
      rotate3d on
    
  hold off
   
