Lagrange Multipliers
The idea
Many engineering questions ask for the best value of something while something else is held fixed: the least material for a set volume, the most power for a set budget, the closest point on a surface. Lagrange multipliers turn that constrained problem into a set of ordinary equations you can solve by hand.
Picture the level curves of the function you want to optimize and the curve you must stay on. Walk along the constraint curve and watch the value of . Where reaches a maximum or minimum, the constraint curve can't cross a level curve of (crossing would mean is still rising on one side), so the two curves just touch. Touching curves share a tangent line, so their gradients point along the same line:
The number (lambda) is the Lagrange multiplier. It says how many times longer one gradient is than the other, and, as shown below, it also measures how fast the best value changes when the constraint is loosened.
The method
- Write the constraint as and the function to optimize as .
- Set up as one equation per variable: and (add in three variables).
- Solve these together with the constraint . That is equations for the variables and .
- Evaluate at every point you found. On a closed, bounded constraint (an ellipse, a sphere) the largest value is the maximum and the smallest is the minimum.
Some books write the same thing as one function, , and set all its partial derivatives to zero. The equations are identical; use whichever you find easier to remember.
Worked example: the largest product on an ellipse
Find the maximum and minimum of on the ellipse .
Gradients. and with , . So
Substitute the first into the second: . Either , which forces and misses the ellipse, or , so .
With , . The constraint gives , so and the points are and , where . With , , giving and , where .
Answer: the maximum is and the minimum is . A quick check: parametrize the ellipse as , , so , which runs from to .
Worked example: the nearest point on a plane
Find the point on the plane closest to the origin.
Minimizing the distance is the same as minimizing its square, which avoids a square root: , with .
Put these into the plane: , so and the point is . Its distance from the origin is .
This agrees with the point-to-plane distance formula, . Notice that is a multiple of the plane's normal vector, exactly as says it must be.
Worked example: the cheapest open-top box
An open-top box (an enclosure tray, say) must hold . Find the base by and height that use the least sheet material.
The area is (base plus four sides) and the constraint is . Setting :
Multiply the first by and the second by : both right sides become , so , which gives . Doing the same with the second and third equations gives . So the base is square and the height is half the side.
Then , so , cm and cm. The material used is . A brute-force search over base sizes from 5 to 15 cm (with the height set by the volume) finds the same minimum of at .
| Base (cm) | Height (cm) | Area (cm²) |
|---|---|---|
| 8 × 8 | 7.81 | 314.0 |
| 10 × 10 | 5.00 | 300.0 |
| 12 × 12 | 3.47 | 310.7 |
| 10 × 12.5 | 4.00 | 305.0 |
What λ tells you
The multiplier is not just a helper variable. At the optimum, equals the rate at which the best value of changes as the constraint level changes:
In the ellipse example the constraint was with . Repeating the working for any gives and , so the best product is . Its derivative is , the value of found at the maximum. In economics this is the shadow price; in engineering it tells you how much a design improves per unit of extra budget, area or power.
Checking that it is a maximum or minimum
Lagrange's equations find every point where the two curves touch, but touching is not the same as being the best. On a closed, bounded constraint, comparing at all the candidate points is enough, as in the first example. On an open constraint, like the box (whose sides can grow without limit), argue from the shape of the problem: the area grows without bound as any side shrinks to zero or grows very large, so the single candidate must be the minimum. For a formal test, use the bordered Hessian, covered in most multivariable calculus texts.
Common mistakes
- Dropping the constraint equation. alone has too few equations; you always need as well.
- Dividing by a variable that could be zero. In the first example, dividing by assumes . Check the case separately.
- Forgetting the negative value of λ. Square roots give ; each sign can be a different extremum.
- Minimizing distance instead of distance squared. Both have the same minimizer, but the square has far easier derivatives.
- Assuming every solution is a maximum. Evaluate at each point, or check the problem's shape, before naming it.
Sources
- OpenStax Calculus Volume 3, section 4.8: Lagrange Multipliers
- MIT OpenCourseWare 18.02SC Multivariable Calculus, part on Lagrange multipliers
- Every number on this page is checked by a script that solves each example directly and by brute-force search.