Skip to content
Free public beta until December 4, 2026: every course is open, no card needed. After that, the first chapter of each course stays free and full access is a one-time $39 ($19 for up to 100 founding members chosen for helpful feedback). Your progress is kept. How the beta works

Recipe

Solve a constrained optimization problem with Lagrange multipliers, two constraints

Use when: you need the extrema of f(x,y,z) subject to two equation constraints g(x,y,z)=k_1 and h(x,y,z)=k_2 at once, with \nabla g and \nabla h never parallel on the intersection

Goal: every candidate point on the curve where both constraint surfaces meet, with the true max and min picked out by comparing f across all of them

Taught in Lagrange multipliers with two constraints · extends Solve a constrained optimization problem with Lagrange multipliers

  1. 1

    Compute all three gradients, then write the three component equations this condition gives, alongside both constraints g=k_1 and h=k_2: five equations in the five unknowns x,y,z,\lambda,\mu.

    Example

    Extremize f(x,y,z)=x+y+2z subject to g(x,y,z)=x^2+y^2+z^2=22 and h(x,y,z)=y-z=0. Here \nabla f=(1,1,2), \nabla g=(2x,2y,2z), \nabla h=(0,1,-1), giving 1=2\lambda x, 1=2\lambda y+\mu, and 2=2\lambda z-\mu.

    Why: with two independent constraints pulling on f at once, the tangency condition needs one gradient term per constraint, since the constrained extremum is only forced to happen where \nabla f lies in the plane \nabla g and \nabla h span together.

  2. 2

    Add or subtract equations in a way that cancels \mu (or, if that's easier for the given system, cancels \lambda first instead), then bring in a constraint to simplify further.

    Example

    Adding the second and third equations cancels \mu: 1+2=2\lambda y+2\lambda z, i.e. 3=2\lambda(y+z). The constraint h=0 gives y=z, so this becomes 3=4\lambda y, meaning y=\dfrac{3}{4\lambda} and, since y=z, also z=\dfrac{3}{4\lambda}. The first equation gives x=\dfrac{1}{2\lambda}.

    Why: five equations in five unknowns is too many to substitute directly. Combining equations to knock out one multiplier at a time is what makes the system solvable by hand, the same idea Step 2 of the one-constraint recipe uses for its single multiplier.

  3. 3

    Plug the expressions for x, y, z in terms of \lambda into whichever constraint hasn't been used yet, and solve.

    Example

    Substituting into x^2+y^2+z^2=22: \left(\dfrac{1}{2\lambda}\right)^2+2\left(\dfrac{3}{4\lambda}\right)^2=\dfrac{1}{4\lambda^2}+\dfrac{9}{8\lambda^2}=\dfrac{11}{8\lambda^2}=22, so \lambda^2=\dfrac{1}{16} and \lambda=\pm\dfrac14.

    Why: exactly as with one constraint, the gradient condition alone only pins down ratios between the unknowns; the constraint equations are what turn those ratios into actual numbers.

  4. 4

    Back-substitute each value of \lambda into the Step 2 expressions to get a complete (x,y,z) candidate.

    Example

    \lambda=\dfrac14 gives x=2, y=z=3, so the candidate (2,3,3). \lambda=-\dfrac14 gives the negated point (-2,-3,-3).

    Why: \lambda and \mu were only ever bookkeeping variables; a candidate for the constrained extremum is a point in x,y,z, and every one of them has to be written out explicitly before comparing f-values.

  5. 5

    Compute f at each candidate; the largest and smallest values are the constrained extrema, provided the intersection of the two constraint surfaces is closed and bounded.

    Example

    f(2,3,3)=2+3+6=11 and f(-2,-3,-3)=-2-3-6=-11. The sphere and the plane y=z intersect in a circle, closed and bounded, so the maximum is 11 at (2,3,3) and the minimum is -11 at (-2,-3,-3).

    • the two constraint surfaces intersect in a closed, bounded curve, such as a sphere meeting a plane through its interior — the multivariable extreme value theorem guarantees the true max and min are among the candidates found
    • the two constraint surfaces are tangent somewhere on the intersection, so \nabla g and \nabla h point the same way there — that point isn't covered by this method, since the argument behind \nabla f=\lambda\nabla g+\mu\nabla h assumed the two gradients span a genuine plane

    Why: solving the five-equation system only narrows the search to candidates on the intersection curve, exactly as in the one-constraint case; comparing f-values is still the step that turns candidates into an answer.

Common mistakes

  • Writing \nabla f=\lambda\nabla g+\mu\nabla h but only ever using one of the two constraint equations to solve for the candidates.
  • Trying to eliminate both multipliers in one combined step instead of one at a time.
  • Forgetting to check that \nabla g and \nabla h are genuinely non-parallel at the candidate points found.
  • Reporting \lambda and \mu's values as if they were the answer, instead of the (x,y,z) point they came from.