40
Lecture 12 MATH 2411 - Harrell Copyright 2013 by Evans M. Harrell II. The Strange Dr. Lagrange, or...

The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

  • Upload
    others

  • View
    7

  • Download
    0

Embed Size (px)

Citation preview

Page 1: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

Lecture 12

MATH 2411 - Harrell

Copyright 2013 by Evans M. Harrell II.

The Strange Dr. Lagrange, or...

Page 2: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

Lecture 12

MATH 2411 - Harrell

Copyright 2013 by Evans M. Harrell II.

How I learned to stop worrying and love the constraint

Page 3: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

Winners for the “funky saddle” contest!

ª Congrats to Rehman and a few others…

Page 4: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

A little-known tale from the 1001 Nights: Ali Baba and the shady gradient wallahs. ª One day Ali Baba went to the bazaar, because he very much

needed a function and its gradient. In the bazaar he met two gradient wallahs. The first of them came to him and spake thusly, “ Esteemed sire, There is a wondrous function I will sell you for ten pieces of silver, and its gradient is

∇f = (y cos(xy) – y2) i + (x sin(xy) – x2 + 1) j .”

Page 5: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

ª Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire, believe not yon notorious liar! Verily

∇f = (y cos(xy) – y2) i + (x sin(xy) – x2 + 1) j is bogus and counterfeit , and can in no wise be a gradient. But

I can sell you a wondrous function for only 9 pieces of silver, and its true gradient is

∇f = (y cos(xy) – y2) i + (x cos(xy) – 2 xy + 1) j .”

Ali Baba and the shady gradient wallahs.

Page 6: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

ª Whereupon the first merchant sprang at the second and a violent fight ensued, with entertaining clashes of scimitars and much blood and gore, whilst Ali Baba crouched against the wall, much with biting of the fingernails. Anon both merchants lay decapitated, and poor Ali Baba despaired of obtaining the function with the gradient. Then as usual his faithful and clever main squeeze Morgiana appeared and saved Ali Baba’s مؤخرة, saying, “Oh.Master, do not despair, for one gradient wallah spake the truth, and I shall reveal both gradient and function!”

Ali Baba and the shady gradient wallahs.

Page 7: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

Which brings us to today’s

Page 8: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

ª Using what you know about mixed partials, which of the following could be a true statement?

A ∇f = (y cos(xy) – y2) i + (x sin(xy) – x2 + 1) j B ∇f = (y cos(xy) – y2) i + (x cos(xy) – 2 xy + 1) j .”

Clicker Quiz

Page 9: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

∇f = (y cos(xy) – y2) i + (x sin(xy) – x2 + 1) j ∇f = (y cos(xy) – y2) i + (x cos(xy) – 2 xy + 1) j In general, ∇f = P(x,y) i + Q(x,y) j, where

P(x,y) = fx and Q(x,y) = fy .

Page 10: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

∇f = (y cos(xy) – y2) i + (x sin(xy) – x2 + 1) j ∇f = (y cos(xy) – y2) i + (x cos(xy) – 2 xy + 1) j ****Is Py = fyx the same as Qx = fxy?****

Page 11: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

∇f1 = (y cos(xy) – y2) i + (x sin(xy) – x2 + 1) j ∇f2 = (y cos(xy) – y2) i + (x cos(xy) – 2 xy + 1) j ****Is Py = fyx the same as Qx = fxy?****

∂P1/∂y = cos(xy) – xy sin(xy) – 2y

is not equal to

∂Q1/∂x = sin(xy) + xy cos(xy) – 2x.

Page 12: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

∇f1 = (y cos(xy) – y2) i + (x sin(xy) – x2 + 1) j ∇f2 = (y cos(xy) – y2) i + (x cos(xy) – 2 xy + 1) j ****Is Py = fyx the same as Qx = fxy?****

Whereas

∂P2/∂y = cos(xy) – xy sin(xy) – 2y = ∂Q2/∂x

as it should.

Page 13: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

Ah, but what is f?

ª We can integrate in x for fixed y or vice versa. The constant of integration if you”fix” y temporarily might vary when y is no longer held fixed. It is therefore a function of y – but not x.!

ª And conversely, switching x and y !

Page 14: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

∇f1 = (y cos(xy) – y2) i + (x sin(xy) – x2 + 1) j ∇f2 = (y cos(xy) – y2) i + (x cos(xy) – 2 xy + 1) j ****Is Py = fyx the same as Qx = fxy?****

Page 15: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

∇f = (y cos(xy) – y2) i + (x sin(xy) – x2 + 1) j ∇f = (y cos(xy) – y2) i + (x cos(xy) – 2 xy + 1) j ****Is Py = fyx the same as Qx = fxy?****

By comparing both calculations,

f(x,y) = sin(xy) – xy2 + y + C

This one is an absolute constant

Page 16: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

Constrained optimization

ª Let f(x,y) = x2 + y2 + x + y on the closed unit disk. Find its absolute max and min.

ª Is there an easier way?!

Page 17: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

Example

ª Let f(x,y) = x2 + y2 + x + y on the closed unit disk. Find its absolute max and min. Previous solution: ª Only 1 critical pt: 2x+1= 0 = 2y+1 ⇒ x=y=-1/2. !

ª On the boundary write x = cos t, y = sin t ª f becomes 1+cos t+sin t and we are back

in KG Calculus. ª Check 3 possibilities.

Page 18: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

Example

ª Plug the three candidates into f(x,y) = x2 + y2 + x + y : ª The f(-1/2, -1/2) = -1/2 = -0.5

ª f(2-1/2,2-1/2) = 1+ 21/2 = 2.414214…

ª f(-2-1/2,-2-1/2) = 1- 21/2 = -0.414214…

Max!

Minnie!

This candidate is a loser!

Page 19: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

Constraints, regions, and side conditions

ª These are all pretty much the same! ª We can think of it as a region when x,y,z

are position variables, even when the physical meaning is entirely different: ª  Temperature, pressure, volume ª  Cost of various items, sales

Page 20: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

Example

ª Let f(x,y,z) = x3 y4 z5 with the side conditions x,y,z ≥ 0, x+y+z ≤ 1.

ª Point to ponder: What does the feasible set look like? ª A tetrahedron, a 4-sided figure each face

of which is a triangle. ª Do you see this?

Page 21: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

Examples

ª How big can the product of two numbers be if you fix the sum?

ª How small?

ª How big/small can the sum be if you fix the product?

Page 22: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

Examples

ª How big can the product of two numbers be if you fix the sum? ª Objective function: f(x,y) = xy ª Constraint: x+y = 12 (say) ª Plug: f → x(12 - x) . Maximize this with

Calc I when 0 = 12 - 2 x•, so x•=6. Also y•=6.

Page 23: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

Interpretation

ª How big can the product of two numbers be if you fix the sum?

ª This is the same as maximizing the area xy of a rectangle of sides x and y, when you fix the perimeter 2(x+y). It’s at least plausible that the square is the best shape, so x=y.

Page 24: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

Examples

ª OK…. So how big can the product of three numbers be if you fix the sum? ª Objective function: f(x,y,z) = xyz ª Constraint: x+y+z = 12 (say)

Page 25: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

Examples

ª Or…. So how big can the product of four numbers be if you fix the sum?

Page 26: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

A great optimist, er optimizer, - Joseph-Louis Lagrange

Page 27: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,
Page 28: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

The Lagrange condition

ª A constrained max or min subject to g(x,y,z) = 0 satisfies… ª Think: f(r(t)) will be maximized as long as

the curve r(t) stays on the curve or surface C = {r : g(r) = 0}.

ª What do we know about the scalar function h(t) = f(r(t)) at max or min?

Page 29: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

The Lagrange condition

ª Ans: 0 = ∇f(r(t)) • rʹ′(t), and the velocity rʹ′(t) can have any direction parallel to C.

ª So ∇f(r(t)) has to be perpendicular to the surface or curve C = {r : g(r) = 0}.

ª Don’t we know another gradient that is perpendicular to this level set of the function g?

Page 30: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

The Lagrange condition

ª Ans: 0 = ∇f(r(t)) • rʹ′(t), and the velocity rʹ′(t) can have any direction parallel to C.

ª So ∇f(r(t)) has to be perpendicular to the surface or curve C = {r : g(r) = 0}.

ª Don’t we know another gradient that is perpendicular to this level set of the function g? ª  Sure. ∇g is also perpendicular to the level sets of

g. So ∇f and ∇g must be parallel.

Page 31: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

The Lagrange condition

ª Assuming f and C (or the g that defines it) are “smooth,” at a boundary maximum point x0 where

∇g(x0) ≠ 0, ∇f(x0) = λ ∇g(x0) for some scalar value λ.

Page 32: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

An example

ª Let f(x,y) = x2 + y2 + x + y on the closed unit disk. Find its absolute max and min.

Let’s look at!level curves:!

Page 33: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

Examples

ª Closest point to the origin of the plane x + 2 y - 3 z = 6.

ª Extrema of 2 x + y, assuming x2 + 2 y2 = 18 .

Page 34: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

Examples

ª Closest point to the origin of the plane x + 2 y - 3 z = 6. ª f(r) could be x2 + y2 + z2, rather than the

distance. This avoids differentiating square roots, and it is just as good for answering the question.

ª g(r) := x + 2 y - 3 z - 6

Page 35: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

Examples

ª How big can the product be on the unit circle?

ª On the square 0 ≤ x,y ≤ 1?

Page 36: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

A closer look at surfaces and constraints as implicit functions

Page 37: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

Implicit functions

ª Suppose that you aren’t given a function z = g(x) explicitly, but you know

something about it. We can imagine we know that

F(x, g(x)) = 0. Is that kind of information sufficient to

determine g(x)?

Page 38: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

Implicit functions

ª For example, suppose that ª x2 + y2 – 2 x z + z3 + y z-5 = 2

ª Observation #1, there is a solution at a point, (1,1,1)

Page 39: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

Implicit functions

ª For example, suppose that x2 + y2 – 2 x z + z3 + y z-5 = 2

ª Could we “Taylorize?”

Page 40: The Strange Dr. Lagrange, orpeople.math.gatech.edu/~harrell/2411S13/Lex/L12.2411.pdf · Then came a second gradient wallah and tugged on Ali Baba’s sleeve, proclaiming, “Sire,

The theorem, stated informally

ª If F(x, z) is smooth enough, and you can work out z in terms of x to first order in Taylor, you can continue to work out corrections. There is a locally defined solution function z = g(x).