Section 14.6: Gradient Vectors: Here we need the package "vect"

load(vect);

Example 4: Directional derivative

f: x^2*y^3 - 4*y;

del_f: [diff(f,x), diff(f,y)];

del_f: del_f,x=2,y=-1;

v: [2,5];

u: v/sqrt(v.v);

del_f . u;

Example 6: Significance of Gradient Vector

f: x*exp(y);

del_f: [diff(f,x), diff(f,y)];

del_f: del_f, x=2,y=0;

PQ: [1/2,2] - [2,0];

u: PQ/sqrt(PQ.PQ);

del_f . u;

wxdraw3d(color=red, contour=map, contour_levels={1,2,3,4,5},
   explicit(f,x,0,3,y,0,2),
    head_length=0.1, color=cyan,
    vector([2,0,0],[-3/5,4/5,0]),
user_preamble="unset clabel",xlabel="x",ylabel="y");

u: del_f / sqrt(del_f.del_f);

del_f . u;

wxdraw3d(color=red, contour=map, contour_levels={1,2,3,4,5},
   explicit(f,x,0,3,y,0,2),
    head_length=0.1, color=cyan,
    vector([2,0,0],[1/sqrt(5),2/sqrt(5),0]),
user_preamble="unset clabel",xlabel="x",ylabel="y");

sqrt(del_f.del_f);

Example 8: Tangent Plane to Surface

F: x^2/4+y^2+z^2/9;

del_F: ev(express(grad(F)), diff);

nn: del_F, x=-2, y=1, z=-3;

p: nn . ([x,y,z] - [-2,1,-3]) = 0;

expand(-3*p);

Exercise 12: Find the directional derivative
at x=2, y=1 in the direction [-1,2] for f(x,y) = log(x^2+y^2)

f: log(x^2+y^2);

del_f: [diff(f,x), diff(f,y)];

v: [-1,2];

D_u: del_f . v/sqrt(v.v), x=2, y=1;

Exercise 44: Find an equation of the tangent plane
at x=0, y=0, z=1 for F(x,y,z) = log(x+z) - y*z = 0

F: log(x+z) - y*z;

del_F: ev(express(grad(F)), diff);

nn: del_F, x=0, y=0, z=1;

nn . [x,y,z-1] = 0;