Contact Us!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

| Download
Views: 63
Image: ubuntu2204
Kernel: SageMath 10.1

Extreme Values, Lagrange Multiplier and Taylor's Formula for Two Variables

Extreme Values and Saddle Points

Derivative tests for local extreme values

Definition Let f(x,y)f(x, y) be defined on a region RR containing the point (a,b)(a, b). Then

  • f(a,b)f(a, b) is a local maximum value of ff if f(a,b)f(x,y)f(a, b) \geq f(x, y) for all domain points (x,y)(x, y) in an open disk centered at (a,b)(a, b).

  • f(a,b)f(a, b) is a local minimum value of ff if f(a,b)f(x,y)f(a, b) \leq f(x, y) for all domain points (x,y)(x, y) in an open disk centered at (a,b)(a, b).

Theorem(Theorem 10)

If f(x,y)f(x, y) has a local maximum or minimum value at an interior point (a,b)(a, b) and if the first partial derivatives exist there, then fx(a,b)=0f_x(a, b) = 0 and fy(a,b)=0f_y(a, b) = 0.

Critical Points and Saddle Points

Definition (Critical Point)

critical point of ff: interior point of f(x,y)f(x, y) where both fx=fy=0f_x=f_y=0 or where one or both of fxf_x and fyf_y do not exist.

Definition (Saddle Point)

saddle point (a,b,f(a,b))(a, b, f(a,b)) of the surface z=f(x,y)z = f(x, y): in every open disk centered at a critical point (a,b)(a, b) there are domain points (x,y)(x, y) where f(x,y)>f(a,b)f(x, y) > f(a, b) and domain points (x,y)(x, y) where f(x,y)<f(a,b)f(x, y) < f(a, b).

Example

Find the local extreme values of f(x,y)=y2x2f(x, y) = y^2-x^2

Solution:

The domain of ƒƒ is the entire plane (so there are no boundary points) and the partial derivatives fx=2xf_x = -2x and fy=2yf_y = 2y exist everywhere. Therefore, local extrema can occur only at the origin (0, 0) where fx=0f_x = 0 and fy=0f_y = 0. Along the positive xx-axis, however, ff has the value f(x,0)=x2<0f(x, 0) = -x^2 < 0; along the positive yy-axis, ff has the value ƒ(0,y)=y2>0ƒ(0, y) = y^2 > 0. Therefore, every open disk in the xy-plane centered at (0, 0) contains points where the function is positive and points where it is negative. The function has a saddle point at the origin and no local extreme values.

var('x', 'y') plot3d(y^2-x^2, (x,-1,1), (y,-1,1))

Example

Find the local extreme values of f(x,y)=x2+y24y+9f(x, y) = x^2 + y^2 - 4y + 9.

Solution:

The domain of ƒ is the entire plane (so there are no boundary points) and the partial derivatives fx=2xf_x = 2x and fy=2y4f_y = 2y - 4 exist everywhere. Therefore, local extreme values can occur only where fx=2x=0,fy=2y4=0.f_x = 2x = 0 , f_y = 2y - 4 = 0. The only possibility is the point (0,2)(0, 2), where the value of ff is 5. Since f(x,y)=x2+(y2)2+5f(x, y) =x^2 + (y - 2)^2 + 5 is never less than 5, we see that the critical point (0, 2) gives a local minimum.

reset() var('x', 'y') f(x,y) = x^2+(y-2)^2+5 def c(x, y): return float(f(x,y)/1.4) p2 = plot3d(f(x,y), (x,-2,2), (y,-2,2), color=(c, colormaps.hsv)) p2c = contour_plot(f(x,y), (x,-10,10), (y,-10,10), fill = False, plot_points = 150, cmap = 'hsv', labels = True) p2c.show()
Image in a Jupyter notebook

Second derivative test for local extreme values

Suppose that f(x,y)f(x, y) and its first and second partial derivatives are continuous throughout a disk centered at (a,b)(a, b) and that fx(a,b)=fy(a,b)=0f_x(a, b) = f_y(a, b) = 0. Then

  • ff has a saddle point at (a,b)(a, b) if fxxfyyfxy2<0f_{xx} f_{yy} - f_{xy}^2 < 0 at (a,b)(a, b).

  • ff has a local maximum at (a,b)(a, b) if fxxfyyfxy2>0f_{xx} f_{yy} - f_{xy}^2>0 and fxx<0f_{xx}< 0 at (a,b)(a, b).

  • ff has a local minimum at (a,b)(a, b) if fxxfyyfxy2>0f_{xx} f_{yy} - f_{xy}^2> 0 and fxx>0f_{xx}> 0 at (a,b)(a, b).

  • the test is inconclusive at (a,b)(a, b) if fxxfyyfxy2=0f_{xx} f_{yy} - f_{xy}^2 = 0 at (a,b)(a, b). In this case, we must find another way to determine the behavior of ff at (a,b)(a, b).

Example

Find the local extreme values of f(x,y)=xyx2y22x2y+4.f(x,y)=xy-x^2-y^2-2x-2y+4.

var('x,y') f(x,y) = x*y - x^2 - y^2 -2*x -2*y +4 fx = f.diff(x) fy = f.diff(y) print("solve fx = 0 and fy = 0 to find the point(s) where f may take on an extreme value:") sol = solve([fx == 0, fy == 0], x, y) show(sol) x0 = sol[0][0].rhs() # get the point (x0,y0) from the solution of fx =0, fy = 0 y0 = sol[0][1].rhs() fxx(x,y) = fx.diff(x) fyy(x,y) = fy.diff(y) fxy(x,y) = fx.diff(y) print("The discriminant of f at (x0, y0) is: ") show(fxx(x0,y0)*fyy(x0,y0)-(fxy(x0,y0))^2) print("fxx is:") show(fxx(x0,y0)) print("The value of f at (x0,y0):") show(f(x0,y0)) def c(x, y): return float(f(x,y)/1.4) p2c = contour_plot(f(x,y), (x,-5,0), (y,-5,0), fill = False, plot_points = 150, cmap = 'hsv', labels = True) p2c.show()
solve fx = 0 and fy = 0 to find the point(s) where f may take on an extreme value:

[[x=(2),y=(2)]]\displaystyle \left[\left[x = \left(-2\right), y = \left(-2\right)\right]\right]

The discriminant of f at (x0, y0) is:

3\displaystyle 3

fxx is:

2\displaystyle -2

The value of f at (x0,y0):

8\displaystyle 8

Image in a Jupyter notebook

According to second derivative test for local extreme values, ff has a local maximum at (-2,-2). The value of ff at this point is 8.

Absolute maxima and minima on closed bounded regions

  • Check critical points

  • Check boundary points

  • Compare values.

Example

Find the absolute maximum and minimum values of f(x,y)=2+2x+4yx2y2f(x,y)=2+2x+4y-x^2-y^2 on the triangular region bounded by the lines x=0x=0, y=0y=0, and y=9xy=9-x.

Solution

  1. Interior points. For these we have fx=22x=0,fy=42y=0f_x = 2 - 2x = 0, f_y = 4 - 2y = 0, yielding the single point (x,y)=(1,2)(x, y) = (1, 2). The value of ƒƒ there is ƒ(1,2)=7ƒ(1, 2) = 7.

  2. Boundary points. Boundary points. We take the triangle one side at a time:

  • On the segment OAOA, y=0y = 0. The function f(x,y)=f(x,0)=2+2xx2f(x, y) = f(x, 0) = 2 + 2x - x2 may now be regarded as a function of x defined on the closed interval 0<=x<=90 <= x <= 9. Its extreme values (we know from Chapter 4) may occur at the endpoints x=0x = 0 where f(0,0)=2f(0, 0) = 2, x=9wheref(9,0)=2+1881=61x = 9 where f(9, 0) = 2 + 18 - 81 = -61 and at the interior points where f(x,0)=22x=0f′(x, 0) = 2 - 2x = 0. The only interior point where f(x,0)=0f′(x, 0) = 0 is x=1x = 1, where f(x,0)=f(1,0)=3f(x, 0) = f(1, 0) = 3.

  • On the segment OBOB, x=0x = 0 and f(x,y)=f(0,y)=2+4yy2f(x, y) = f(0, y) = 2 + 4y - y2 the interior point where f(0,y)=0f′(0, y) = 0 occurs at (0, 2), with f(0,2)=6f(0, 2) = 6. So the candidates for this segment are f(0,0)=2,f(0,9)=43,f(0,2)=6f(0, 0) = 2, f(0, 9) = -43, f(0, 2) = 6.

  • We have already accounted for the values of ff at the endpoints of ABAB, so we need only look at the interior points of the line segment ABAB. With y=9xy = 9 - x, we have f(x,y)=2+2x+4(9x)x2(9x)2=43+16x2x2f(x, y) = 2 + 2x + 4(9 - x) - x^2 - (9 - x)^ 2 = -43 + 16x - 2x^2 Setting f(x,9x)=164x=0f′(x, 9 - x) = 16 - 4x = 0 gives x=4x = 4. At this value of xx, y=94=5y = 9 - 4 = 5 and f(x,y)=f(4,5)=11f(x, y) = f(4, 5) = -11.

  1. summary We list all the function value candidates: 7, 2, -61, 3, -43, 6, -11. The maximum is 7, which ƒ assumes at (1, 2). The minimum is -61, which ƒ assumes at (9, 0).

reset() var('x', 'y') f(x,y) = 2+2*x+4*y-x^2-y^2 def c(x, y): return float(f(x,y)/1.4) p2 = plot3d(f(x,y), (x,-2,2), (y,-2,2), color=(c, colormaps.hsv)) p2c = contour_plot(f(x,y), (x,0,9), (y,0,9), fill = False, plot_points = 100, cmap = 'hsv', labels = True) p2c += line(((0,9),(9,0))) p2c.show()
Image in a Jupyter notebook

Lagrange Multipliers

Constrained maxima and minima

Find point P(x,y,z)P(x,y,z) on the hyperbolic cylinder x2z21=0x^2-z^2-1=0 closest to the origin.

The orthogonal gradient theorem

Suppose that f(x,y,z)f(x, y, z) is differentiable in a region whose interior contains a smooth curve C:r(t)=x(t)i+y(t)j+z(t)k.C: \vec{r}(t) = x(t)\vec{i} + y(t)\vec{j} + z(t)\vec{k}. If P0P_0 is a point on CC where ff has a local maximum or minimum relative to its values on CC, then f\nabla f is orthogonal to CC at P0P_0.

The method of Lagrange multipliers

Suppose that f(x,y,z)f(x, y, z) and g(x,y,z)g(x, y, z) are differentiable and g0\nabla g \neq 0 when g(x,y,z)=0g(x, y, z) = 0. To find the local maximum and minimum values of ff subject to the constraint g(x,y,z)=0g(x, y, z) = 0 (if these exist), find the values of x,y,z,x, y, z, and λ\lambda that simultaneously satisfy the equations f=λgandg(x,y,z)=0.\nabla f =\lambda \nabla g \qquad {and} \qquad g(x, y, z) = 0.

Example

Find the greatest and smallest values of f(x,y)=xyf(x,y)=xy takes on the ellipse x28+y22=1.{x^2\over 8}+{y^2\over 2}=1.

Lagrange multipliers with two constraints

Find the extreme values of a differentiable function ƒ(x,y,z)ƒ(x, y, z) whose variables are subject to two constraints. If the constraints are g1(x,y,z)=0g_1(x, y, z) = 0 and g2(x,y,z)=0g_2(x, y, z) = 0 and g1g_1 and g2g_2 are differentiable, with g1\nabla g_1 not parallel to g2\nabla g_2, we find the constrained local maxima and minima of ƒƒ by introducing two Lagrange multipliers λ\lambda and μ\mu. is, we locate the points P(x,y,z)P(x, y, z) where ƒƒ takes on its constrained extreme values by finding the values of x,y,z,λ,x, y, z, \lambda, and μ\mu that simultaneously satisfy the three equations f=λg1+μg2,g1(x,y,z)=0,g2(x,y,z)=0\nabla f =\lambda \nabla g_1+ \mu \nabla g_2,\qquad g_1(x,y,z)=0,\qquad g_2(x,y,z)=0

Taylor's Formula for Two Variables