The best value along a path
The bowl has its lowest point at the origin. Now ask for the smallest value of f only among the points on the line x + 2y = 5. The origin is not on that line, so the answer is somewhere else: the point of the line closest to the origin.
The line is a constraint, written g(x, y) = c with g = x + 2y and c = 5. On a contour map, the contours of f are circles, and the constraint is a line drawn across them. Walking along the line, you cross the circles, and f goes down and then up again.
The contours of a bowl, cut at heights 4, 8, 12 and 16, and a straight constraint g = k. At the marked point on the line, the gold points straight out from the center and the plain stands square to the line: they point different ways, and the small arrow shows the direction along the line in which f falls.
Crossing gradients mean f can still improve
At a point on the path, let t be a unit vector along the path. Moving along the path, f changes at the rate . If that is not 0, f falls one way along the path and rises the other, so the point is neither the smallest nor the largest value of f on the path.
So at a constrained maximum or minimum, : is at right angles to the path. The path is a level curve of g, and is always at right angles to the level curves of g. Two vectors at right angles to the same direction are parallel, so at the best point for some number , the Lagrange multiplier.
The same map with the point moved to where the smallest contour, the ring at height 4, just touches the line. There and lie along one ray, the longer: .
Three equations, three unknowns
Written in components, is two equations: and . With the constraint g(x, y) = c that makes three equations for x, y and . Solve the first two for x and y in terms of , then substitute into the constraint.
For on x + 2y = 5: and , so and , giving and . The constraint becomes , so and . The point is (1, 2), which is on the line, since 1 + 4 = 5, and .
Other points on the line give more: (5, 0) gives 25, and (3, 1) and (−1, 3) both give 10. Far along the line f grows without limit, so 5 is the minimum.
The line x + 2y = 5, the contour touching it at (1, 2), and the dashed contour crossing it at (3, 1) and (−1, 3). Each is drawn at a quarter of its length. At (1, 2), stands square to the line; at (3, 1), does not, and f still falls along the line toward (1, 2).
More than one candidate
The equations can give several points, and each must be checked. Find the largest and smallest values of f = xy on the circle . Here and , so and . Then . If x = 0 then y = 0 too, which is not on the circle, so and or .
With , y = x, and gives (2, 2) and (−2, −2), where f = 4. With , y = −x, giving (2, −2) and (−2, 2), where f = −4. All four lie on the circle, since 4 + 4 = 8. Comparing the values, the largest is 4 and the smallest is −4.
What measures
The multiplier is the rate at which the best value changes as the constant in the constraint changes. To maximize xy on x + y = 10, the equations and give x = y = 5, a maximum of 25, with . On x + y = 11 the maximum is 5.5 × 5.5 = 30.25, which is 5.25 more: close to for a change of 1.
In the bowl example, the smallest value of on x + 2y = c is . At c = 5 it is 5, and at c = 5.1 it is 5.202, a rise of about 2 for each unit of c, which is .
x + 2y = 1 cuts the ellipse twice: walk along the ellipse between the crossings and x + 2y rises above 1, so neither crossing is the maximum
Slide the line up until it only just touches the ellipse
The ellipse is the constraint, and the line x + 2y = k is a contour of f = x + 2y. At k = 1 the line cuts the ellipse at two points, where the plain and the gold point different ways, so a larger k can still be reached. Slide k up and the cuts close in, until at the line just touches at , where .
The usual mistakes
Solving without the constraint. The two component equations alone leave undetermined; the constraint fixes it.
Dividing by a variable that might be 0. In xy on , dividing by x is safe only after checking that x = 0 gives no point on the circle.
Stopping at the first candidate. The method gives every point where the gradients are parallel; the largest and smallest values come from comparing f at all of them.
Taking the gradients to be perpendicular at the best point. They are parallel; it is and the path that are at right angles.
A beam sawn from a log
In the application below, a beam with a rectangular cross-section is cut from a round log, so its width and depth are tied by the circle of the log. Setting the gradient of its strength equal to times the gradient of the constraint gives the strongest beam, which is deeper than it is wide.
Worked example: A Beam Sawn From a Round Log: the Width and Depth That Resist Bending Best, Compared With a Square Beam
Question A sawmill cuts a beam of rectangular cross-section, w centimeters wide and d centimeters deep, from a round log 60 centimeters across, with the corners of the rectangle on the circle, so that w2 + d2 = 3600. The beam's strength against bending under a load from above is S = kwd2, for a constant k. (a) Use a Lagrange multiplier to find the width and depth of the strongest beam. (b) Find how much stronger it is than the square beam cut from the same log, as a percentage of the square beam's strength.
1.(a) ∇ S = (kd2, 2kwd) and ∇ g = (2w, 2d), so ∇ S = λ∇ g says kd2 = 2λ w and 2kwd = 2λ d.
(a) The arc is the edge of the log, w2 + d2 = 3600, and the other curves join beams of equal strength. The strongest beam is where one of them just touches the arc, and there the two gradients are parallel. 2.The depth is not 0, so dividing the second equation by 2d gives λ = kw. The first then becomes kd2 = 2kw2, that is d2 = 2w2.
The equations kd2 = 2λ w and 2kwd = 2λ d give d2 = 2w2: the strongest beam lies on the line d = √2w. 3.Substituting into the constraint: w2 + 2w2 = 3600, so w2 = 1200 and w = √1200 ≈ 34.6 centimeters, and d2 = 2400, so d = √2400 ≈ 49.0 centimeters. At the ends of the arc, where w = 0 or d = 0, the strength is 0, so this point is the maximum.
The line meets the arc at w ≈ 34.6 and d ≈ 49.0 centimeters. 4.(b) The strongest beam has S = k × √1200 × 2400 ≈ 83138k. The square beam has w = d, so 2w2 = 3600, w = √1800 ≈ 42.43 centimeters, and S = k × √1800 × 1800 ≈ 76368k.
(b) The square beam, 42.4 centimeters each way, lies on a curve of lower strength. 5.The ratio is 8313876368 ≈ 1.089, so the strongest beam is about 8.9 percent stronger than the square one. Check: w2 + d2 = 1200 + 2400 = 3600, so the corners of the strongest beam lie on the log.
The strongest beam is about 8.9 percent stronger than the square one.
Answer: (a) about 34.6 centimeters wide and 49.0 centimeters deep, with w2 = 1200 and d2 = 2400; (b) about 8.9 percent stronger than the square beam
Common mistakes
- Maximizing wd2 with nothing linking w and d. Without the constraint the strength has no greatest value; the circle of the log is what ties the width to the depth.
- Taking the square beam to be the strongest because it has the largest cross-section of any rectangle in the circle. The strength grows with the square of the depth, so it pays to give up some width for depth.