Learning Objectives
- Use the method of Lagrange multipliers to solve optimization problems with one constraint.
- Use the method of Lagrange multipliers to solve optimization problems with two constraints.
Solving optimization problems for functions of two or more variables can be similar to solving such problems in single-variable calculus. However, techniques for dealing with multiple variables allow us to solve more varied optimization problems for which we need to deal with additional conditions or constraints. In this section, we examine one of the more common and useful methods for solving optimization problems with constraints.
Lagrange Multipliers
Chapter Opener: Profitable Golf Balls was an applied situation involving maximizing a profit function, subject to certain constraints. In that example, the constraints involved a maximum number of golf balls that could be produced and sold in 11 month (x)(x), and a maximum number of advertising hours that could be purchased per month (y)(y). Suppose these were combined into a budgetary constraint, such as 20x+4y≤21620x+4y≤216, that took into account the cost of producing the golf balls and the number of advertising hours purchased per month. The goal is, still, to maximize profit, but now there is a different type of constraint on the values of xx and yy. This constraint, when combined with the profit function f(x,y)=48x+96y−x2−2xy−9y2f(x,y)=48x+96y−x2−2xy−9y2, is an example of an optimization problem, and the function f(x,y)f(x,y) is called the objective function. A graph of various level curves of the function f(x,y)f(x,y) follows.

Figure 1. Graph of level curves of the function f(x,y)=48x+96y−x2−2xy−9y2f(x,y)=48x+96y−x2−2xy−9y2 corresponding to c=150,250,350, and 400c=150,250,350, and 400.
In Figure 1, the value cc represents different profit levels (i.e., values of the function ff). As the value of cc increases, the curve shifts to the right. Since our goal is to maximize profit, we want to choose a curve as far to the right as possible. If there was no restriction on the number of golf balls the company could produce, or the number of units of advertising available, then we could produce as many golf balls as we want, and advertise as much as we want, and there would not be a maximum profit for the company. Unfortunately, we have a budgetary constraint that is modeled by the inequality 20x+4y≤21620x+4y≤216. To see how this constraint interacts with the profit function, Figure 2 shows the graph of the line 2x+4y=2162x+4y=216 superimposed on the previous graph.

Figure 2. Graph of level curves of the function f(x,y)=48x+96y−x2−2xy−9y2f(x,y)=48x+96y−x2−2xy−9y2 corresponding to c=150,250,350, and 395c=150,250,350, and 395. The red graph is the constraint function.
As mentioned previously, the maximum profit occurs when the level curve is as far to the right as possible. However, the level of production corresponding to this maximum profit must also satisfy the budgetary constraint, so the point at which this profit occurs must also lie on (or to the left of) the red line in Figure 2. Inspection of this graph reveals that this point exists where the line is tangent to the level curve of ff. Trial and error reveals that this profit level seems to be around 395395, when xx and yy are both just less than 55. We return to the solution of this problem later in this section. From a theoretical standpoint, at the point where the profit curve is tangent to the constraint line, the gradient of both of the functions evaluated at that point must point in the same (or opposite) direction. Recall that the gradient of a function of more than one variable is a vector. If two vectors point in the same (or opposite) directions, then one must be a constant multiple of the other. This idea is the basis of the method of Lagrange multipliers.
Theorem: method of lagrange multipliers: one constant
Let ff and gg be functions of two variables with continuous partial derivatives at every point of some open set containing the smooth curve g(x,y)=0g(x,y)=0. Suppose that ff, when restricted to points on the curve g(x,y)=0g(x,y)=0, has a local extremum at the point (x0,y0)(x0,y0) and that ∇g(x0,y0)≠0∇g(x0,y0)≠0. Then there is a number λλ called a Lagrange multiplier, for which
∇f(x0,y0)=λ∇g(x0,y0)∇f(x0,y0)=λ∇g(x0,y0)
Proof
Assume that a constrained extremum occurs at the point (x0,y0)(x0,y0). Furthermore, we assume that the equation g(x,y)=0g(x,y)=0 can be smoothly parameterized as
x=x(s)x=x(s) and y=y(s)y=y(s)
where s is an arc length parameter with reference point (x0,y0)(x0,y0) at s=0s=0. Therefore, the quantity z=f(x(s),y(s))z=f(x(s),y(s)) has a relative maximum or relative minimum at s=0s=0, and this implies that dzds=0dzds=0 at that point. From the chain rule,
dzds=∂f∂x⋅∂x∂s+∂f∂y⋅∂y∂s=(∂f∂xˆi+∂f∂yˆj)⋅(∂x∂sˆi+∂y∂sˆj)=0,dzds=∂f∂x⋅∂x∂s+∂f∂y⋅∂y∂s=(∂f∂x^i+∂f∂y^j)⋅(∂x∂s^i+∂y∂s^j)=0,
where the derivatives are all evaluated at s=0s=0. However, the first factor in the dot product is the gradient of ff, and the second factor is the unit tangent vector T(0)T(0) to the constraint curve. Since the point (x0,y0)(x0,y0) corresponds to s=0s=0, it follows from this equation that
∇f(x0,y0)⋅T(0)=0,∇f(x0,y0)⋅T(0)=0,
which implies that the gradient is either 00 or is normal to the constraint curve at a constrained relative extremum. However, the constraint curve g(x,y)=0g(x,y)=0 is a level curve for the function g(x,y)g(x,y) so that if ∇g(x0,y0)≠0∇g(x0,y0)≠0 then ∇g(x0,y0)∇g(x0,y0) is normal to this curve at (x0,y0)(x0,y0) It follows, then, that there is some scalar λλ such that
∇f(x0,y0)=λ∇g(x0,y0)∇f(x0,y0)=λ∇g(x0,y0)
■
To apply the Method of Lagrange Multipliers: One Constraint to an optimization problem similar to that for the golf ball manufacturer, we need a problem-solving strategy.
Problem solving strategy: steps for using Lagrange multipliers
- Determine the objective function f(x,y)f(x,y) and the constraint function g(x,y)g(x,y). Does the optimization problem involve maximizing or minimizing the objective function?
- Set up a system of equations using the following template:
[latex]\hspace{8cm}\begin{align}
\nabla{f}(x_0,y_0)\cdot{\text{T}}(0)&=0 \\ g(x_0,y_0)&=0. \end{align}[/latex]
- Solve for x0x0 and y0y0.
- The largest of the values of ff at the solutions found in step 3 maximizes ff; the smallest of those values minimizes ff.
Example: using lagrange multipliers
Use the method of Lagrange multipliers to find the minimum value of f(x,y)=x2+4y2−2x+8yf(x,y)=x2+4y2−2x+8y subject to the constraint x+2y=7x+2y=7.
try it
Use the method of Lagrange multipliers to find the maximum value of f(x,y)=9x2+36xy−4y2−18x−8yf(x,y)=9x2+36xy−4y2−18x−8y subject to the constraint 3x+4y=323x+4y=32.
Let’s now return to the problem posed at the beginning of the section.
Example: golf balls and lagrange multipliers
The golf ball manufacturer, Pro-T, has developed a profit model that depends on the number xx of golf balls sold per month (measured in thousands), and the number of hours per month of advertising yy, according to the function
z=f(x,y)=48x+96y−x2−2xy−9y2z=f(x,y)=48x+96y−x2−2xy−9y2,
where zz is measured in thousands of dollars. The budgetary constraint function relating the cost of the production of thousands golf balls and advertising units is given by 20x+4y=21620x+4y=216. Find the values of xx and yy that maximize profit, and find the maximum profit.
try it
A company has determined that its production level is given by the Cobb-Douglas function f(x,y)=2.5x0.45y0.55f(x,y)=2.5x0.45y0.55 where xx represents the total number of labor hours in 11 year and yy represents the total capital input for the company. Suppose 11 unit of labor costs $40$40 and 11 unit of capital costs $50$50. Use the method of Lagrange multipliers to find the maximum value of f(x,y)=2.5x0.45y0.55f(x,y)=2.5x0.45y0.55 subject to a budgetary constraint of $500,000$500,000 per year.
Watch the following video to see the worked solution to the above Try It
In the case of an optimization function with three variables and a single constraint function, it is possible to use the method of Lagrange multipliers to solve an optimization problem as well. An example of an optimization function with three variables could be the Cobb-Douglas function in the previous example: f(x,y,z)=x0.2y0.4z0.4f(x,y,z)=x0.2y0.4z0.4, where xx represents the cost of labor, yy represents capital input, and zz represents the cost of advertising. The method is the same as for the method with a function of two variables; the equations to be solved are
∇f(x,y,z)=λ∇g(x,y,z)g(x,y,z)=0.∇f(x,y,z)=λ∇g(x,y,z)g(x,y,z)=0.
Example: lagrange multipliers with a three-variable optimization function
Find the minimum of the function f(x,y,z)=x2+y2+z2f(x,y,z)=x2+y2+z2 subject to the constraint x+y+z=1x+y+z=1.
Try it
Use the method of Lagrange multipliers to find the minimum value of the function
f(x,y,z)=x+y+z
subject to the constraint x2+y2+z2=1.
Problems with Two Constraints
The method of Lagrange multipliers can be applied to problems with more than one constraint. In this case the optimization function, w is a function of three variables:
w=f(x,y,z)
and it is subject to two constraints:
g(x,y,z)=0 and h(x,y,z)=0
There are two Lagrange multipliers, λ1 and λ2, and the system of equations becomes
∇f(x0,y0,z0)=λ1∇g(x0,y0,z0)+λ2∇h(x0,y0,z0)g(x0,y0,z0)=0h(x0,y0,z0)=0.
Example: Lagrange Multipliers with Two constraints
Find the maximum and minimum values of the function
f(x,y,z)=x2+y2+z2
subject to the constraints z2=x2+y2 and x+y−z+1=0.
Try it
Use the method of Lagrange multipliers to find the minimum value of the function
f(x,y,z)=x2+y2+z2
subject to the constraints 2x+y+2z=9 and 5x+5y+7z=29.
Watch the following video to see the worked solution to the above Try It
Candela Citations
- CP 4.38. Authored by: Ryan Melton. License: CC BY: Attribution
- CP 4.40. Authored by: Ryan Melton. License: CC BY: Attribution
- Calculus Volume 3. Authored by: Gilbert Strang, Edwin (Jed) Herman. Provided by: OpenStax. Located at: https://openstax.org/books/calculus-volume-3/pages/1-introduction. License: CC BY-NC-SA: Attribution-NonCommercial-ShareAlike. License Terms: Access for free at https://openstax.org/books/calculus-volume-3/pages/1-introduction