Lagrange Multiplier Demystified
Why Does It Work?
1 Understanding why it works
Have you ever wondered why we use the Lagrange multiplier to solve constrained optimization problems?
Is it just a clever technique?
Since it is straightforward to use, we learn it like basic arithmetic by practicing it until we can do it by heart.
But have you ever wondered why it works? Does it always work? If not, why not?
If you want to know the answers to these questions, you are in the right place.
I’ll demystify it for you.
2 An example constrained optimization problem
If you are unfamiliar with constrained optimizations, I have written an article that explains them. Otherwise, please read on.
Suppose we have a mountain that looks like the one below:
The height of a location (x, y) is given as follows (in kilometers):
Further, suppose the mountain has an eruption:
From the top, it looks like the one below:
The eruption area is given as follows:
That means the edge of the eruption is given as follows:
So, the edge looks like this.
Suppose we want to know the highest position of the eruption on this mountain.
That means the highest position must be on the edge line of the eruption, which we can express as follows:
Any location
Therefore, the constrained optimization problem is to find the maximum
3 Intuition on how to solve the constrained optimization problem
Intuitively, we know that the maximum height of the eruption is around where the blue arrow indicates.
We are looking for the highest contour line that touches the edge of the eruption.
Let’s define the contour line equation:
For a given value of
The gradient of
The gradient is a vector of partial derivatives.
Similarly, the gradient of
The highest contour line that touches the edge of the eruption must have the gradient of
If the gradient of the contour line is not parallel with the gradient of the eruption edge, some eruption areas will be higher than the contour line.
So, we need to find such a point
4 The Lagrange multiplier and the Lagrangian
Let’s put our objective into a mathematical formula.
The gradient of
This
At this stage, we don’t know the value of
We can rearrange the equation as follows:
The zero here means the vector with zeros:
And we call the inside of the curly brackets the Lagrangian
So, we are saying that the following is the required condition.
The gradient of the Lagrangian gives us two equations.
But we have three unknowns
Actually, we have one more equation:
So, we can solve the three equations to find the highest location
The problem now becomes an arithmetic exercise.
The answer is
You can verify the values with the equations.
Also,
All in all, the Lagrange multiplier helps solve constraint optimization problems.
We find the point
In summary, we followed the steps below:
- Identify the function to optimize (maximize or minimize):
- Identify the function for the constraint:
- Define the Lagrangian
- Solve
satisfying the constraint
It’s as mechanical as the above, and you now know why it works.
But there are a few more things to mention.
5 When it does not work
I made a few assumptions while explaining the Lagrange multiplier.
First of all, I assumed all functions have gradients (the first derivatives), which means the functions
Second, I also assume that
These two assumptions are valid in this example, but in real problems, you should check that to use the Lagrange multiplier to solve your constraint optimization problem.
Third, I simplified the question so that we only need to deal with one maximum.
In other words, the shape of the mountain is defined such that there is only one solution to the constrained optimization problem.
In real-life problems, the mountain could have more complicated shapes with multiple peaks and valleys.
In such a case, we’d need to deal with the global optimization problem (i.e., multiple local maxima).
Instead, the example in this article only deals with one local maximum (the global maximum).
I hope that your understanding of the Lagrange multiplier is optimal now.
6 References
- Maxima, minima, and saddle points
Khan Academy - Joseph-Louis Lagrange
Wikipedia - On the Genesis of the Lagrange Multipliers
P. Bussotti - A Simple Explanation of Why Lagrange Multipliers Works
Andrew Chamberlain