 clear
 close all

disp(' ')
 disp('              Directional Derivatives  ')
 disp(' ')
 disp('           f(x,y) = 2*x^2 +y  ')
 disp(' Directional derivatives at the point p = [1,2] ')
 
 clear f
  f = inline('2*x.^2 +y', 'x', 'y');
 disp(' First we look at the graph and some level curves  ')
  x= linspace(0, 2, 51);
  y = linspace(0, 4, 51);
  [X,Y] = meshgrid(x,y);
  subplot(2,1,1)
    surf(X,Y,f(X,Y)); shading flat;
   subplot(2,1,2)
    contour(X,Y, f(X,Y));
    hold on
    plot(1,2,'*')
    hold off
  pause

  disp(' ')
  disp(' Now we look at the point (1,2) more closely and evaluate')
  disp(' the directional derivative in several directions ')
  clf
  p = [1,2];
  mslice(f,p)
  pause
  close

