Tangent Plane and Normal Line Examples

1) Find and graph the tangent plane and normal line for 
f(x,y)==-x y (e^(-(x^2)-(y^2))) at the point (-(1/2), (1/2), (1/(4 (Sqrt[e])))).

Plot the surface:

Plot3D[-x*y*E^(-x^2-y^2),{x,-1,1},{y,-1,1},PlotStyle->Blue,Mesh->None]

Change domain to center at point of interest and name this to be “surface” for later use.

surface=Plot3D[-x*y*E^(-x^2-y^2),{x,-1,0},{y,0,1},PlotStyle->Blue,Mesh->None]

Find the derivative of F(x, y, z) = z - f(x, y) with respect to x:

D[z+x*y*E^(-x^2-y^2),x]

Find the derivative of F(x, y, z) with respect to x and substitute in values for x and y.

D[z+x*y*E^(-x^2-y^2),x]/.{x->-1/2,y->1/2}

Do the same thing for the y and z partial derivatives.

D[z+x*y*E^(-x^2-y^2),y]/.{x->-1/2,y->1/2}
D[z+x*y*E^(-x^2-y^2),z]/.{x->-1/2,y->1/2}

There is also a built-in gradient function: Grad.
You have to indicate the variables as the second argument to Grad. See below.

Grad[z+x*y*E^(-x^2-y^2),{x,y,z}]

Grad[z+x*y*E^(-x^2-y^2),{x,y,z}]/.{x->-1/2,y->1/2,z->(1/(4 (Sqrt[E])))}

Make Mathematica solve a(x - x0) + b(y - y0) + c(z - z0) = 0 for z so it's easy to plot.
Note the double equals == within the equation.

Solve[(1/(4 (Sqrt[E])))(x+1/2)-(1/(4 (Sqrt[E])))(y-1/2)+1(z-(1/(4 (Sqrt[E]))))==0,z]

Graph the plane:

plane=Plot3D[((-x+y)/(4 (Sqrt[E]))),{x,-3/4,-1/4},{y,1/4,3/4},Mesh->None]

Show the surface and the plane together:

Show[surface,plane,BoxRatios->Automatic,PlotRange->All]

Graph the normal line:

NormalLine=ParametricPlot3D[{(1/(4 (Sqrt[E])))t-1/2,-(1/(4 (Sqrt[E])))t+1/2,1t+(1/(4 (Sqrt[E])))},{t,0,0.3},PlotStyle->Red]

Show all together:

Show[surface,plane, NormalLine,BoxRatios->Automatic,PlotRange->All]

Extra: Plot the contour map for f(x, y) over the smaller and larger domains.

ContourPlot[-x*y*E^(-x^2-y^2),{x,-1,0},{y,0,1}]

ContourPlot[-x*y*E^(-x^2-y^2),{x,-1,1},{y,-1,1}]

2) Find and graph the tangent plane and normal line for 
f(x,y)==1-(1/10)((x^2)+4(y^2)) at the point (1,1, (1/2)).

3) Find the line tangent to the curve of intersection of
z==(Sqrt[(x^2)+(y^2)])and 2x+y+2z=20 at (3,4,5). Graph everything.

Abby Brown - www.abbymath.com - March 2007 (updated October 2015)