Preview

A lesson from Essential Calculus for ML

£29/month

£29/month£29/month or £249/year · 30-day money-back guarantee

Get full access

Our content is best on a larger screen

Critical points of a function of two variables

The gradient at a local extremum

Explanation

For a function of one variable, a critical point is an input cc in the domain of ff where f′(c)=0f'(c) = 0 or f′(c)f'(c) does not exist, and every local maximum or minimum occurs at one. We now carry both ideas over to a function f(x,y)f(x,y) of two variables.

Local maximum and local minimum

Definition

Let (a,b)(a,b) be a point in the domain of ff. Then:

  • ff has a local maximum at (a,b)(a,b) if f(a,b)≥f(x,y)f(a,b) \ge f(x,y) for every point (x,y)(x,y) within some distance of (a,b)(a,b).
  • ff has a local minimum at (a,b)(a,b) if f(a,b)≤f(x,y)f(a,b) \le f(x,y) for every point (x,y)(x,y) within some distance of (a,b)(a,b).

Either is a local extremum.

To find where a local extremum can occur, we replace f′f' with the gradient ∇f\nabla f, whose entries are the partial derivatives fxf_x and fyf_y.

Theorem

If ff has a local extremum at (a,b)(a,b), then

∇f(a,b)=[fx(a,b)fy(a,b)]=0⃗,\nabla f(a,b) = \begin{bmatrix} f_x(a,b) \\ f_y(a,b) \end{bmatrix} = \vec{0},

or fx(a,b)f_x(a,b) or fy(a,b)f_y(a,b) does not exist. A point (a,b)(a,b) in the domain of ff where this holds is a critical point of ff.

This is the one-variable result in two variables: the critical points are the candidates for local extrema. The converse is false: a critical point need not be a local extremum.

x
y
z

Step 1: A local minimum

The surface z=f(x,y)=x2+y2 has a local minimum at the origin, the black point: f(x,y)≥0=f(0,0) for every (x,y).

Drag the scene to rotate it.

Step 2: The cross-section at y=0

The grey plane y=0 cuts the surface in the curve z=f(x,0)=x2, a function of x alone. Near x=0, its points are points of the surface near the origin, so the curve also has a local minimum at x=0. Its derivative there is fx(0,0), so

fx(0,0)=0

Drag the scene to rotate it.

Step 3: The cross-section at x=0

The grey plane x=0 cuts the surface in the curve z=f(0,y)=y2, a function of y alone with a local minimum at y=0 in the same way, so

fy(0,0)=0

Drag the scene to rotate it.

Step 4: The gradient at the point

Both partial derivatives at the origin are zero, so ∇f(0,0)=0→. The same holds at any local extremum where both partial derivatives exist: each cross-section has a local extremum there, so each partial derivative is zero.

Drag the scene to rotate it.

ML Context

Training a neural network adjusts its weights to make its loss LL small, aiming for a local minimum. At a local minimum where the partial derivatives of LL exist, ∇L=0⃗\nabla L = \vec{0}.

Practice questions

4 questions

A function ff has a local maximum at (3,−1)(3,-1), and both partial derivatives exist there. What are fx(3,−1)f_x(3,-1) and fy(3,−1)f_y(3,-1)?

Select the correct answer:

+ 3 more questions · unlocked with a subscription

Finding critical points

Explanation

For a function of one variable, we find the critical points where f′f' exists by solving f′(x)=0f'(x) = 0. For a function f(x,y)f(x,y) whose partial derivatives exist everywhere, a critical point is a point where

∇f(x,y)=[fx(x,y)fy(x,y)]=0⃗.\nabla f(x,y) = \begin{bmatrix} f_x(x,y) \\ f_y(x,y) \end{bmatrix} = \vec{0}.

Both entries must be zero at the same point, so fx=0f_x = 0 and fy=0f_y = 0 form one system in xx and yy. An equation that contains only one variable is solved on its own. When both equations contain both variables and are linear, we solve the system by substitution.

Finding the critical points of f(x,y)f(x,y)

Procedure

  1. Compute fxf_x and fyf_y, and set both equal to 00.
  2. Solve an equation that contains only one variable. If neither does, rearrange one equation for one variable and substitute into the other.
  3. Find the other coordinate. If the other equation contains only one variable, solve it on its own; otherwise, substitute each value found into an equation that contains both variables.
  4. Report each solution as a point (a,b)(a,b).

Example

Find every critical point of f(x,y)=2x2+2xy+y2−2xf(x,y) = 2x^2 + 2xy + y^2 - 2x.

Solution

  1. The critical points are where ∇f=0⃗\nabla f = \vec{0}, so we differentiate with respect to one variable while the other is held fixed, and set both partial derivatives equal to 00:

    fx=4x+2y−2=0,fy=2x+2y=0.\begin{align*} f_x &= 4x + 2y - 2 = 0, \\ f_y &= 2x + 2y = 0. \end{align*}
  2. Both equations contain both variables, and both are linear, so we use substitution. The second equation rearranges to

    y=−x.y = -x.

    Substituting y=−xy = -x into the first equation:

    4x+2(−x)−2=02x−2=0x=1.\begin{align*} 4x + 2(-x) - 2 &= 0 \\ 2x - 2 &= 0 \\ x &= 1. \end{align*}
  3. Substituting x=1x = 1 into the rearranged second equation, y=−xy = -x, gives y=−1y = -1.

  4. The system has one solution, so ff has one critical point, (1,−1)(1,-1).

Practice questions

4 questions

Find every critical point of f(x,y)=x2+y2−6x+4yf(x,y) = x^2 + y^2 - 6x + 4y.

Select the correct answer:

+ 3 more questions · unlocked with a subscription

Critical points when an equation factors

Explanation

Solving fx=0f_x = 0, fy=0f_y = 0 by substitution works when the equations are linear. When they are not, one of them often factors, either into factors in different variables, such as 2x(y−2)2x(y - 2), or into factors in one variable, such as 3(x−1)(x+1)3(x - 1)(x + 1).

By the zero product property, a product is zero exactly when at least one of its factors is zero. So setting each factor equal to 00 splits the equation into cases, and each case is substituted into the other equation. A case can give several points or none, so every case is solved.

Finding critical points when an equation factors

Procedure

  1. Compute fxf_x and fyf_y, and set both equal to 00.
  2. Factor one equation, and set each factor equal to 00 to list the cases.
  3. Substitute each case into the other equation, and solve for the remaining variable.
  4. Collect the points from every case.

Example

Find every critical point of f(x,y)=x2y−2x2−y33−5yf(x,y) = x^2y - 2x^2 - \dfrac{y^3}{3} - 5y.

Solution

  1. The critical points are where ∇f=0⃗\nabla f = \vec{0}, so we differentiate with respect to one variable while the other is held fixed, and set both partial derivatives equal to 00:

    fx=2xy−4x=0,fy=x2−y2−5=0.\begin{align*} f_x &= 2xy - 4x = 0, \\ f_y &= x^2 - y^2 - 5 = 0. \end{align*}
  2. The first equation has the common factor 2x2x:

    2x(y−2)=0.2x(y - 2) = 0.

    By the zero product property, 2x=02x = 0 or y−2=0y - 2 = 0, so the cases are x=0x = 0 and y=2y = 2.

  3. In the case x=0x = 0, the second equation becomes

    −y2−5=0y2=−5.\begin{align*} -y^2 - 5 &= 0 \\ y^2 &= -5. \end{align*}

    No real number has a negative square, so this case gives no point.

    In the case y=2y = 2, the second equation becomes

    x2−9=0x2=9,\begin{align*} x^2 - 9 &= 0 \\ x^2 &= 9, \end{align*}

    so x=3x = 3 or x=−3x = -3. This case gives the points (3,2)(3,2) and (−3,2)(-3,2).

  4. Collecting the points from both cases, ff has two critical points: (3,2)(3,2) and (−3,2)(-3,2).

Practice questions

6 questions

Find every critical point of f(x,y)=x3−3x+y2−4yf(x,y) = x^3 - 3x + y^2 - 4y.

Select the correct answer:

+ 5 more questions · unlocked with a subscription

Memory is built by recalling, not by reading.

Every time you pull an answer from memory, the memory gets stronger. Reading doesn't do that. Nodeledge asks you questions on every step of every lesson, then asks again after days, weeks and months.

Get full access

£29/month or £249/year · 30-day money-back guarantee

See the learning path