This is Day 2 in Unit 2.

Prep

We're in Unit 2 - Derivatives. Your homework assignment each day is to spend 1-2 hours working on the next 4 tasks from the current unit's prep.

Brain Gains (Rapid Recall, Jivin' Generation)

  • Let $z = f(x,y) = |x|-2$. Construct a contour plot (using the outputs $0,-1,4$), and then construct a surface plot.

Solution

Here's an option with Mathematica.

f[x_, y_] := Abs[x]-2
ContourPlot[f[x, y], {x, -2, 2}, {y, -2, 2}]
Plot3D[f[x, y], {x, -2, 2}, {y, -2, 2}]
Plot3D[f[x, y], {x, -2, 2}, {y, -2, 2}, MeshFunctions -> {#3 &}]
  • Let $z = f(x,y) = x^2-y$.
    • Construct a contour plot that includes the level curves corresponding to $z = -1$, $z = 0$, and $z=4$.
    • Construct a surface plot.
    • Compute the gradient.
    • In your contour plot, add the gradient $\vec \nabla f(P)$ at the points $P = (0,1)$, $P = (-2,0)$, $P = (2,4)$, $P = (6,1)$, and $P = (-6,-4)$.

Solution

Here's a solution with Mathematica.

f[x_, y_] := x^2 - y
p1 = ContourPlot[f[x, y], {x, -2, 2}, {y, -2, 2}]
Plot3D[f[x, y], {x, -2, 2}, {y, -2, 2}]
Plot3D[f[x, y], {x, -2, 2}, {y, -2, 2}, MeshFunctions -> {#3 &}]
gradf = D[f[x, y], {{x, y}}]
p2 = VectorPlot[gradf, {x, -2, 2}, {y, -2, 2}]
Show[p1, p2]
  • Let $f(x,y) = e^{2x}\cos(3y)+3x-7y^2$. Compute $f_x$ and $\frac{\partial f}{\partial y}$.

Solution

There are many ways to do this.

First, we could use implicit differentiation. This gives $$\frac{df}{dt} = 2e^{2x}\frac{dx}{dt}\cos(3y)-3e^{2x}\sin(3y)\frac{dy}{dt}+3\frac{dx}{dt}-14y\frac{dy}{dt}.$$ Multiplying by $dt$ gives the (total) differential $$df = 2e^{2x}dx\cos(3y)-3e^{2x}\sin(3y)dy+3dx-14ydy.$$ Writing this in the form $df = ?dx+?dy$ gives $$df = (2e^{2x}\cos(3y)+3)dx+(-3e^{2x}\sin(3y)14y)dy.$$ From there, we have $f_x = 2e^{2x}\cos(3y)+3$ and $\frac{\partial f}{\partial y} = -3e^{2x}\sin(3y)14y$.

Another way to tackle this is to treat variables as constants, and differentiate. To compute $f_x$, we let every variable except $x$ be a constant, and compute the derivative with respect to $x$. This gives $f_x = (2e^{2x})(\cos(3y))+3-0$ and $\frac{\partial f}{\partial y} = (e^{2x})(-3\sin(3y))+0-14y$.

With Mathematica, we have the following.

f[x_, y_] := Exp[2 x] Cos[3 y] + 3 x - 7 y^2
D[f[x, y], x]
D[f[x, y], y]
D[f[x, y], {{x, y}}]

Group Problems

  1. Consider the function $z = f(x,y)=4-y^2$.
    • Compute $\vec \nabla f$.
    • Construct a 2D contour plot by hand. So pick several values for $z$ and plot the resulting curves. If you end up with lots of horizontal lines in the $xy$-plane, you're doing this correctly. Write the height on each horizontal line you draw.
    • Construct a 3D surface plot by hand.
    • Remember that the gradient is a vector field. At a few points in your contour plot, add the gradient vector.
    • Check your work with Mathematica, modifying the code below to fit your needs.
      f[x_, y_] := x^2 - y
      p1 = ContourPlot[f[x, y], {x, -2, 2}, {y, -2, 2}]
      Plot3D[f[x, y], {x, -2, 2}, {y, -2, 2}]
      Plot3D[f[x, y], {x, -2, 2}, {y, -2, 2}, MeshFunctions -> {#3 &}]
      gradf = D[f[x, y], {{x, y}}]
      p2 = VectorPlot[gradf, {x, -2, 2}, {y, -2, 2}]
      Show[p1, p2]
      
  2. Repeat the previous exercise using $f(x,y) = x-y^2$.
  3. Pick your own function $f(x,y)$, and use Mathematica to compare the level curve plot with the gradient field plot. Repeat with several functions, looking for relationships between the contour plot and gradient field plot.
    f[x_, y_] := Exp[2 x] Cos[3 y] + 3 x - 7 y^2
    p1 = ContourPlot[f[x, y], {x, -2, 2}, {y, -2, 2}]
    gradf = D[f[x, y], {{x, y}}]
    p2 = VectorPlot[gradf, {x, -2, 2}, {y, -2, 2}]
    Show[p1, p2]
    


Today

« October 2024 »

Sun

Mon

Tue

Wed

Thu

Fri

Sat

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31