Example 2. Find the extremum of the function

$$
f(x, y)=x^{3}+3 x y^{2}-18 x^{2}-18 x y-18 y^{2}+57 x+138 y+290
$$
Solution. We find the first and second partial derivatives:

$$
\begin{gathered}
f_{x}^{\prime}(x, y)=3 x^{2}+3 y^{2}-36 x-18 y+57 \\
f_{y}^{\prime}(x, y)=6 x y-18 x-36 y+138 \\
f_{x x}^{\prime \prime}(x, y)=6 x-36 ; f_{x y}^{\prime \prime}(x, y)=6 y-18 ; f_{y y}^{\prime \prime}(x, y)=6 x-36
\end{gathered}
$$

By setting the first derivatives to zero, we obtain a system of equations to determine the critical points:

$$
\left.\begin{array}{c}
3 x^{2}+3 y^{2}-36 x-18 y+57=0 \\
6 x y-18 x-36 y+138=0
\end{array}\right\}
$$

or

$$
\left.\begin{array}{c}
x^{2}+y^{2}-12 x-6 y+19=0 \\
2 x y-6 x-12 y+46=0
\end{array}\right\}
$$

By adding these equations term by term, we get the equation

$$
x^{2}+y^{2}+2 x y-18 x-18 y+65=0
$$

which can be rewritten as

$$
(x+y)^{2}-18(x+y)+65=0
$$

This is a quadratic equation in terms of $(x+y)$, solving it, we find

$$
x+y=13, x+y=5
$$

By subtracting the second equation of system (A) from the first term by term, we get

$$
x^{2}-2 x y+y^{2}-6 x+6 y-27=0
$$

or

$$
(x-y)^{2}-6(x-y)-27=0
$$

from which

$$
x-y=9, x-y=-3
$$

Thus, for determining the critical points, we have four systems of equations:

$$
\left.\left.\left.\left.\begin{array}{r}
x+y=13 \\
x-y=9 ;
\end{array}\right\} \begin{array}{r}
x+y=13 ; \\
x-y=-3 ;
\end{array}\right\} \begin{array}{r}
x+y=5 ; \\
x-y=9 ;
\end{array}\right\} \begin{array}{r}
x+y=5 \\
x-y=-3
\end{array}\right\}
$$

Solving these systems, we find four critical points $M_{1}(11,2)$, $M_{2}(5,8), M_{3}(7,-2), M_{4}(1,4)$.

We compute the values of the second-order partial derivatives at these points:

$$
\begin{aligned}
& A_{1}=f_{x x}^{\prime \prime \prime}(11,2)=30, B_{1}=f_{x y}^{\prime \prime}(11,2)=-6, \quad C_{1}=f_{y y}^{\prime \prime}(11,2)=30 ; \\
& A_{2}=f_{x x}^{\prime \prime}(5,8)=-6, B_{2}=f_{x y}^{\prime \prime}(5,8)=30, \quad C_{2}=f_{y y}^{\prime \prime}(5,8)=-6 ; \\
& A_{3}=f_{x x}^{\prime \prime}(7,-2)=6, B_{3}=f_{x y}^{\prime \prime}(7,-2)=-30, \quad C_{3}=f_{y y}^{\prime \prime}(7,-2)=6 \\
& A_{4}=f_{x x}^{\prime \prime}(1,4)=-30, B_{4}=f_{x y}^{\prime \prime}(1,4)=6, \quad C_{4}=f_{y y}^{\prime \prime}(1,4)=-30
\end{aligned}
$$

and the values of the determinant (8.9):

$$
\Delta_{1}=A_{1} C_{1}-B_{1}^{2}=30 \cdot 30-(-6)^{2}=864
$$

$$
\begin{gathered}
\Delta_{2}=A_{2} C_{2}-B_{2}^{2}=(-6)(-6)-30^{2}=-864 \\
\Delta_{3}=A_{3} C_{3}-B_{3}^{2}=6 \cdot 6-(-30)^{2}=-864 \\
\Delta_{4}=A_{4} C_{4}-B_{4}^{2}=(-30)(-30)-6^{2}=864
\end{gathered}
$$

Since $\Delta_{2}<0$ and $\Delta_{4}>0$ and $A_{4}<0$, the point $M_{4}$ is a point of maximum, and

$$
\max f(x, y)=f(1,4)=19
$$

Since $\Delta_{1}>0$ and $A_{1}>0$, the point $M_{1}$ is a point of minimum, and

$$
\min f(x, y)=f(11,2)=10
$$

Since $\Delta_{2}<0$ and $\Delta_{3}<0$, the points $M_{2}$ and $M_{3}$ are saddle points.

## § 8.3. Maximum and Minimum Values of a Function

A function that is continuous in a bounded closed domain attains its maximum and minimum values either at critical points or at points lying on the boundary of the domain.

To find the maximum and minimum values of a function in a closed bounded domain, it is necessary to:

1. Find the critical points (lying inside the given domain) and compute the values of the function at these points.
2. Find the maximum (minimum) value of the function on the boundary of the domain.
3. Compare all the obtained values of the function: the largest (smallest) will be the maximum (minimum) value of the function in the given domain.

Remark 1. In this case, there is no need to investigate the function for extremum using second-order partial derivatives. It is necessary to find the critical points and the values of the function at these points.

Remark 2. For the function $z=f(x, y)$, the boundary of the domain consists of several arcs (segments), the equations of which are $y=f(x)$, where $a \leq x \leq b$ or $x=\varphi(y)$, where $c \leq y \leq d$, so on the corresponding arcs of the boundary, the given function becomes a function of one variable:

$$
z=f[x, f(x)]=z(x) \text { or } z=f[\varphi(y), y]=z(y) .
$$

If the boundary is given by parametric equations

$$
x=\varphi_{1}(t), y=\varphi_{2}(t)(\alpha \leq t \leq \beta)
$$

then the given function also becomes a function of one variable:

$$
z=f(x, y)=f\left[\varphi_{1}(t) ; \varphi_{2}(t)\right]=z(t)
$$