# What do Lagrange multipliers give?

Finds where f is largest or smallest on a constraint g = c, by Lagrange multipliers.

- Page: https://www.acalculator.org/math/lagrange-multiplier-calculator
- JSON spec: https://www.acalculator.org/math/lagrange-multiplier-calculator.json
- Version: 367261e67fee

## Default answer

Example with the default inputs (Objective f x^2 + 4y^2 - 2x + 8y, Constraint x + 2y = 7): For x^2 + 4y^2 - 2x + 8y with x + 2y = 7: minimum 27 at (5, 1).

## Inputs

| Key | Label | Description |
| --- | --- | --- |
| f | Objective f | The function to maximize or minimize, in 2 or 3 letters. |
| g | Constraint | An equation such as x + 2y = 7. |

## Outputs

| Key | Label | Description |
| --- | --- | --- |
| extrema | Extrema | The largest local maximum and the smallest local minimum found. |
| points | All candidate points | Every point where ∇f = λ∇g on the constraint, with f and its type. |

## Method

Newton’s method on ∇f = λ∇g from a grid of starts; a second-order test on the constraint.

## Assumptions

- Decimals to 10 significant figures; points where ∇g = 0 are not candidates.

## Worked examples

1. f = x^2 + 4y^2 - 2x + 8y, g = x + 2y = 7 gives extrema = minimum 27 at (5, 1). Source: OpenStax Calculus Vol. 3 (Strang and Herman, 2016), 4.8, Ex. 4.42.
2. f = 48x + 96y - x^2 - 2x y - 9y^2, g = 20x + 4y = 216 gives extrema = maximum 540 at (10, 4).

## FAQ

### What is the method of Lagrange multipliers?

To find the largest or smallest value of f subject to a constraint g = c, look for points where the gradients are parallel: ∇f = λ∇g for some number λ, the Lagrange multiplier, together with g = c. With two variables that is three equations in x, y and λ. Every constrained maximum or minimum at a point where ∇g is not 0 is among these candidate points.

### How does the page tell a maximum from a minimum?

It uses the second-order test along the constraint. At each candidate point it steps a short distance along the constraint in each direction and compares f there with f at the point: with two variables along the one tangent direction, with three along two perpendicular tangent directions and the diagonal between them, which fixes the curvature of f on the surface. Curving up in every direction is a local minimum, down in every direction a local maximum, and anything else (a saddle, or flat) neither.

### Is the largest value a global maximum?

When the constraint is a closed, bounded curve or surface, such as a circle or a sphere, f has a largest and a smallest value on it, and they are among the candidates, so the largest local maximum is the maximum. On an unbounded constraint such as a line, f may grow without limit, so a local minimum can be the only extreme value: for f = x² + 4y² − 2x + 8y on x + 2y = 7 the minimum is 27 at (5, 1) and there is no maximum.

### Why are the answers decimals?

The equations ∇f = λ∇g, g = c are solved numerically, by Newton’s method, so every coordinate and value is a decimal to 10 significant figures. A point such as (5, 1) shows as 5 and 1 because its decimals round to those numbers.

### What does λ mean?

The multiplier λ tells how fast the best value of f changes when the constraint constant c changes: d(max f)/dc = λ. In economics, when f is output and g = c is a budget, λ is the extra output per extra dollar of budget.

### Can I use two constraints?

No. This page takes one constraint g = c in 2 or 3 variables. With two constraints the method uses two multipliers, ∇f = λ∇g + μ∇h.

## Sources

- OpenStax, Calculus Volume 3, section 4.8 Lagrange Multipliers: https://openstax.org/books/calculus-volume-3/pages/4-8-lagrange-multipliers
