Optimization & Lagrange Multipliers
Understanding Constrained and Unconstrained Optimization
Prerequisites
Required Knowledge
- Partial derivatives and their notation ($f_x, f_y, f_{xy}$ etc.)
- Critical points in multivariable calculus
- Second derivatives and the second derivative test
- Basic system of equations solving
- Understanding of contour plots and level curves
Key Terms Review
- Critical Point: Where $f_x = 0$ and $f_y = 0$
- Constraint: An equation $g(x,y) = 0$ that limits possible solutions
- Level Curve: A curve where $f(x,y) = k$ for some constant $k$
Visual Understanding
Types of Critical Points
Local Minimum: Bowl Shape (z = x² + y²)
Local Maximum: Hill Shape (z = -(x² + y²))
Saddle Point (z = x² - y²)
Constrained Optimization Example
Level curves of f(x,y) = x² + y² with constraint x + y = 2
Part 1: Unconstrained Optimization
Finding Critical Points
For a function $f(x,y)$, find points where:
\[ f_x = 0 \quad \text{and} \quad f_y = 0 \]The D-Test (Second Derivative Test)
- If $D>0$ and $f_{xx}(a,b)<0$, \(f\) has a relative maximum\).
- If $D>0$ and $f_{xx}(a,b)>0$, \(f\) has a relative minimum\).
- If $D<0$, \(f\) has a saddle point\) at $(a,b)$.
- If $D=0$, the test is inconclusive.
Examples: D-Test
Introductory Example: Simple Quadratic
Find and classify the critical point of $f(x,y)=x^2+y^2$
-
Visualize: This is a bowl-shaped surface, like a paraboloid.
Think of a ball rolling to the bottom of a bowl.
-
Find partial derivatives:
\[ f_x = 2x \quad \text{and} \quad f_y = 2y \] -
Set both equal to zero:
\[ 2x = 0 \implies x = 0 \] \[ 2y = 0 \implies y = 0 \] -
Critical point is $(0,0)$. Now classify it:
\[ f_{xx} = 2, \quad f_{yy} = 2, \quad f_{xy} = 0 \] \[ D = f_{xx}f_{yy} - (f_{xy})^2 = (2)(2) - (0)^2 = 4 > 0 \] \[ \text{Since } D > 0 \text{ and } f_{xx} > 0, \text{ this is a minimum} \]
-
Compute partial derivatives:
\[ f_x = 2x + 2y \quad \text{and} \quad f_y = 2x - 6y \] -
Set both partials to zero and solve the system:
\begin{align*} 2x + 2y &= 0 \quad &\text{(Equation 1)}\\ 2x - 6y &= 0 \quad &\text{(Equation 2)} \end{align*} From Equation 1: $x = -y$ Substitute into Equation 2: \[ 2(-y) - 6y = 0 \implies -8y = 0 \implies y = 0 \] Therefore, $x = 0$ also. The critical point is $(0,0)$. -
Compute second partial derivatives:
\[ f_{xx} = 2, \quad f_{yy} = -6, \quad f_{xy} = 2 \] -
Apply the D-Test at $(0,0)$:
\begin{align*} D &= f_{xx}(0,0)\,f_{yy}(0,0) - \bigl(f_{xy}(0,0)\bigr)^2 \\ &= (2)(-6) - (2)^2 \\ &= -12 - 4 \\ &= -16 \end{align*}Since $D < 0$, the point $(0,0)$ is a saddle point.
- $g_x=3x^2-3y,\;g_y=-3x+2y$. Solve $3x^2-3y=0,\;-3x+2y=0$.
- From $y=x^2$ and $y=\tfrac{3}{2}x$, get $x^2=\tfrac{3}{2}x\Rightarrow x( x-1.5)=0\). So $x=0$ or $1.5$.
- When $x=0$, $y=0$. When $x=1.5$, $y=2.25$.
- Compute second partials: $g_{xx}=6x,\;g_{yy}=2,\;g_{xy}=-3.$
- At $(0,0)$: $D=0\times2-(-3)^2=-9<0$ → saddle. At $(1.5,2.25)$: $g_{xx}=9, D=9\times2-9=9>0,g_{xx}>0$ → relative minimum.
Part 2: Optimization with Constraints
Lagrange Multipliers Method
For a function $f(x,y)$ subject to constraint $g(x,y)=0$:
\[ L(x,y,\lambda) = f(x,y) - \lambda g(x,y) \] \[ \text{Solve:} \quad L_x = 0, \quad L_y = 0, \quad L_\lambda = 0 \]Geometric Intuition: Lagrange Multipliers
Step 1: Visualize Level Curves
Think of contour lines on a topographic map:
- Each curve represents points where $f(x,y) = c$ for some constant $c$
- The gradient $\nabla f$ points in the direction of steepest increase
- The gradient is perpendicular to level curves
Step 2: Understand the Constraint
The constraint $g(x,y) = k$ is like a path we must follow:
- We can only move along this path
- $\nabla g$ is perpendicular to the constraint curve
Step 3: Find the Extremum
At an extremum point:
- The level curve of $f$ is tangent to the constraint curve
- $\nabla f = \lambda \nabla g$ (gradients are parallel)
- $\lambda$ tells us how the gradients scale relative to each other
Examples: Lagrange Multipliers
Example 1: Quadratic Function with Linear Constraint
Find the extremum of $f(x,y)=x^2+4y^2$ subject to $2x+y=51$
- Form Lagrangian: \[ L(x,y,\lambda) = x^2+4y^2 - \lambda(2x+y-51) \]
- Find partial derivatives: \[ L_x = 2x - 2\lambda = 0 \] \[ L_y = 8y - \lambda = 0 \] \[ L_\lambda = -(2x+y-51) = 0 \]
- Solve system: \[ x = \lambda, \quad y = \frac{\lambda}{8} \] \[ 2(\lambda) + \frac{\lambda}{8} = 51 \] \[ \lambda = 24 \implies x = 24, y = 3 \]
- Evaluate: $f(24,3) = 612$ (minimum)
Example 2: Quadratic Function with Mixed Terms
Find the extremum of $f(x,y) = 3x^2 + 2y^2 - 2xy$ subject to $x + y = 14$
- Form Lagrangian: \[ L(x,y,\lambda) = 3x^2 + 2y^2 - 2xy - \lambda(x + y - 14) \]
- Find partial derivatives: \[ L_x = 6x - 2y - \lambda = 0 \] \[ L_y = 4y - 2x - \lambda = 0 \] \[ L_\lambda = -(x + y - 14) = 0 \]
- Solve system: \[ 6x - 2y = \lambda \] \[ 4y - 2x = \lambda \] \[ x + y = 14 \]
- Solution: $x = 6$, $y = 8$, $\lambda = 20$
- Evaluate: $f(6,8) = 140$ (minimum)
Example 3: Mixed Signs in Quadratic Terms
Find the extremum of $f(x,y) = 3y^2 - x^2$ subject to $4x + 2y = 88$
- Form Lagrangian: \[ L(x,y,\lambda) = 3y^2 - x^2 - \lambda(4x + 2y - 88) \]
- Find partial derivatives: \[ L_x = -2x - 4\lambda = 0 \] \[ L_y = 6y - 2\lambda = 0 \] \[ L_\lambda = -(4x + 2y - 88) = 0 \]
- Solve: \[ x = -2\lambda \] \[ y = \frac{\lambda}{3} \] \[ -8\lambda + \frac{2\lambda}{3} = -88 \] \[ \lambda = 12 \implies x = -24, y = 4 \]
- Evaluate: $f(-24,4) = -528$ (minimum)
Example 4: Three-Variable Optimization
Find the extremum of $f(x,y,z) = x^2 + y^2 + z^2$ subject to $x + 2y - 4z = 42$
- Form Lagrangian: \[ L(x,y,z,\lambda) = x^2 + y^2 + z^2 - \lambda(x + 2y - 4z - 42) \]
- Find partial derivatives: \[ L_x = 2x - \lambda = 0 \] \[ L_y = 2y - 2\lambda = 0 \] \[ L_z = 2z + 4\lambda = 0 \] \[ L_\lambda = -(x + 2y - 4z - 42) = 0 \]
- Solve system: \[ x = \frac{\lambda}{2}, y = \lambda, z = -2\lambda \] \[ \frac{\lambda}{2} + 2\lambda + 8\lambda = 42 \] \[ \frac{21}{2}\lambda = 42 \implies \lambda = 4 \]
- Solution: $x = 2$, $y = 4$, $z = -8$
- Evaluate: $f(2,4,-8) = 84$ (minimum)
Extreme Value Theorem
Examples: Extreme Value Theorem
- Interior: $f_x=1,f_y=1$ never zero, so no interior critical points.
- Boundary edges:
- $x=0,\;0\le y\le1:\;f=y$, min $0$ at $(0,0)$, max $1$ at $(0,1)$.
- $x=1,\;0\le y\le1:\;f=1+y$, min $1$ at $(1,0)$, max $2$ at $(1,1)$.
- $y=0,\;0\le x\le1:\;f=x$, same as $x=0$ edge.
- $y=1,\;0\le x\le1:\;f=x+1$, same as $x=1$ edge.
- Compare: absolute minimum $0$ at $(0,0)$; absolute maximum $2$ at $(1,1)$.
Interactive Visualizations
Common Mistakes to Avoid
1. Forgetting to Check Boundary Points
When using the Extreme Value Theorem, students often:
- Only find interior critical points
- Forget to check endpoints or corners
- Miss absolute extrema on boundaries
2. Issues with Lagrange Multipliers
- Writing incorrect constraint equations
- Forgetting to set $L_\lambda = 0$
- Not verifying solutions satisfy the constraint
3. Sign Errors in D-Test
- Mixing up conditions for max/min
- Forgetting to check $f_{xx}$ sign when $D > 0$
- Incorrect computation of $f_{xy}$ terms
Real-World Applications
1. Economics & Business
Maximize profit subject to budget constraints:
where:
- $x,y$ are quantities of products
- $p,q$ are unit prices
- $ax + by = c$ is the budget constraint
2. Engineering Design
Minimize material cost for cylindrical container:
where:
- $r$ is radius, $h$ is height
- $A$ is surface area (cost)
- $V$ is required volume
3. Physics
Find minimum potential energy in mechanical systems:
Summary
- Find critical points via $f_x=f_y=0$.
- Apply D-Test to classify local extrema.
- Use Lagrange multipliers for constraints.
- Check boundaries when using the Extreme Value Theorem.