18.02A Topic 28: Max-min problems, least squares.Author: Jeremy OrloffRead: TB: 19.7, SN: LSStandard calculus question:Given z = f(x, y) where are the (relative) maxima and minima?Answer: At the points where ∇f = h0, 0i.I.e.∂f∂x= 0 and∂f∂y= 0.Critical points: Such points are called critical points.Example: z = x2+ y2∇z = h2x, 2yi ⇒ only critical point is (0, 0). Clearly a minimum.Example: z = −x2− y2∇z = h−2x, −2yi ⇒ only critical point is (0, 0).Clearly a maximum.Example: z = y2− x2∇z = h−2x, 2yi ⇒ only critical point is (0, 0).Clearly neither maximum or minimum.Critical point = horizontal tangent planeEquation of tangent plane at (x0, y0, z0) (z0= f(x0, y0)) is(z − z0) =∂f∂x(x0,y0)(x − x0) +∂f∂y(x0,y0)(y − y0).At a critical point this becomes: z − z0= 0 = horizontal plane.Example: Making a box.Sides double thick, bottom triple thick, no top, volume = 3.What dimensions use the least amount of cardboard?Area of one side = yz, two sides, double thick ⇒ cardboard used = 4yz.Area front (and back) = xz, single thick ⇒ cardboard used = 2xz.Area bottom = xy, triple thick ⇒ cardboard used = 3xy.Total cardboard used = w = 4yz + 2xz + 3xy.Volume = 3 = xyz ⇒ z =3xy⇒ w =12x+6y+ 3xyCritical points: wx= −12x2+ 3y = 0, wy= −6y2+ 3x = 0wx= 0 ⇒ y =4x2wy= 0 ⇒ −616x4+ 3x = 0⇒ x = 2, y = 1, z = 3/2.Clearly a minimum. (physically we know it must have a minimum somewhere, itcan’t be on the boundary (axes) because w is infinite there ⇒ only critical pointmust be a minimum.(continued)118.02A topic 28 2Least squares You should read §LS in the notes.Start with data points: (x1, y1), (x2, y2), . . . , (xn, yn).Try to fit a line, y = ax + b, to the data.The ’squared error sum’ is E(a, b) =Xi(yi− (axi+ b))2.The least squares fit is the line that minimizes E.To find the minimum we set∂E∂a= 0 and∂E∂b= 0.∂E∂a=X−2xi(yi− (axi+ b)) = 2Xiax2i+ bxi− xiyi= 0.∂E∂b=X−2xi(yi− (axi+ b) = 2Xiaxi+ b − yi= 0.This gives the least squares equations for a line:⇒ aXix2i+ bXixi=XixiyiaXixi+ b n =XyiExample: Use least squares to fit a line to the following data: (0,1), (2,1), (3,4).answer: In our case, (x1, y1) = (1, 1), (x2, y2) = (2, 1) and (x3, y3) = (3, 4).⇒Px2i= 13,Pxi= 5, n = 3,Pxiyi= 14,Pyi= 6.⇒ 13a + 5b = 14; 5a + 3b = 6 ⇒ a = 6/7 and b = 4/7.The least squares line has equation y =67x +47.Example: For the same points as above, use least squares to fit a parabola.answer: A parabola has the formula y = ax2+ bx + c.Squared error = E(a, b, c) =X(yi− (ax2i+ bxi+ c))2.The least squares fit minimizes E ⇒∂E∂a=∂E∂b=∂E∂c= 0:⇒ aXx4i+ bXx3i+ cXx2i=Xx2iyiaXx3i+ bXx2i+ cXxi=XxiyiaXx2i+ bXxi+ c n =XyiPlugging in our points:Px4i= 97,Px3i= 35,Px2i= 13,Pxi= 5, n = 3.Px2iyi= 40,Pxiyi= 14,Pyi= 6.⇒ 97a + 35b + 13c = 4035a + 13b + 5c = 1413a + 5b + 3c = 6.Solving ⇒ a = 1, b = −2, c = 1.The least squares parabola has equation y = x2− 2x + 1.Note: for 3 points the fit is perfect.xy• ••Least squares lineand
View Full Document