Lesson 11 of 18

Second Derivative Test

Critical Points and the Second Derivative Test

For a function f(x,y)f(x,y), critical points occur where f=0\nabla f = \mathbf{0} (both partial derivatives are zero).

The Discriminant

At a critical point (x0,y0)(x_0, y_0), classify it using:

D=fxxfyy(fxy)2D = f_{xx} \cdot f_{yy} - (f_{xy})^2

Where:

  • fxx=2f/x2f_{xx} = \partial^2 f / \partial x^2
  • fyy=2f/y2f_{yy} = \partial^2 f / \partial y^2
  • fxy=2f/xyf_{xy} = \partial^2 f / \partial x \partial y (mixed partial)

Classification Rules

DDfxxf_{xx}Type
D>0D > 0fxx>0f_{xx} > 0Local minimum
D>0D > 0fxx<0f_{xx} < 0Local maximum
D<0D < 0Saddle point
D=0D = 0Test inconclusive

Examples

f(x,y)=x2+y2f(x,y) = x^2 + y^2 at (0,0)(0,0):

  • fxx=2f_{xx} = 2, fyy=2f_{yy} = 2, fxy=0f_{xy} = 0
  • D=40=4>0D = 4 - 0 = 4 > 0, fxx>0f_{xx} > 0local minimum

f(x,y)=x2y2f(x,y) = x^2 - y^2 at (0,0)(0,0):

  • fxx=2f_{xx} = 2, fyy=2f_{yy} = -2, fxy=0f_{xy} = 0
  • D=4<0D = -4 < 0saddle point

f(x,y)=(x2+y2)f(x,y) = -(x^2 + y^2) at (0,0)(0,0):

  • fxx=2f_{xx} = -2, fyy=2f_{yy} = -2, fxy=0f_{xy} = 0
  • D=4>0D = 4 > 0, fxx<0f_{xx} < 0local maximum

Computing fxyf_{xy} Numerically

fxyf(x+h,y+h)f(x+h,yh)f(xh,y+h)+f(xh,yh)4h2f_{xy} \approx \frac{f(x+h,y+h) - f(x+h,y-h) - f(x-h,y+h) + f(x-h,y-h)}{4h^2}

Your Task

Implement double discriminant_2d(double (*f)(double, double), double x, double y, double h) that computes D=fxxfyyfxy2D = f_{xx} \cdot f_{yy} - f_{xy}^2.

TCC compiler loading...
Loading...
Click "Run" to execute your code.