Why Solve the System by Substitution?
For a differentiable objective \(f(x,y)\) subject to a smooth equality constraint \(g(x,y)=c\), the Lagrange equations introduce a multiplier \(\lambda\). The equations are often straightforward to write down, but solving them can be the harder part. A useful strategy is to eliminate \(\lambda\), use the constraint to reduce the variables, and factor the resulting equation.
This approach is especially effective when the objective and constraint are polynomials. Substitution may turn a system of three equations in \(x\), \(y\), and \(\lambda\) into one equation whose factors identify the possible cases. Each case must still be solved against the constraint, and every resulting point must be checked in the original Lagrange equations.
When the constraint is regular, the Lagrange theorem says that a differentiable objective can have a constrained local extremum there only if the Lagrange equations hold. Thus solving the equations finds necessary candidates; it does not by itself prove that a candidate is a maximum or minimum. The method below assumes regularity at the feasible points being considered.
Eliminating the Multiplier
Write the Lagrange equations in components:
Multiply the first equation by \(g_y\) and the second by \(g_x\). Their right-hand sides are both \(\lambda g_xg_y\), so subtracting gives an equation that does not contain \(\lambda\):
This determinant condition says that the two gradient vectors are parallel. It is equivalent to the existence of a multiplier when \(\nabla g\ne\mathbf{0}\): if \(g_x\ne0\), set \(\lambda=f_x/g_x\), and the determinant equation then gives \(f_y=\lambda g_y\). If \(g_x=0\), regularity forces \(g_y\ne0\); the determinant equation gives \(f_x=0\), and setting \(\lambda=f_y/g_y\) satisfies both component equations.
After forming \(f_xg_y-f_yg_x=0\), use the constraint to substitute for one variable where convenient. Factoring the resulting expression reveals branches of possible solutions. This elimination step is a way to solve the equations, not a replacement for checking them: degenerate points where \(\nabla g=\mathbf{0}\) must be treated separately if they are feasible.
A Linear Constraint
Worked Example: A Quadratic Objective on a Line
Find the Lagrange candidates for \(f(x,y)=x^2+y^2\) subject to \(x+2y=6\).
Let \(g(x,y)=x+2y\) and \(c=6\). The gradients are \(\nabla f=(2x,2y)\) and \(\nabla g=(1,2)\). The Lagrange equations are
The first equation gives \(\lambda=2x\); the second gives \(\lambda=y\). Equating these expressions yields \(y=2x\). Substituting into the constraint gives \(x+2(2x)=6\), so \(5x=6\), \(x=6/5\), and \(y=12/5\). The multiplier is \(\lambda=2x=12/5\).
Check the constraint: \(6/5+2(12/5)=30/5=6\). Check the gradient equations: \(2x=12/5=\lambda\) and \(2y=24/5=2\lambda\). Thus the only Lagrange candidate is \((6/5,12/5)\). The constraint gradient \((1,2)\) is nonzero everywhere, so it is regular at this point.
Factoring After Substitution
For a nonlinear constraint, the determinant equation often gives a polynomial that factors into separate cases. The constraint then determines the points in each case. It is important to solve every factor branch: dividing by a factor before checking whether it can be zero may discard valid candidates.
Worked Example: A Product on the Unit Circle
Find all Lagrange candidates for \(f(x,y)=xy\) subject to \(x^2+y^2=1\).
Here \(g(x,y)=x^2+y^2\), so \(\nabla f=(y,x)\) and \(\nabla g=(2x,2y)\). The determinant condition is
Thus \(y=x\) or \(y=-x\). For \(y=x\), the constraint gives \(2x^2=1\), hence \(x=y=1/\sqrt{2}\) or \(x=y=-1/\sqrt{2}\). For \(y=-x\), it again gives \(2x^2=1\), hence \((x,y)=(1/\sqrt{2},-1/\sqrt{2})\) or \((-1/\sqrt{2},1/\sqrt{2})\).
Check the multiplier for the first branch. The component equations are \(y=2\lambda x\) and \(x=2\lambda y\). At \(y=x\ne0\), both give \(\lambda=1/2\). At \(y=-x\ne0\), both give \(\lambda=-1/2\). Each point satisfies \(x^2+y^2=1\), and substituting the stated multiplier satisfies both gradient equations. Since \(\nabla g=(2x,2y)\ne\mathbf{0}\) on the unit circle, these four points are exactly the Lagrange candidates.
A Polynomial Objective with a Zero-Factor Branch
The next example shows why every factor branch matters. One factor will set a coordinate equal to zero, and those points must be retained even though a later algebraic step on the other branch will divide by that coordinate.
Worked Example: A Cubic Objective on the Unit Circle
Find all Lagrange candidates for \(f(x,y)=x^2y\) subject to \(x^2+y^2=1\).
The gradients are \(\nabla f=(2xy,x^2)\) and \(\nabla g=(2x,2y)\). Eliminating \(\lambda\) gives
First consider \(x=0\). The constraint becomes \(y^2=1\), so the candidates on this branch are \((0,1)\) and \((0,-1)\). At either point, \(\nabla f=(0,0)\), while \(\nabla g=(0,2y)\ne\mathbf{0}\). The Lagrange equations hold with \(\lambda=0\).
Now consider \(2y^2-x^2=0\), or \(x^2=2y^2\). Substituting into the constraint gives \(2y^2+y^2=1\), so \(y^2=1/3\) and \(x^2=2/3\). Therefore this branch gives all four sign choices:
To check these four points, use the first component equation \(2xy=2\lambda x\). Since \(x\ne0\), it gives \(\lambda=y\). The second component equation requires \(x^2=2\lambda y=2y^2\), which holds by construction. The constraint also holds because \(x^2+y^2=2/3+1/3=1\). The two points on the \(x=0\) branch and the four points on the other branch exhaust the factors and satisfy the original system. The constraint gradient is nonzero everywhere on the unit circle.
A Reliable Solving Procedure
The examples use the same logical sequence. Keeping the branches visible prevents missed solutions and makes the final verification systematic.
Set \(\nabla f=\lambda\nabla g\) and include the constraint \(g(x,y)=c\).
Form \(f_xg_y-f_yg_x=0\), or eliminate \(\lambda\) directly from the component equations.
Use the constraint to reduce the equation, then list every factor branch without dividing away possible zeros.
Find the points satisfying both the branch and constraint, recover \(\lambda\) when regular, and check the original equations.
Common Pitfall: Dividing by a Variable Too Soon
In the cubic example, the condition was \(2x(2y^2-x^2)=0\). A mistaken solution might divide by \(x\) and keep only \(2y^2-x^2=0\). That would discard \(x=0\) and miss the valid candidates \((0,1)\) and \((0,-1)\).
The correction is to apply the zero-product property first: either \(x=0\), or \(2y^2-x^2=0\). Solve both branches with the constraint, then check both against the original Lagrange equations. More generally, cancellation is valid only after establishing that the canceled quantity cannot be zero among the solutions.
Check Your Understanding
Use the determinant condition and the constraint where appropriate. Keep every factor branch and verify proposed points in the original system.
- For \(f(x,y)=x^2+y^2\) subject to \(x-y=2\), write the Lagrange equations and solve for the candidate and multiplier.
- For \(f(x,y)=xy\) subject to \(x^2+y^2=4\), factor the multiplier-free equation and find all candidate points.
- Why does \(f_xg_y-f_yg_x=0\) imply a multiplier exists when \(\nabla g\ne\mathbf{0}\)?
- In solving \(2x(2y^2-x^2)=0\), what solutions might be lost by dividing by \(x\) immediately?
- Does satisfying the Lagrange equations alone prove that a point is a constrained maximum? Explain.