In-class work for April 9

Math 104 Calculus II, April 9, 2019
T. Ratliff, Wheaton College
ratliff_thomas@wheatoncollege.edu

f(x,y) = (e^(-(x^2)-(y^2)))-3(e^(-(((x-1))^2)-(((y-1))^2)))

Since all commands in Mathematica begin with capital letters, we have to use ‘E’ rather than ‘e’

f=E^(-x^2-y^2) - 3*E^(- (x-1)^2 - (y-1)^2)

Let’s form the gradient of f

{ D[f,x], D[f,y]}

What we really want to do is substitute (1, 0.5) into the gradient and store those values.
This syntax is one way to do that in Mathematica.

grad = ( {D[f,x], D[f,y]} /. {x->1 , y-> 0.5})

Now we can use this value to form the directional derivatives

grad.{1,0}

grad.{0,1}

grad.{-1/Sqrt[5], 2/Sqrt[5]}

Let’s look at the contour plot to see if our answers make sense

ContourPlot[f, {x,-0.5, 1.5}, {y,-0.5, 1.5}, Contours->50, ColorFunction->"Rainbow"]

Just for chuckles, let’s also create plot that shows our point (1, 0.5) on the graph

p1=ContourPlot[f, {x,-0.5, 1.5}, {y,-0.5, 1.5}, Contours->50, ColorFunction->"Rainbow"];
p2=Graphics[Disk[{1,0.5},0.02]];
Show[p1,p2]