Salta al contenuto
Note per Studenti Constrained Extrema and Lagrange Multipliers Report

Constrained Extrema and Lagrange Multipliers

In questa pagina 7

This note builds on Absolute Extrema on Compact SetsWeierstrass theorem: a continuous function on a compact (closed and bounded) subset of R^n has an absolute maximum and minimum. They are found by comparing the values at the interior critical points, at the critical points of the restrictions to the (parametrized) pieces of the boundary, and at the vertices. On an unbounded closed set, if f tends to +infinity at infinity the minimum exists and the maximum does not.Absolute Extrema on Compact Sets →, Implicit Function TheoremIf F is C^1, F(x0, y0) = 0 and F_y(x0, y0) is nonzero, near (x0, y0) the set F(x, y) = 0 is the graph of a unique C^1 function y = g(x), with g'(x) = -F_x/F_y (obtained by differentiating F(x, g(x)) = 0). The tangent line is orthogonal to grad F. Where F_y = 0 but F_x is nonzero one solves for x = h(y); where grad F = 0 the point is singular.Implicit Function Theorem → and Differentiability and the Gradientf is differentiable at x0 if f(x) = f(x0) + grad f(x0)·(x - x0) + o(‖x - x0‖), i.e. near x0 the graph is indistinguishable from the tangent plane z = f(x0) + grad f(x0)·(x - x0). Differentiable implies continuous, with partial derivatives and D_v f = grad f · v; continuous partial derivatives imply differentiable. The gradient gives the direction of steepest increase (slope ‖grad f‖) and is orthogonal to level curves.Differentiability and the Gradient →.

The problem of constrained optimization consists in finding the maximum or minimum points of a function f:A⊆Rn→Rf: A \subseteq \mathbb{R}^n \to \mathbb{R} considering only the points belonging to a subset defined by a constraint g(x1,…,xn)=cg(x_1, \dots, x_n) = c.

Elementary methods

Before introducing Lagrange's method, it is useful to recall the basic techniques for tackling the problem:

  1. Substitution: if the constraint g(x,y)=0g(x, y) = 0 can be solved explicitly (for instance y=h(x)y = h(x)), substitute the expression into the objective function obtaining f(x,h(x))f(x, h(x)). The problem reduces to finding maxima and minima of a one-variable function.
  2. Parametrization: if the constraint describes a curve γ(t)=(x(t),y(t))\gamma(t) = (x(t), y(t)), compose the objective function with the curve: f(γ(t))f(\gamma(t)). One then studies the extrema of f(x(t),y(t))f(x(t), y(t)) as the parameter tt varies.

These methods are often prohibitive in higher dimensions or when the constraint cannot easily be solved explicitly.

Example (parametrization). Extrema of f(x,y)=xyf(x, y) = xy on the circle x2+y2=1x^2 + y^2 = 1: with (cos⁡t,sin⁡t)(\cos t, \sin t) we get 12sin⁡2t\frac12\sin 2t, maximum 12\frac12 and minimum −12-\frac12 (worked out in Absolute Extrema on Compact SetsWeierstrass theorem: a continuous function on a compact (closed and bounded) subset of R^n has an absolute maximum and minimum. They are found by comparing the values at the interior critical points, at the critical points of the restrictions to the (parametrized) pieces of the boundary, and at the vertices. On an unbounded closed set, if f tends to +infinity at infinity the minimum exists and the maximum does not.Absolute Extrema on Compact Sets →). The same problem is solved below with Lagrange.

Geometric interpretation

Consider f(x,y)f(x, y) and the constraint g(x,y)=cg(x, y) = c. At a constrained extremum point (x0,y0)(x_0, y_0), the level curve of ff through that point must be tangent to the level curve of gg. If it were not, we could move along the constraint increasing or decreasing the value of ff, contradicting the extremum hypothesis. Since the gradient of a function is always orthogonal to its level curvethe set of points where the function takes the same value, the tangency of the two curves implies that the gradients ∇f\nabla f and ∇g\nabla g are parallel vectors.

Why, more precisely. If ∇g(P0)≠0\nabla g(P_0) \neq 0, by the implicit function theoremIf F is C^1, F(x0, y0) = 0 and F_y(x0, y0) is nonzero, near (x0, y0) the set F(x, y) = 0 is the graph of a unique C^1 function y = g(x), with g'(x) = -F_x/F_y (obtained by differentiating F(x, g(x)) = 0). The tangent line is orthogonal to grad F. Where F_y = 0 but F_x is nonzero one solves for x = h(y); where grad F = 0 the point is singular.Implicit Function Theorem → near P0P_0 the constraint is a regular curve γ(t)\gamma(t) with γ(0)=P0\gamma(0) = P_0. The one-variable function t↦f(γ(t))t \mapsto f(\gamma(t)) has an extremum at t=0t = 0, so its derivative is zero: ∇f(P0)⋅γ′(0)=0\nabla f(P_0) \cdot \gamma'(0) = 0. Also g(γ(t))=cg(\gamma(t)) = c is constant, so ∇g(P0)⋅γ′(0)=0\nabla g(P_0) \cdot \gamma'(0) = 0. In the plane two vectors both orthogonal to the same nonzero vector γ′(0)\gamma'(0) are parallel.

Lagrange multiplier theorem

Theorem. Let f,g:A⊆Rn→Rf, g: A \subseteq \mathbb{R}^n \to \mathbb{R} be functions of class C1C^1. Let P0P_0 be a local extremum point for ff constrained to g(x)=cg(x) = c. If ∇g(P0)≠0\nabla g(P_0) \neq 0, then there exists a real number λ\lambda (Lagrange multiplier) such that: ∇f(P0)=λ∇g(P0)\nabla f(P_0) = \lambda \nabla g(P_0)

Example. Maximum of f=xyf = xy with the constraint g=x+y=2g = x + y = 2: from ∇f=(y,x)=λ(1,1)\nabla f = (y, x) = \lambda (1, 1) it follows x=yx = y, so x=y=1x = y = 1 and f=1f = 1.

The hypothesis ∇g(P0)≠0\nabla g(P_0) \neq 0 (a regular point of the constraint) is needed to have a true curve around P0P_0. The points of the constraint where ∇g=0\nabla g = 0 must therefore be added separately to the list of candidates.

To solve the problem, define the Lagrangian functionan auxiliary function incorporating the constraint L(x,y,λ)=f(x,y)−λ(g(x,y)−c)\mathcal{L}(x, y, \lambda) = f(x, y) - \lambda(g(x, y) - c). Imposing ∇L=0\nabla \mathcal{L} = 0 (gradient with respect to xx, yy and λ\lambda) gives exactly the Lagrange conditions plus the constraint. The candidate extremum points are obtained by solving the system: {fx=λgxfy=λgyg(x,y)=c\begin{cases} f_x = \lambda g_x \\ f_y = \lambda g_y \\ g(x, y) = c \end{cases} These are three equations in three unknowns (xx, yy, λ\lambda). In nn variables they are n+1n + 1 equations in n+1n + 1 unknowns. The value of λ\lambda is usually of no interest: it serves only as an auxiliary unknown.

Example: minimum distance from the origin

Find the point on the hyperbola xy=3xy = 3 closest to the origin. The squared distance is f(x,y)=x2+y2f(x, y) = x^2 + y^2. The constraint is g(x,y)=xy=3g(x, y) = xy = 3.

  1. Compute the gradients: ∇f=(2x,2y)\nabla f = (2x, 2y), ∇g=(y,x)\nabla g = (y, x).
  2. Set up the system: {2x=λy2y=λxxy=3\begin{cases} 2x = \lambda y \\ 2y = \lambda x \\ xy = 3 \end{cases}
  3. From the first two: x=λy2x = \frac{\lambda y}{2}. Substituting into the second: 2y=λ(λy2)  ⟹  4y=λ2y2y = \lambda (\frac{\lambda y}{2}) \implies 4y = \lambda^2 y.
  4. If y=0y = 0, the constraint would give xy=0≠3xy = 0 \neq 3: impossible. So y≠0y \neq 0 and we can divide: λ2=4  ⟹  λ=±2\lambda^2 = 4 \implies \lambda = \pm 2.
    • If λ=2\lambda = 2: x=yx=y. From the constraint x2=3  ⟹  x=±3x^2 = 3 \implies x = \pm \sqrt{3}. Points: (3,3)(\sqrt{3}, \sqrt{3}) and (−3,−3)(-\sqrt{3}, -\sqrt{3}).
    • If λ=−2\lambda = -2: x=−yx=-y. From the constraint −x2=3-x^2 = 3 (impossible).
  5. ∇g=(y,x)\nabla g = (y, x) vanishes only at (0,0)(0, 0), which is not on the constraint: there are no singular points to add.

The candidates are (3,3)(\sqrt{3}, \sqrt{3}) and (−3,−3)(-\sqrt{3}, -\sqrt{3}), both with f=6f = 6. The hyperbola is not compact, so Weierstrass does not apply directly; but along the hyperbola, moving away, x2+y2→+∞x^2 + y^2 \to +\infty, so the minimum exists (as for functions tending to +∞+\infty on a closed set) and the maximum does not. The minimum distance from the origin is 6\sqrt6, attained at the two points found.

Grafico interattivo: The point of the hyperbola xy = 3 closest to the origin: the circle x² + y² = 6 (radius √6) is tangent to the hyperbola at (√3, √3) and at (−√3, −√3)

Example: xyxy on the circle

f(x,y)=xyf(x, y) = xy with the constraint g(x,y)=x2+y2=1g(x, y) = x^2 + y^2 = 1.

  1. ∇f=(y,x)\nabla f = (y, x), ∇g=(2x,2y)\nabla g = (2x, 2y), never zero on the circle.
  2. System: y=2λxy = 2\lambda x, x=2λyx = 2\lambda y, x2+y2=1x^2 + y^2 = 1.
  3. Substituting the first into the second: x=4λ2xx = 4\lambda^2 x. If x=0x = 0, from the first y=0y = 0, which is not on the constraint; so x≠0x \neq 0 and λ2=14\lambda^2 = \frac14, λ=±12\lambda = \pm\frac12.
    • λ=12\lambda = \frac12: y=xy = x, and 2x2=12x^2 = 1: points ±(12,12)\pm\left(\frac{1}{\sqrt2}, \frac{1}{\sqrt2}\right), with f=12f = \frac12.
    • λ=−12\lambda = -\frac12: y=−xy = -x: points ±(12,−12)\pm\left(\frac{1}{\sqrt2}, -\frac{1}{\sqrt2}\right), with f=−12f = -\frac12.
  4. The circle is compact and ff is continuous: the maximum and minimum exist and are among the candidates. Maximum 12\frac12, minimum −12-\frac12, as with the parametrization.

Grafico interattivo: f = xy on the circle x² + y² = 1: the level curves xy = ±1/2 are tangent to the circle at the extremum points, where grad f = (y, x) and grad g = (2x, 2y) are parallel (grad f = grad g / 2 at (1/√2, 1/√2)); the curve xy = 1/4 cuts the circle

Use with the Weierstrass theorem

If the constraint is a closed and bounded set, the Weierstrass theorem (Absolute Extrema on Compact SetsWeierstrass theorem: a continuous function on a compact (closed and bounded) subset of R^n has an absolute maximum and minimum. They are found by comparing the values at the interior critical points, at the critical points of the restrictions to the (parametrized) pieces of the boundary, and at the vertices. On an unbounded closed set, if f tends to +infinity at infinity the minimum exists and the maximum does not.Absolute Extrema on Compact Sets →) guarantees the existence of constrained maximum and minimum. Lagrange's method provides all the candidates among the regular points of the constraint; the points where ∇g=0\nabla g = 0 must be added and, if the constraint is an arc with endpoints, the two endpoints. The comparison of values decides.

The same method serves for the boundary of a domain in the search for absolute extrema: instead of parametrizing the circle x2+y2=1x^2 + y^2 = 1 one writes the Lagrange system with g=x2+y2g = x^2 + y^2.

Common mistakes

  • Confusion with free extrema: the Lagrange system looks for points where the gradient of ff is nonzero but only "balanced" by the gradient of the constraint. Do not look for the points where ∇f=0\nabla f = 0 unless they satisfy g=cg=c.
  • Nature of the points: the method does not say whether a point is a maximum or a minimum. One must compare the values of ff at all the points found.
  • Forgetting the constraint: always include the equation g(x,y)=cg(x, y) = c in the system; without it the system is underdetermined.
  • Dividing by zero in the system: before dividing by xx, yy or λ\lambda the case where they vanish must be treated separately (in the hyperbola example the case y=0y = 0).

Versione ripasso

Multiplier theorem. Let f,gf, g be of class C1C^1, and P0P_0 a local extremum of ff constrained to g=cg = c. If ∇g(P0)≠0\nabla g(P_0) \neq 0, there exists λ\lambda with ∇f(P0)=λ ∇g(P0)\nabla f(P_0) = \lambda\,\nabla g(P_0) Why: along the constraint γ(t)\gamma(t) with γ(0)=P0\gamma(0) = P_0 (it exists by the implicit function theorem), t↦f(γ(t))t \mapsto f(\gamma(t)) has an extremum at 00, so ∇f⋅γ′(0)=0\nabla f\cdot\gamma'(0) = 0; and ∇g⋅γ′(0)=0\nabla g\cdot\gamma'(0) = 0 because g(γ(t))=cg(\gamma(t)) = c. In the plane two vectors orthogonal to the same nonzero vector are parallel.

Lagrangian. L(x,y,λ)=f(x,y)−λ(g(x,y)−c)\mathcal L(x,y,\lambda) = f(x,y) - \lambda(g(x,y) - c). The system fx=λgx,fy=λgy,g(x,y)=cf_x = \lambda g_x, \qquad f_y = \lambda g_y, \qquad g(x,y) = c has three equations in three unknowns. The value of λ\lambda is not of interest in itself.

Elementary methods. One can substitute the constraint into ff (if one solves y=h(x)y = h(x)) or parametrize it as γ(t)\gamma(t) and study f(γ(t))f(\gamma(t)). Example: f=xyf = xy on the circle with (cos⁡t,sin⁡t)(\cos t, \sin t) gives 12sin⁡2t\frac12\sin 2t.

Example: minimum distance from the origin. Point of the hyperbola xy=3xy = 3 closest to the origin. With f=x2+y2f = x^2+y^2 and g=xyg = xy:

  • 2x=λy2x = \lambda y, 2y=λx2y = \lambda x, xy=3xy = 3.
  • From the first two, 4y=λ2y4y = \lambda^2 y. If y=0y = 0 the constraint is violated, so λ2=4\lambda^2 = 4.
  • λ=2\lambda = 2 gives x=yx = y and x2=3x^2 = 3: points ±(3,3)\pm(\sqrt3, \sqrt3), with f=6f = 6.
  • λ=−2\lambda = -2 gives −x2=3-x^2 = 3: impossible.

The constraint is not compact, but f→+∞f \to +\infty far from the origin: the minimum exists, the minimum distance is 6\sqrt6.

Example: xyxy on the circle. With ∇f=(y,x)\nabla f = (y,x), ∇g=(2x,2y)\nabla g = (2x,2y): y=2λxy = 2\lambda x, x=2λyx = 2\lambda y. If x=0x = 0 then y=0y = 0, not on the constraint; so λ2=14\lambda^2 = \frac14.

  • λ=12\lambda = \frac12: y=xy = x, points ±(12,12)\pm(\frac{1}{\sqrt2}, \frac{1}{\sqrt2}), with f=12f = \frac12 (maximum).
  • λ=−12\lambda = -\frac12: y=−xy = -x, points ±(12,−12)\pm(\frac{1}{\sqrt2}, -\frac{1}{\sqrt2}), with f=−12f = -\frac12 (minimum).

Procedure.

  1. Build the Lagrange system with g=cg = c.
  2. Solve, treating separately the cases where a variable is zero.
  3. Add the points of the constraint where ∇g=0\nabla g = 0 (Lagrange does not apply there) and, if the constraint is an arc, its endpoints.
  4. Compare the values of ff: the highest is the constrained maximum, the lowest the minimum.
  5. If the constraint is compact, Weierstrass (Absolute Extrema on Compact SetsWeierstrass theorem: a continuous function on a compact (closed and bounded) subset of R^n has an absolute maximum and minimum. They are found by comparing the values at the interior critical points, at the critical points of the restrictions to the (parametrized) pieces of the boundary, and at the vertices. On an unbounded closed set, if f tends to +infinity at infinity the minimum exists and the maximum does not.Absolute Extrema on Compact Sets →) guarantees that extrema exist and are among the candidates.

Typical mistakes.

  • Looking for the points with ∇f=0\nabla f = 0: here what matters is that ∇f\nabla f be parallel to ∇g\nabla g, not that it vanish.
  • Forgetting the constraint g=cg = c in the system: without it the system is underdetermined.
  • Thinking the method distinguishes maximum from minimum: it only finds candidates.
  • Dividing by xx, yy or λ\lambda without treating the zero case separately.

Teoria collegata