Lagrange Multipliers in Two Dimensions

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.


  • [Snapshot]
  • [Snapshot]
  • [Snapshot]


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 to be minimized and the rescaled constraint (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 and is restored by the introduction of (which is adjusted so that and are strictly parallel in both slope and orientation, so that their height difference remains constant near the solution, with no more constraint between and ).
The global problem can be understood as finding a point that is:
1. on the particular contour line , and
2. on a contour line or (the constant is unknown, as the contour line is what we are looking for) tangent to the previous one.
By imposing (for any ), we impose that and share the same orientation but with different relative slopes (depending on ).
is then a tuning tool to find the place where the functions and have the same slope (strict parallelism) and hence where the potential 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 , 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 is rescaled (), but as , the constraint (thick blue line) keeps the same position as in the previous case. The function plotted in green is the new potential, which is to be optimized without constraint on . 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 , , .
• 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 ); 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 , and have the same orientation but different slopes (this amounts to the 1D problem), and near the solution, they become completely parallel. When , their orientations are different. When equilibrium is forced, their slopes remain parallel, hence remains horizontal (constant).
When forcing equilibrium, you can only change (then , , and are the computed unique solution of the problem).
With the equilibrium box unchecked, you can change (a slider) and (2D slider) to get a feeling of how they act and what they mean.
    • Share:

Embed Interactive Demonstration New!

Just copy and paste this snippet of JavaScript code into your website or blog to put the live Demonstration on your site. More details »

Files require Wolfram CDF Player or Mathematica.

Mathematica »
The #1 tool for creating Demonstrations
and anything technical.
Wolfram|Alpha »
Explore anything with the first
computational knowledge engine.
MathWorld »
The web's most extensive
mathematics resource.
Course Assistant Apps »
An app for every course—
right in the palm of your hand.
Wolfram Blog »
Read our views on math,
science, and technology.
Computable Document Format »
The format that makes Demonstrations
(and any information) easy to share and
interact with.
STEM Initiative »
Programs & resources for
educators, schools & students.
Computerbasedmath.org »
Join the initiative for modernizing
math education.
Step-by-step Solutions »
Walk through homework problems one step at a time, with hints to help along the way.
Wolfram Problem Generator »
Unlimited random practice problems and answers with built-in Step-by-step solutions. Practice online or make a printable study sheet.
Wolfram Language »
Knowledge-based programming for everyone.
Powered by Wolfram Mathematica © 2014 Wolfram Demonstrations Project & Contributors  |  Terms of Use  |  Privacy Policy  |  RSS Give us your feedback
Note: To run this Demonstration you need Mathematica 7+ or the free Mathematica Player 7EX
Download or upgrade to Mathematica Player 7EX
I already have Mathematica Player or Mathematica 7+