15.6 Directional Derivatives and the Gradient
Tangent Planes and Normal Lines

Example

Find the equation of the tangent plane and the normal line to the sphere (x^2) + (y^2) + (z^2)= 6at the point (1, 1, 2). Combine all three objects in one plot.

Gradient:

F  =  (x^2) +  (y^2) +  (z^2);
grad[x_, y_, z_]  =  {D[F, x], D[F, y], D[F, z]}

Tangent Plane:

p  =  {1, 1, 2};

n  =  grad[1, 1, 2]

n . {x, y, z}  ==  n . p

Normal Line:

r[t_]  =  p  +  t n

graph  =  
        Plot3D[(Sqrt[6  -  (x^2) -  (y^2)]), {x, 0, 1.5}, {y, 0, 
            1.5}];

tplane  =  
        Plot3D[(6  -  x  -  y)/2, {x, 0.5, 1.5}, {y, 0.5, 
            1.5}];

nline  =  
        ParametricPlot3D[r[t], {t, - .25,  .25}];

Show[graph, tplane, nline, BoxRatios -> Automatic, 
      ViewPoint -> {2,  -1.5,  1.5}]

The option BoxRatios needs to be set to Automatic, otherwise the normal line will not look perpendicular due to the compressed vertical scale that Mathematica would use by default.

Example

Find the equation of the plane tangent to the graph of f(x, y)  =  ((x^2) -  (y^3))/6 at the point (3, 2, 1/6).

Solution. Let g(x, y, z)  =  z  - ( (x^2) - (y^3))/6, so the graph z  =  f(x, y)is the level surface g(x, y, z)  =  0.

Gradient:

F  = z  -  ( (x^2) -  (y^3))/6;
grad[x_, y_, z_]  =  {D[F, x], D[F, y], D[F, z]}

Tangent Plane:

p  =  {3, 2, 1/6};

n  =  grad[3, 2, 1/6]

n . {x, y, z}  ==  n . p

Normal Line:

r[t_]  =  p  +  t n

graph  =  
        Plot3D[((x^2) - (y^(3 )))/6, {x, 2, 4}, {y, 1, 3}, 
          PlotPoints -> 30];

tplane  =  
        Plot3D[7/6  + x  - 2  y, {x, 2, 4}, {y, 1, 3}];

nline  =  ParametricPlot3D[r[t], {t, - .5,  .5}];

Show[graph, tplane, nline, BoxRatios -> Automatic, 
      ViewPoint -> {2,  3,  1}]

Example

Find the tangent and normal line to the curve defiend by sin(x y)  +  x  +  (y^2) =  π + 1at the point (π, 1).

Gradient:

f  =  Sin[x y]  +  x  +  (y^2);
n = grad[x_, y_]  =  {D[f, x], D[f, y]}

Tangent line:

p  =  {π, 1};
n  = grad[π, 1]

n . {x, y}  ==  n . p

or y  =  1.

Normal Line:

p  +  t n

This is the line x  =  π.

curve  =  
      ContourPlot[
        Sin[x y]  +  x  +  (y^2), {x, 0, 2  π}, {y, -2, 2}, 
        PlotPoints -> 50,  Contours -> {π + 1},  
        ContourShading -> False]

tl  =  ParametricPlot[{x, 1}, {x, π - 1, π + 1}]

nl  =  ParametricPlot[{π, y}, {y, 0, 2}]

Show[curve, tl, nl]