44
Unit #20 : Directional Derivatives and the Gradient Goals: To learn about dot and scalar products of vectors. To introduce the directional derivative and the gradient vector. To learn how to compute the gradient vector and how it relates to the directional derivative. To explore how the gradient vector relates to contours.

Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

  • Upload
    others

  • View
    9

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Unit #20 : Directional Derivatives and the Gradient

Goals:

• To learn about dot and scalar products of vectors.

• To introduce the directional derivative and the gradient vector.

• To learn how to compute the gradient vector and how it relates to the directionalderivative.

• To explore how the gradient vector relates to contours.

Page 2: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Vector Multiplication - 1

Vector Multiplication

Unlike for addition and subtraction, vector quantities differ from scalars in thatvector multiplication can be defined in several ways. There are twosuch operations that we will need to use:

• scalar multiplication

• dot product

Scalar multiplication: λ~v

• combines a scalar, e.g. λ, with a vector, e.g. ~v to produce a new vector,λ~v.

• the magnitude of the new vector is |λ| times the original vector length e.g. 2~v = ~v + ~v twice as long as the original.

• If λ > 0, λ~v is a vector in the same direction as ~v

• If λ < 0, λ~v is a vector in the opposite direction as ~v

Page 3: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Vector Multiplication - 2

Example: Choose a vector ~v and then draw

• 2~v,

• 0 ~v, and

• (−1.5)~v.

Page 4: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Vector Multiplication - 3

Example: For the vector ~v = 〈5,−2〉, express the following in componentform:

• 2~v,

• 0 ~v, and

• (−1.5)~v.

Page 5: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Vector Multiplication - 4

Linearity of Vector OperationsAddition, subtraction, and scalar multiplication all obey consistent rules of oper-ation familiar from your experience with scalar operations. These properties aresummarized on page 617 of Hughes-Hallett. For convenience we repeat them here.

Commutativity Associativity

~v + ~w = ~w + ~v ~u + (~v + ~w) = (~u + ~v) + ~w

Distributivity Identity

(λ + µ)~v = λ~v + µ~v 1~v = ~v, 0~v = ~0

λ(~v + ~w) = λ~v + λ~w ~v +~0 = ~v

Note that for any vector ~v, (−1)~v is a vector with the same magnitude/length as~v and opposite direction.Because of this property we write (−1)~v = −~v.

Page 6: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Dot Product - Angle Definition - 1

Dot Product of Vectors: ~v · ~w

Remember that the scalar product multiplies a scalar times a vector.Another possible multiplication between two vectors is called the dot product.The dot product

• combines two vectors, e.g. ~v, ~w to produce a scalar, ~v · ~w• If θ ∈ [0, π] is the angle between two vectors ~v and ~w, then

~v · ~w = ||~v|| ||~w|| cos(θ)

Question: Use this definition to find ~i ·~i.(a) -1

(b) 0

(c) 1

(d) 2

Page 7: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Dot Product - Angle Definition - 2

~v · ~w = ||~v|| ||~w|| cos(θ)

Question: Use this definition to find ~i ·~j.(a) -1

(b) 0

(c) 1

(d) 2

Page 8: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Dot Product - Angle Definition - 3

~v · ~w = ||~v|| ||~w|| cos(θ)

Suppose that ~v and ~w are perpendicular to one another. What can you sayabout ~v · ~w?

What can you conclude if ~v · ~w = 0?

Page 9: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Dot Product - Component Definition - 1

The previous definition of dot product involved the angle between the two vectors.It is also helpful to compute the dot product purely in terms of the componentsof the vectors.

Component Definition of Dot Product

If ~v = λ1~i + λ2~j + λ3~k

(or = 〈λ1, λ2, λ3〉)and ~w = µ1~i + µ2~j + µ3~k,

(or = 〈µ1, µ2, µ3〉)

then

~v · ~w = λ1 µ1 + λ2 µ2 + λ3 µ3.

It is not at all obvious that this is the same as the other definition!

Page 10: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Dot Product - Component Definition - 2

The fact that the two definitions always give the same result is proven in yourtextbook. We will study an example demonstrating this general property to see aspecific instance of this general rule.Example: Use both definitions of the dot product to calculate

〈1, 1〉 · 〈0, 3〉

in two different ways.

Page 11: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Dot Product - Component Definition - 3

Example: Find a vector ~u = 〈a, b〉 of magnitude/length 1 which is perpen-dicular to the vector 3~i + 7~j.

Page 12: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Dot Product - Component Definition - 4

~u = 〈a, b〉 of magnitude/length 1, perpendicular to 3~i + 7~j.

Page 13: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Dot Product - Component Definition - 5

Are there other possibilities than the perpendicular vector you found?

Page 14: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Using the Dot Product - 1

Product Confusion Is (~v1 · ~v2)~v3 = ~v1(~v2 · ~v3)?

(a) Yes, the results are equal.

(b) No, the results will be different because of the grouping.

(c) No,the results will be different because the product types are different.

Page 15: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Using the Dot Product - 2

Example: Which pairs (if any) of vectors from the following list

(a) Are perpendicular?

(b) Have an angle less than π/2 between them?

(c) Have an angle of more than π/2 between them?

~a = 〈1, 0,−2〉 ~b = 〈1, 3, 0〉 ~c = 〈2, 1, 1〉

Page 16: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Directional Derivative - Concept - 1

Directional Derivative - Concept

Now we can return to the study of rates of change of a function f (x, y) whosedomain is all or part of IR2 (in other words, functions of two real variables,x and y).In our new terms,

• The partial derivative fx is the rate of change of f in the direction of the unitvector ~i (towards larger x values)

• The partial derivative fy is the rate of change of f in the direction of the unit

vector ~j (towards larger y values)

Page 17: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Directional Derivative - Concept - 2

On the surface below, find a point that has fx < 0 and fy > 0.

Page 18: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Directional Derivative - Concept - 3

Suppose we now want to find the rate of change in an arbitrary direction.

• Any direction can be specified by a vector ~u of length 1.

• Vectors of length 1 are called unit vectors.

• Given a unit vector ~u, we want to find the rate of change of f (x, y) if we moveaway from (x, y) in the direction of ~u.

From the same point on the graph, indicate a direction where the slope wouldbe steeper than fy.

Indicate another direction where the slope would be close to zero.

Page 19: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Directional Derivative - Contour Diagrams - 1

Example: Consider the contour diagram for a linear function f (x, y) shownbelow.

−6

−4

−2

−2

0

0

0

2

2

2

4

4

4

6

6

6

8

8

8

10

10

10

P

On the diagram, mark three directions ~u, ~v and ~w at the point P , chosen sothat

• D~uf (a, b) > 0

• D~vf (a, b) < 0

• D~wf (a, b) = 0

Page 20: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Directional Derivative - Contour Diagrams - 2

Example - The following is a contour diagram for a more complex functionf (x, y). A = (a, b) is a point in the domain of f .

On the diagram, mark three directions ~u, ~v and ~w at the point P , chosen sothat

• D~uf (a, b) > 0

• D~vf (a, b) < 0

• D~wf (a, b) = 0

Page 21: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Directional Derivative - Definition - 1

We now define the slope of f (x, y) in an arbitrary direction, with the directionspecified by a unit vector ~u.

Directional Derivative

Let ~u = (u1~i + u2~j) = 〈u1, u2〉with u21 + u22 = 1, so that ||~u|| = 1.

Then, at the point (a, b) in the domain of f , the rate of change of f in thedirection of ~u is

limh→0

f (a + hu1, b + hu2)− f (a, b)

h.

This is called the directional derivative of f at the point (a, b) in thedirection of ~u and it is denoted by

D~uf (a, b) or f~u(a, b)

Note: This formula only applies if ~u is a unit vector.

Unfortunately, this derivative definition is cumbersome as it involves limits. Wewould prefer to compute these directional derivatives using our simpler derivativerules if we could.

Page 22: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Directional Derivative - Definition - 2

Computing D~uf(a, b)How can we go about computing values for D~uf (a, b) in a systematic way?Keep in mind the ingredients of our calculation:

• f (x, y) is a function of two variables,

• (a, b) is a point in the domain of f ,

• ~u = 〈u1, u2〉 with√u21 + u22 = 1 is a unit vector.

Then

D~uf (a, b) = limh→0

f (a + hu1, b + hu2)− f (a, b)

h

= limh→0

f (x, y)− f (a, b)

h(where x = a + hu1 and y = b + hu2)

Use local linearity to find an alternate expression for f (x, y)− f (a, b).

Page 23: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Directional Derivative - Definition - 3

Use that alternate expression to express the directional derivative in terms ofpartial derivatives.

Page 24: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Directional Derivative - Calculation - 1

Computing the Directional DerivativeIf ~u = 〈u1, u2〉 is a unit vector (||~u|| = 1), then

D~uf (a, b) = fx(a, b)u1 + fy(a, b)u2

NOTE: we don’t define directional derivatives for non-unit vectors. To find theslope in the direction of a non-unit length vector, ~v, you must normalize itbefore computing the directional derivative.

If ~v = 〈v1, v2〉 is not a unit vector,

first find ~u =1

||~v||~v =

1√v21 + v22

~v,

then compute D~uf (a, b)

This formula allows us to compute the slope in any direction simply by knowingthe partial derivatives.

Page 25: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Directional Derivative - Calculation - 2

Example: Let f (x, y) = x2−xy2 and let ~u =⟨35,−

45

⟩. We are going to show

the steps required to calculate D~uf (2, 2).

Question: First: is ~u a unit vector?

(a) Yes.

(b) No.

Page 26: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Directional Derivative - Calculation - 3

f (x, y) = x2 − xy2 and ~u =⟨35,−

45

⟩.

fx(x, y) =

fy(x, y) =

fx(2, 2) =

fy(2, 2) =

u1 =

u2 =

Duf (2, 2) =

Page 27: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Directional Derivative - Calculation - 4

Now compute the slope in the direction opposite of ~u. What do you noticeabout the slope?

Page 28: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Directional Derivative - Example - 1

Example: Find the slope of the surface f (x, y) = x2 − y2 at (x, y) = (2, 3)if we were to move directly towards the origin.

Page 29: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Directional Derivative - Example - 2

Slope of f (x, y) = x2 − y2, at (2, 3), moving directly towards the origin.

Page 30: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

The Gradient Vector - 1

The Gradient Vector

Note that the formula for directional derivatives could be written as a dot prod-uct if we so desired:

D~uf (a, b) = fx(a, b)u1 + fy(a, b)u2

= 〈fx(a, b), fy(a, b)〉︸ ︷︷ ︸new vector

· 〈u1 u2〉︸ ︷︷ ︸~u

This is the first appearance of an important vector function called the gradientof f . While f assigns a number to each point in its domain, the gradient of fassigns a vector to each point in the domain of f , provided both partial derivativesof f exist at that point. The gradient is denoted by either grad f or ~5f .

Page 31: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

The Gradient Vector - 2

Gradient Vector Definition

gradf = ~5f = fx(x, y)~i + fy(x, y)~j

= 〈fx(x, y), fy(x, y)〉

Alternate Directional Derivative Definition

D~uf (x, y) = (gradf ) · ~u

Page 32: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

The Gradient Vector - 3

Example -

Let f (x, y) = xey

grad f (x, y) =

grad f (1, 0) =

grad f (0, 1) =

grad f (2,−3) =

For each point in the domain of f where the partial derivatives are both defined,the gradient vector is also defined.

Page 33: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Gradient Vector - Importance - 1

Example: Use the gradient-based definition of the directional derivative todetermine the direction in which a surface has the largest positive slope.

Page 34: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Gradient Vector - Importance - 2

Relationship between the surface and the gradient at a point (a, b)

The direction of grad f (a, b) is the direction of maximum increase of thefunction f at the point (a, b).

orThe gradient at (a, b) points in the direction of the steepest uphill slope.

Page 35: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Gradient Vector - Importance - 3

Example: Consider the plane z = x + 2y + 3. At the point (x, y) = (1, 1),in which (x, y) direction should we move to move uphill the most quickly?

Page 36: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Gradient Vector - Importance - 4

Support your answer, using the contour diagram for z = x + 2y + 3 shownbelow.

−20

0

2

2

2

4

4

4

4

6

6

6

6

8

8

8

8

10

10

10

12

12

14

Page 37: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Gradient Vector - Properties - 1

Properties of the Gradient VectorUse the properties of the directional derivative and the dot product to justifythe following conclusions :

• grad f (a, b) is perpendicular to the contour of f that passes through the point(a, b)

• –grad f (a, b) gives the direction of maximum decrease of the function f atthe point (a, b).

Page 38: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Gradient Vector - Properties - 2

• ‖ grad f (a, b) ‖ (i.e. the length or magnitude of the gradient vector) isthe maximum rate of change of f at (a, b).

Page 39: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Gradient Vector - Properties - 3

Reminding ourselves of these properties of the gradient vector, consider the contourdiagram for a function f (x, y)

For each of the points. A, B, and C, draw a vector that points in the directionof the gradient vector at that point .

At which of the points is the gradient vector longest? At which of the pointsis the gradient vector shortest? Justify your answers.

Page 40: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Gradient and Contours - Example - 1

Putting Gradients and Contours TogetherWe said earlier that the gradient is perpendicular to the contour at the same point.However, that isn’t very precise, given that the contours are curves themselves.It is better to say that contours, as curves, have tangent lines, and gradient isperpendicular to those tangent lines.

Consider the 2-variable function f (x, y) = xy2.Write an equation for the contour (level curve), C, of f that passes throughthe point (2, 1).

Page 41: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Gradient and Contours - Example - 2

Find grad f (2, 1).

Find an equation for the tangent line at (2, 1) to the contour (level curve) C,through (2, 1).

Page 42: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Gradient and Contours - Example - 3

f (x, y) = xy2

On the axes below,

• sketch the level curve C

• indicate the vector grad f (2, 1), and

• draw the tangent line to the contour at (2, 1).

0

1

2

3

4

5

0 1 2 3 4 5

x

y

Page 43: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Gradient and Contours - Example - 4

For reference, here is a more detailed contour diagram of the function f (x, y) = xy2,used in the previous question.

2

2

2

2

2

4

4

4

4

4

6

6

6

6

8

8

8

8

10

10

10

10

12

12

12

12

14

14

14

14

16

16

16

16

18

18

18

18

20

20

20

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 50

0.5

1

1.5

2

2.5

3

3.5

4

4.5

5

Page 44: Unit #20 : Directional Derivatives and the Gradientmath121/Notes/Annotated_Online/notes20… · Directional Derivative - Concept - 1 Directional Derivative - Concept Now we can return

Gradient and Contours - Example - 5

Note The idea of directional derivative and gradient are new, and are easily con-fused at first. The following reminders can be useful to help you check that youare on the right track.

• D~uf (a, b) is a derivative or slope, so is a scalar number. It is a rate of changeassociated with a specific direction, chosen regardless of the surface.

• grad f (a, b) is a vector. Its direction is the direction of maximum increase off at (a, b). Its length is a number which represent the rate of change in thegradient’s direction.