MTH 212: Gradients and Tangents to Level Curves. Tangent Planes and Normal Lines. 

Example I : 3D graph and level curves of f(x,y)=x^3*y^2 and the gradient vector at the point (1,2).

f[x_,y_]:=x^3*y^2; (* function of two variables *)
ContourPlot3D[z==f[x,y],{x,-15,15},{y,-15,15},{z,-15,15}, Mesh -> None, AxesLabel->{x,y,z}] (* graph of f *)
Show[ContourPlot[f[x,y],{x,-15,15},{y,-15,15},PlotLegends->Automatic,Contours->{-100,-40,-20,-4,0,4,20,40,100}],Graphics[Point[{1,2}]],Graphics[Arrow[{{1,2},{13,6}}]]
]  (* level curves and the gradient at (1,2) *)

Example II :  Level curve f(x,y)=x^3y^2=4, tangent line and the gradient vector at the point (1,2).

Show[ContourPlot[f[x,y] == 4,{x,-15,15},{y,-15,15}],
ContourPlot[3x+y-5==0, {x,-15,15},{y,-15,15}, ContourStyle-> Red],
Graphics[{PointSize[.025],Point[{1,2}]}],Graphics[Arrow[{{1,2},{13,6}}]]
]

Example III : Level surface g(x,y,z) = x^2+y^2-z = 9 of the function of 3 variables g(x,y,z) =x^2+y^2-z  and the gradient vector at the point (1,2,-4).

Clear[x,y,z];
g[x_,y_,z_] := x^2+y^2-z;
pt={x-> 1,y->2,z-> -4};
pt1={x,y,z}/.pt;
pt2=pt1+Grad[g[x,y,z],{x,y,z}]/.pt;
Show[
ContourPlot3D[g[x,y,z]==9,{x,-7,7},{y,-7,7},{z,-10,10}, Mesh -> None, ContourStyle->Opacity[0.5],AxesLabel-> {x,y,z}],
Graphics3D[{Arrowheads[Large],Arrow[{pt1,pt2}]}],
Graphics3D[{PointSize[.02],Point[pt1]}]
]

Example IV : Level surface g(x,y,z) = x^2+y^2-z = 9, tangent plane and normal line at the point (1,2,4).

Show[ContourPlot3D[{x^2+y^2-z==9,2 x+4 y-z==14},{x,-7,7},{y,-7,7},{z,-10,10},Mesh->None,ContourStyle->Opacity[.6], AxesLabel->{x,y,z}],ParametricPlot3D[{1+2 t,2+4 t,-4-t},{t,-10,10}],
Graphics3D[{PointSize[.02],Point[pt1]}]
  ]

Example V (from class notes): Level surface f(x,y,z) = x^2/4+y^2+z^2/9 = 3 (ellipsoid), tangent plane and normal line at the point (-2,1,-3).

Show[ContourPlot3D[{x^2/4+y^2+z^2/9==3,-x+2y-2/3z==6},{x,-5,5},{y,-5,5},{z,-6,6},Mesh->None,ContourStyle->Opacity[.6], AxesLabel->{x,y,z}],
ParametricPlot3D[{-2- t,1+2 t,-3-2/3t},{t,-10,10}],
Graphics3D[{PointSize[.02],Point[{-2,1,-3}]}]
  ]

Example VI: Cylinder f(x,y,z) = x^2+y^2-2=0 and plane g(x,y,z) = x+z-4 =0 meet in an ellipse. Find parametric equations for the line tangent to the ellipse at the point (1,1,3).

Show[ContourPlot3D[{x^2+y^2-2==0,x+z-4==0},{x,-4,4},{y,-4,4},{z,0,7},Mesh->None,ContourStyle->Opacity[.6], AxesLabel->{x,y,z}]
(*graphs of the cylinder and plane*),
ParametricPlot3D[{Sqrt[2]Cos[t],Sqrt[2]Sin[t],4-Sqrt[2]Cos[t]},{t,0,2Pi},PlotStyle ->{Black,Dashed}],(*ellipse in the intersection*)
ParametricPlot3D[{1+2t,1-2 t,3-2t},{t,-10,10},PlotStyle ->Red],(*line tangent to the ellipse*)
Graphics3D[{PointSize[.02],Point[{1,1,3}]}],(*point*)
Graphics3D[{{Arrowheads[0.02],Arrow[{{1,1,3},{3,3,3}}]}, Text[Style["grad f",Bold],{3.1,3.1,3.1}]}], (*grad f*)
Graphics3D[{{Arrowheads[0.02],Arrow[{{1,1,3},{2,1,4}}]}, Text[Style["grad g",Bold],{2.1,1.1,4.1}]}]     (*grad g*)
]