From Two Constraints to One System
A constrained optimization problem asks for the largest or smallest value of an objective function while the variables are restricted by specified conditions. With two equality constraints in three variables, the feasible points generally lie on a curve. At a regular constrained extremum, the objective gradient must be a combination of the two constraint gradients.
The practical task is to express that condition correctly and include both constraints. The result is a system of five equations in the three coordinates and two multipliers. Omitting either multiplier or either constraint equation changes the problem.
The Five Equations
Suppose \(f,g,h\) have continuous first partial derivatives near a feasible point, and suppose \(\nabla g\) and \(\nabla h\) are linearly independent there. The multiple-constraint Lagrange condition says that if the point is a constrained local extremum, then \(\nabla f\) lies in the span of \(\nabla g\) and \(\nabla h\). Thus there are scalars \(\lambda\) and \(\mu\) such that \(\nabla f=\lambda\nabla g+\mu\nabla h\).
Writing out each gradient gives three scalar equations. The two original constraints provide the other two. In partial-derivative notation, the complete system is:
All partial derivatives in the first three equations are evaluated at the same point \((x,y,z)\). The five unknowns are \(x,y,z,\lambda,\mu\). A solution is a stationary candidate, not automatically a maximum or minimum: the system identifies points to investigate, while further reasoning is needed to classify them.
Why Both Multiplier Terms Appear
The geometric reason for the gradient-span condition is that a feasible tangent direction must be tangent to both constraint surfaces. If \(\mathbf{v}\) is such a direction, then \(\nabla g\cdot\mathbf{v}=0\) and \(\nabla h\cdot\mathbf{v}=0\). At a constrained local extremum, the first-order change of the objective in every feasible tangent direction is zero, so \(\nabla f\cdot\mathbf{v}=0\) as well. When the two constraint gradients are independent, the vectors orthogonal to all such common tangent directions are precisely the vectors in their span. Therefore \(\nabla f=\lambda\nabla g+\mu\nabla h\). This is the gradient-span rule for two regular constraints.
Expanding that vector equation is the essential setup step. Its \(x\)-component contains both \(g_x\) and \(h_x\); the same is true of its \(y\)- and \(z\)-components. The multipliers need not have the same value: each records the coefficient of a different constraint gradient.
Worked Example: A Quadratic Objective with Two Linear Constraints
Find the Lagrange system for \(f(x,y,z)=x^2+y^2+z^2\), subject to \(x+y=2\) and \(y+z=3\), and solve it.
First write both constraints in zero-level form: \(g=x+y-2=0\) and \(h=y+z-3=0\). Their gradients are \(\nabla g=(1,1,0)\) and \(\nabla h=(0,1,1)\), which are independent. The objective gradient is \(\nabla f=(2x,2y,2z)\). Thus the five equations are:
From the first and third equations, \(\lambda=2x\) and \(\mu=2z\). The second then gives \(2y=2x+2z\), so \(y=x+z\). Substituting into the constraints gives \(2x+z=2\) and \(x+2z=3\). Subtracting the first of these equations from the second gives \(z-x=1\), or \(z=x+1\). Then \(2x+(x+1)=2\), so \(3x=1\) and \(x=\frac13\). Consequently \(z=\frac43\) and \(y=x+z=\frac53\). The multipliers are \(\lambda=2x=\frac23\) and \(\mu=2z=\frac83\).
Check the constraints: \(\frac13+\frac53=2\), and \(\frac53+\frac43=3\). Check the multiplier equations: \(2x=\frac23=\lambda\), \(2y=\frac{10}{3}=\lambda+\mu\), and \(2z=\frac83=\mu\). The point and both multipliers satisfy all five equations.
Writing Constraints in a Usable Form
Constraints may be presented as equations with nonzero right-hand sides. To use the standard system, move each right-hand side to the left so that each constraint is set equal to zero. For example, \(x^2+y^2=1\) becomes \(g(x,y,z)=x^2+y^2-1=0\), and \(x+z=2\) becomes \(h(x,y,z)=x+z-2=0\). The constants disappear when differentiating, but they must remain in the constraint equations.
Worked Example: A Linear Objective and a Cylinder Constraint
Set up and solve the Lagrange system for \(f(x,y,z)=z\), subject to \(x^2+y^2=1\) and \(x+z=2\).
Define \(g=x^2+y^2-1\) and \(h=x+z-2\). Then \(\nabla f=(0,0,1)\), \(\nabla g=(2x,2y,0)\), and \(\nabla h=(1,0,1)\). The five equations are:
The third equation gives \(\mu=1\). The first equation becomes \(2\lambda x=-1\), so \(\lambda\ne 0\). The second equation \(2\lambda y=0\) therefore forces \(y=0\). The first constraint now gives \(x^2=1\), so \(x=1\) or \(x=-1\).
If \(x=1\), the first multiplier equation gives \(\lambda=-\frac12\), and the second constraint gives \(z=1\). If \(x=-1\), it gives \(\lambda=\frac12\), and the second constraint gives \(z=3\). Thus the stationary candidates are \((1,0,1)\), with \((\lambda,\mu)=(-\frac12,1)\), and \((-1,0,3)\), with \((\lambda,\mu)=(\frac12,1)\).
For the first candidate, \(x^2+y^2=1\) and \(x+z=2\); its multiplier equations read \(0=2(-\frac12)(1)+1\), \(0=2(-\frac12)(0)\), and \(1=1\). For the second, the constraints also hold, and the multiplier equations read \(0=2(\frac12)(-1)+1\), \(0=2(\frac12)(0)\), and \(1=1\). Both candidates pass the full system check.
A Second Nonlinear Objective
The same setup applies when the objective and constraints have different algebraic forms. The reliable procedure is unchanged: calculate each gradient, attach its own multiplier to each constraint gradient, expand the three components, then append both constraint equations.
Worked Example: An Objective with a Product Term
Set up and solve the Lagrange system for \(f(x,y,z)=xy+z^2\), subject to \(x+y+z=3\) and \(x-y=0\).
Write \(g=x+y+z-3\) and \(h=x-y\). The gradients are \(\nabla f=(y,x,2z)\), \(\nabla g=(1,1,1)\), and \(\nabla h=(1,-1,0)\). The complete system is:
The last equation says \(x=y\). Comparing the first two equations then gives \(\lambda+\mu=\lambda-\mu\), so \(2\mu=0\) and \(\mu=0\). The first equation now gives \(\lambda=x\), while the third gives \(2z=x\), or \(z=\frac{x}{2}\). Substituting \(y=x\) and \(z=\frac{x}{2}\) into the first constraint gives \(x+x+\frac{x}{2}=3\). Hence \(\frac52x=3\), so \(x=\frac65\), \(y=\frac65\), and \(z=\frac35\). The multipliers are \(\mu=0\) and \(\lambda=\frac65\).
Check the constraints: \(\frac65+\frac65+\frac35=3\) and \(\frac65-\frac65=0\). The gradient equations also hold: \(y=\frac65=\lambda+\mu\), \(x=\frac65=\lambda-\mu\), and \(2z=\frac65=\lambda\). Thus the calculated point solves the system.
Common Setup Mistakes
A frequent error is to use just one multiplier because there are three variables, or to combine both constraint gradients under a single multiplier. Two constraints contribute two gradient directions, and each needs its own coefficient. Another error is to write the three gradient equations but leave out one of the original constraints; that produces an incomplete system.
There is also a condition on applying this method: the two constraint gradients must be independent at the point for the regular gradient-span rule to guarantee the multiplier equations. If that condition fails, the usual rule may not capture every constrained extremum. Therefore, after forming a system, check the gradients at any point under consideration rather than assuming regularity automatically.
Why the Setup Matters
Correctly formulating the equations separates the geometry of the problem from the algebra used to solve it. The three component equations encode the gradient relation; the final two equations restrict solutions to feasible points. Keeping those roles visible makes it easier to detect missing terms, lost constraints, and solutions that do not satisfy the original problem.
Write \(g(x,y,z)=0\) and \(h(x,y,z)=0\).
Find \(\nabla f\), \(\nabla g\), and \(\nabla h\).
Write \(\nabla f=\lambda\nabla g+\mu\nabla h\) and expand all three components.
The three component equations plus the two constraint equations form the full system.
Substitute into all five equations and check the regularity condition when applying the rule.
Check Your Understanding
For each question, focus on the structure of the system as well as the calculations.
- For an objective \(f(x,y,z)\) with constraints \(g(x,y,z)=0\) and \(h(x,y,z)=0\), how many scalar equations and unknowns appear in the standard Lagrange system?
- Why does each constraint gradient have its own multiplier?
- Rewrite \(x^2+y^2=5\) and \(x+2z=4\) in zero-level form.
- If \(\nabla f=(2x,2y,2z)\), \(\nabla g=(1,0,1)\), and \(\nabla h=(0,1,1)\), write the three component equations.
- What regularity condition on the constraint gradients supports the gradient-span rule?