LECTURE 9: LAGRANGE MULTIPLIERS MINGFENG ZHAO January 23, 2015 Polar coordinates For the point (x, y) 6= (0, 0) in the xy-plane, let r = |(x, y)| and θ be the angle between x-axis and the vector from (0, 0) to (x, y), then we have x = r cos(θ), and y = r sin(θ), which is called the Polar coordinates. Figure 1. Polar coordinates in the plane Remark 1. For the ellipse x2 y2 + = 1, we can use the following polar coordinates: a2 b2 x = a cos(θ), and y = b sin(θ), Gradient 1 for all 0 ≤ θ ≤ 2π. 2 MINGFENG ZHAO Definition 1. The gradient of a function f (x, y, z) at point (a, b, c), denoted by ∇f (x, y, z) is defined as: ∇f (a, b, c) = hfx (a, b, c), fy (a, b, c), fz (a, b, c)i. Remark 2. A critical point is just a point such that the gradient at this points equals zero vector. Example 1. Let f (x, y) = ln(xy + sin(y)), compute the gradient of f (x, y). In fact, we have fx (x, y) 1 · y By the chain rule xy + sin(y) y xy + sin(y) 1 · cos(y) By the chain rule xy + sin(y) = = fy (x, y) = cos(y) . xy + sin(y) = So we have ∇f (x, y) = y cos(y) , xy + sin(y) xy + sin(y) . Example 2. Let f (x, y, z) = x2 + 2y 2 + 4z 2 − 1, compute the gradient of f (x, y, z) at point (0, 1, 2). In fact, we have fx = 2x, fy = 4y, and fz = 8z. Then ∇f (x, y, z) = h2x, 4y, 8zi. So we get ∇f (0, 1, 2) = h0, 4, 16i. Lagrange multipliers Consider the optimization problem: max / min f (x, y) −→ g(x, y) = 0 Method of Lagrange Multipliers: −→ objective function constraint. LECTURE 9: LAGRANGE MULTIPLIERS 3 If ∇g(x, y) 6= 0 for all (x, y) such that g(x, y) = 0, to find the maximum and minimum values of f (x, y) subject to the constraint g(x, y) = 0, we have two steps: Step 1. Find the values of x, y and λ such that ∇f (x, y) = λ∇g(x, y), and g(x, y) = 0. Step 2. Among the points (x, y) found in Step 1, select the largest and smallest corresponding function values. These values are the maximum and minimum values of f (x, y) subject to the constraint g(x, y) = 0. Remark 3. For the above Step 1, we can define the function h(x, y, λ) = f (x, y) − λg(x, y) which is a function of three variables x, y and λ, to find values in Step 1, we only need to find critical points of h(x, y, λ), that is, we need to solve the following system: ∇h(x, y, λ) = 0. Remark 4. For solving ∇h(x, y, λ) = 0, fist, you should check whether λ = 0 or not. Usually, λ 6= 0 Example 3. Find the maximum and minimum values of the objective function f (x, y) = 2x2 + y 2 + 2, where x and y lie on the ellipse C given by g(x, y) = x2 + 4y 2 − 4 = 0. Step 1: Let’s compute the gradients of f and g, we have ∇f (x, y) = h4x, 2yi, and ∇g(x, y) = h2x, 8yi. Let’s solve the system: ∇f (x, y) = λ∇g(x, y), and g(x, y) = 0. That is, (1) 4x = λ · (2x) = 2λx (2) 2y = λ · (8y) = 8λy (3) x2 + 4y 2 − 4 = 0 It’s easy to see that λ 6= 0, otherwise, by (1) and (2), we have x = y = 0, which does not satisfy (3). By (1) and (2), we have 4x(8λy) = 2λx(2y). 4 MINGFENG ZHAO Since λ 6= 0, then 32xy = 4xy, that is, xy = 0. So either x = 0 or y = 0. When x = 0, plug x = 0 into (3), we get 4y 2 − 4 = 0, that is, y 2 = 1, so y = 1 or y = −1. By (2), we have λ = 41 . So we have two solutions 1 (x, y, λ) = 0, 1, , 4 and (x, y, λ) = 1 0, −1, 4 . When y = 0, plug y = 0 into (3), we get x2 − 4 = 0, then x = 2 or x = −2. By (1), we have λ = 2. So we have two solutions: (x, y, λ) = (2, 0, 2) , and In summary, we have four solutions: 1 1 , (x, y, λ) = 0, −1, , (x, y, λ) = 0, 1, 4 4 (x, y, λ) = (−2, 0, 2) . (x, y, λ) = (2, 0, 2) , and (x, y, λ) = (−2, 0, 2) . Step 2: Compute the values of f (x, y) on the above points, we have f (0, 1) f (0, −1) f (2, 0) f (−2, 0) = 2 · 02 + 12 + 2 = 3 = 2 · 02 + (−1)2 + 2 = 3 = 2 · 22 + 02 + 2 = 10 = 2 · (−2)2 + 02 + 2 = 10. In summary, the minimum values of f (x, y) subject to the constraint g(x, y) = 0 is 3 = f (0, 1) = f (0, −1), and the maximum values of f (x, y) subject to the constraint g(x, y) = 0 is 10 = f (2, 0) = f (−2, 0). Department of Mathematics, The University of British Columbia, Room 121, 1984 Mathematics Road, Vancouver, B.C. Canada V6T 1Z2 E-mail address: mingfeng@math.ubc.ca