Laboratory 5
Partial Derivatives and Directional Derivatives
Name:

Code

ySlice[f_,ys_,{x,x0_,x1_},{y,y0_,y1_}]:=Module[{g,p1,p2,p3,p4,dz,z0,z1},
g[x_,y_]=f[x,y];
z1=Maximize[{g[x,y],x0≤x≤x1,y0≤y≤y1},{x,y}][[1]];
z0=Minimize[{g[x,y],x0≤x≤x1,y0≤y≤y1},{x,y}][[1]];
dz=10^Floor[Log10[z1-z0]]; z0=z0-0.5dz;z1=z1+0.5dz;
p1=Plot3D[g[x,y],{x,x0,x1},{y,y0,y1},PlotRange->{z0,z1},
AxesLabel->{"x","y","z"},ClippingStyle->None];
p2=ParametricPlot3D[{x,ys,z},{x,x0,x1},{z,z0,z1},
PlotStyle->Opacity[.75],Mesh->None];
p3=Show[p1,p2,PlotRange->{{x0,x1},{y0,y1},{z0,z1}}];
p4=Plot[g[x,ys],{x,x0,x1},PlotRange->{z0,z1},
Axes->False,FrameLabel->{"x","z"},Frame->True,PlotStyle->Blue];
Rasterize[Show[GraphicsRow[{p3,p4}],ImageSize->600]]]

xSlice[f_,xs_,{x,x0_,x1_},{y,y0_,y1_}]:=Module[{g,p1,p2,p3,p4,dz,z0,z1},
g[x_,y_]=f[x,y];
z1=Maximize[{g[x,y],x0≤x≤x1,y0≤y≤y1},{x,y}][[1]];
z0=Minimize[{g[x,y],x0≤x≤x1,y0≤y≤y1},{x,y}][[1]];
dz=10^Floor[Log10[z1-z0]]; z0=z0-0.5dz;z1=z1+0.5dz;
p1=Plot3D[g[x,y],{x,x0,x1},{y,y0,y1},PlotRange->{z0,z1},
AxesLabel->{"x","y","z"},ClippingStyle->None];
p2=ParametricPlot3D[{xs,y,z},{y,y0,y1},{z,z0,z1},
PlotStyle->Opacity[.75],Mesh->None];
p3=Show[p1,p2,PlotRange->{{x0,x1},{y0,y1},{z0,z1}}];
p4=Plot[g[xs,y],{y,y0,y1},PlotRange->{z0,z1},
Axes->False,FrameLabel->{"y","z"},Frame->True,PlotStyle->Blue];
Rasterize[Show[GraphicsRow[{p3,p4}],ImageSize->600]]]

slice[f_,{xa_,ya_},{xb_,yb_},{x,x0_,x1_},{y,y0_,y1_}]:=
Module[{g,p1,p2,p3,p4,dz,z0,z1},
g[x_,y_]=f[x,y];
z1=Maximize[{g[x,y],x0≤x≤x1,y0≤y≤y1},{x,y}][[1]];
z0=Minimize[{g[x,y],x0≤x≤x1,y0≤y≤y1},{x,y}][[1]];
dz=10^Floor[Log10[z1-z0]]; z0=z0-0.5dz;z1=z1+0.5dz;
p1=Plot3D[g[x,y],{x,x0,x1},{y,y0,y1},PlotRange->{z0,z1},
AxesLabel->{"x","y","z"},ClippingStyle->None];
p2=ParametricPlot3D[{xa+t (xb-xa),ya+t (yb-ya),z},{t,0,1},{z,z0,z1},
PlotStyle->Opacity[.75],Mesh->None];
p3=Show[p1,p2,PlotRange->{{x0,x1},{y0,y1},{z0,z1}}];
p4=Plot[g[xa+t (xb-xa),ya+t (yb-ya)],{t,0,1},PlotRange->{z0,z1},
Axes->False,FrameLabel->{"t","z"},Frame->True,PlotStyle->Blue];
Show[GraphicsRow[{p3,p4}],ImageSize->600]]

Exercises

Exercise 1

For each of the functions below, use either xSlice or ySlice to graph the appropriate intersection curve. Then estimate the partial derivative in question graphically by zooming in about a suitable point.

(a) f(x,y)=(Sqrt[25-(x^2)-(y^2)]), ((∂f)/(∂y))(2,-1)		(b) f(x,y)=sin(((x^2)+(y^2))/6), (Subscript[f, y])(3,3)

Exercise 2

Find the equation of the tangent plane to each function at the indicated point, and give a graph showing both the function and the tangent plane. Choose the ranges of the variables so that the graph of the function and the tangent plane are nearly identical.

(a) f(x,y)=sin(Sqrt[(x^2)+2(y^2)]) at (-1,1) 		(b) f(x,y)=sin(((x^2)+(y^2))/6)at(3,3)

Exercise 3

Find the directional derivative of f(x,y) at the indicated point in the direction toward the second indicated point. Calculate the derivative in two ways: as (d/(d t))f(x(t),y(t)) and as ∇f·n. Use the module Slice to obtain plots of the graph of g(t)=f(x(t),y(t)) as the graph of a single-variable function of t and as the intersection curve of the graph of f(x,y) and a vertical plane.
	
	1. f(x,y)=(e^(-x))cos y at (-1,-2) towards (0,-1).
	
	2. f(x,y)=arctan xy at (-1,-2) towards (1,1).
	
	3. f(x,y)=(x^2)sin2y at (1,π/2) towards (3,-4).