Lagrange Multipliers in Two Dimensions

​
K
0.05
λ
0.3
zoom
equilibrium
equilibrium
(x,y,λ) = (0.05, 0, -0.1)
This Demonstration intends to show how Lagrange multipliers work in two dimensions.
The 1D problem, which is simpler to visualize and contains some essential features of Lagrange multipliers, is treated in another Demonstration that can serve as an introduction to this one.

Details

The main ideas behind the Lagrange multipliers have already been discussed in the 1D case. See Lagrange Multipliers in One Dimension.
This Demonstration illustrates the 2D case, where in particular, the Lagrange multiplier
λ
is shown to modify not only the relative slopes of the function
f
to be minimized and the rescaled constraint
λR
(which was already shown in the 1D case), but also their relative orientations (which do not exist in the 1D case).
This in turn shows how the independence of
x
and
y
is restored by the introduction of
λ
(which is adjusted so that
f
and
λR
are strictly parallel in both slope and orientation, so that their height difference
F
remains constant near the solution, with no more constraint between
x
and
y
).
The global problem can be understood as finding a point that is:
1. on the particular contour line
R(x,y)=K
, and
2. on a contour line
f(x,y)=constant
or
df=0
(the constant is unknown, as the contour line is what we are looking for) tangent to the previous one.
By imposing
gradf(x,y)=λgradR(x,y)
(for any
λ
), we impose that
f(x,y)
and
λR(x,y)
share the same orientation but with different relative slopes (depending on
λ
).
λ
is then a tuning tool to find the place where the functions
f(x,y)
and
λR(x,y)
have the same slope (strict parallelism) and hence where the potential
f-λR
is an extremum (equilibrium situation).
Here are a few explanations for each of the four plots displayed:
• upper-left: this is the case treated without the Lagrange multiplier. The thick blue line is the constraint, the thick red line is its projection on
f
, and the solution is the top of the red thick line.
• upper-right: this is the case treated with the help of
λ
. The constraint function
R
is rescaled (
λR
), but as
λR=λK
, the constraint (thick blue line) keeps the same position as in the previous case. The function
F
plotted in green is the new potential, which is to be optimized without constraint on
(x,y)
. When equilibrium is forced, its extremum corresponds to the solution of the problem. When equilibrium is not forced, it is a function of the three variables
x
,
y
,
λ
.
• bottom-left: same as upper-right, but with a contour representation, which shows more clearly the contour lines and the extremums of the three functions involved. The orange point is the one given by the 2D slider. When equilibrium is forced, it shows the solution of the problem (top of the green function
F
); otherwise it can be used to explore the slopes with the bottom-right panel.
• bottom-right: this is a close-up (tangent planes) of the plots of the three functions involved around the position (orange point) chosen by the 2D slider. It allows a comparison between their slopes. In particular, when
y=0
,
f
and
λR
have the same orientation but different slopes (this amounts to the 1D problem), and near the solution, they become completely parallel. When
y≠0
, their orientations are different. When equilibrium is forced, their slopes remain parallel, hence
F
remains horizontal (constant).
When forcing equilibrium, you can only change
K
(then
λ
,
x
, and
y
are the computed unique solution of the problem).
With the equilibrium box unchecked, you can change
λ
(a slider) and
(x,y)
(2D slider) to get a feeling of how they act and what they mean.

External Links

Lagrange Multipliers in One Dimension

Permanent Citation

Cedric Voisin
​
​"Lagrange Multipliers in Two Dimensions"​
​http://demonstrations.wolfram.com/LagrangeMultipliersInTwoDimensions/​
​Wolfram Demonstrations Project​
​Published: July 18, 2012