Example 2. Find the maximum and minimum values of the function $z=f(x, y)=x^{3}+y^{3}+6 x y \quad$ in the rectangle with vertices $A(-3,-3), B(-3,2), C(1,2), D(1,-3)$.
Solution. We take the partial derivatives of the given function:

$$
f_{x}^{\prime}(x, y)=3 x^{2}+6 y ; f_{y}^{\prime}(x, y)=3 y^{2}+6 x
$$

From the system of equations

$$
\left.\left.\begin{array}{c}
3 x^{2}+6 y=0 \\
3 y^{2}+6 x=0
\end{array}\right\} \text { or } \begin{array}{r}
x^{2}+2 y=0 \\
y^{2}+2 x=0
\end{array}\right\}
$$

we find two critical points $M_{1}(0,0), M_{2}(-2,-2)$, both of which belong to the rectangle $A B C D$ (Fig. 8.1).

We calculate the values of the function at these points:

$$
z_{1}=f(0,0)=0, z_{2}=f(-2,-2)=8
$$

![](https://cdn.mathpix.com/cropped/2024_05_22_7ef2114a321cf223ba99g-272.jpg?height=400&width=493&top_left_y=588&top_left_x=51)

Fig. 8.1

We find the maximum and minimum values of the function on the boundary of the rectangle $A B C D$. It is convenient to divide this boundary into four segments $A B, B C, C D, D A$, on each of which there may be critical points. In addition, we must take into account the endpoints of the segments, i.e., the points $A, B, C$ and $D$.

We look for critical points on the segment $A B$, the equation of which is $x=-3$, and $-3 \leq y \leq 2$. On this segment, the given function becomes a function of one variable $y$:

$$
z=f(-3, y)=-27+y^{3}-18 y ; z(y)=y^{3}-18 y-27
$$

The derivative of this function

$$
z^{\prime}=3 y^{2}-18
$$

is zero at $y=-\sqrt{6} \approx-2.45, y=\sqrt{6} \approx 2.45$. We will not consider the second value, as it does not belong to the segment $A B$, for which $-3 \leq y \leq 2$. We calculate the value of the function $z(y)$ at $y=-\sqrt{6}$:

$$
\begin{gathered}
z_{3}=z(-\sqrt{6})=(-\sqrt{6})^{3}-18(-\sqrt{6})-27=12 \sqrt{6}- \\
-27 \approx 2.4
\end{gathered}
$$

On the segment $B C \quad y=2(-3 \leq x \leq 1)$, therefore,

$$
z=f(x, 2)=x^{3}+8+12 x
$$

The function $z(x)=x^{3}+12 x+8$ has no critical points, as its derivative $z^{\prime}(x)=3 x^{2}+12$ does not equal zero.

On the segment $C D$, where $x=1(-3 \leq y \leq 2)$,

$$
z=f(1, y)=1+y^{3}+6 y
$$

there are also no critical points.

On the segment $D A \quad y=-3(-3 \leq x \leq 1)$, therefore

$$
z=f(x,-3)=x^{3}-27-18 x
$$

The function $z(x)=x^{3}-18 x-27$ has a critical point at $x=-\sqrt{6}$ (the point $x=\sqrt{6}$, where the derivative $z^{\prime}(x)=3 x^{2}-18$ also equals zero, does not belong to the segment $D A$).

We calculate the value of the function $z(x)$ at the point $x=-\sqrt{6}$:

$$
\begin{gathered}
z_{4}=z(-\sqrt{6})=(-\sqrt{6})^{3}-18(-\sqrt{6})-27= \\
=12 \sqrt{6}-27 \approx 2.4
\end{gathered}
$$

It remains to find the values of the function $z=f(x, y)=x^{3}+y^{3}+6 x y$ at the vertices $A, B, C, D$:

$$
\begin{gathered}
z_{5}=f(A)=f(-3,-3)=(-3)^{3}+(-3)^{3}+6(-3)(-3)=0 \\
z_{6}=f(B)=f(-3,2)=(-3)^{3}+2^{3}+6(-3) 2=-55 \\
z_{7}=f(C)=f(1,2)=1^{3}+2^{3}+6 \cdot 1 \cdot 2=21 \\
z_{8}=f(D)=f(1,-3)=1^{3}+(-3)^{3}+6(-3) 1=-44
\end{gathered}
$$

By comparing $z_{1}, z_{2}, z_{3}, z_{4}, z_{5}, z_{6}, z_{7}, z_{8}$, we conclude that the function $z=x^{3}+y^{3}+6 x y$ in the rectangle $A B C D$ reaches its minimum value, equal to -55, at point $B$, and its maximum value, equal to 21, at point $C$.