Partial Derivatives and Tangent Planes

Code

graphics[P_,showP_,showXCurve_,showXTan_,showYCurve_,showYTan_,showNormal_,showPlane_]:=(
graphP = Join[P,{f@@P}];
pointP = If[showP,{PointSize[0.03],Point[graphP]},{}];
xCurve = If[showXCurve,ParametricPlot3D[{t,P[[2]],f[t,P[[2]]]},{t,-3,3},PlotStyle->{Blue,Thickness[0.005]}],{}];
xTanVector = {1,0,Derivative[1,0][f]@@P};
xTanArrow=If[showXTan,{Blue,Thickness[0.008],Arrow[{graphP,graphP+xTanVector}]},{}];
yCurve = If[showYCurve,ParametricPlot3D[{P[[1]],t,f[P[[1]],t]},{t,-3,3},PlotStyle->{Red,Thickness[0.005]}],{}];
yTanVector = {0,1,Derivative[0,1][f]@@P};
yTanArrow=If[showYTan,{Red,Thickness[0.008],Arrow[{graphP,graphP+yTanVector}]},{}];
normalVector=Cross[xTanVector,yTanVector];
normalArrow=If[showNormal,{Green,Thickness[0.008],Arrow[{graphP,graphP+normalVector}]},{}];
tangentEquation[x_,y_,z_]:=normalVector.({x,y,z}-graphP);
tangentPlane=If[showPlane,ContourPlot3D[tangentEquation[x,y,z]==0,{x,P[[1]]-1.5,P[[1]]+1.5},{y,P[[2]]-1.5,P[[2]]+1.5},{z,-3,6},Mesh->5],{}];
Show[Graphics3D[{pointP,xTanArrow,yTanArrow,normalArrow}],xCurve,yCurve,tangentPlane,Plot3D[f[x,y],{x,-3,3},{y,-3,3},Mesh->20],Axes->Automatic,AxesLabel->{x,y,z},BoxRatios->{1,1,1},PlotRange->{{-3,3} ,{-3,3},{-3,6}},ViewPoint->{20,4,8}])

Graphics

f[x_,y_]:=5-x^2/4-y^2/2;
P = {0.5,1};
showP = True;
showXCurve = True;
showXTangentVector=True;
showYCurve=True;
showYTangentVector=True;
showNormalVector=True;
showTangentPlane=True;

graphics[P,showP,showXCurve,showXTangentVector,showYCurve,showYTangentVector,showNormalVector,showTangentPlane]

Animation

Note that changing f(x,y) and P above will automatically change the animation.
(All the other True/False parameters are ignored in the animation.)

Animate[Join[graphics[P],graphics@@Table[i<t,{i,1,7,1}]],{t,0,8}]