Example 8 If $(x, y)$ satisfies $x^{2}+x y+y^{2} \leqslant 1$, find the maximum and minimum values of $x-y+2 x y$.


Solution 1: Let $m=x-y, n=xy$, the condition is transformed into $m^{2}+3 n \leqslant 1$, and the target function $S=x-y+2xy=m+2n$. Substituting $y=x-m$ into $n=xy$ yields $x^{2}-mx-n=0, \Delta=m^{2}+4n \geqslant 0$.
Thus, the transformed constraint conditions are
$$
\left\{\begin{array}{l}
m^{2}+3 n \leqslant 1 \\
m^{2}+4 n \geqslant 0
\end{array}\right.
$$

Therefore, the set of points $(m, n)$ is the region $O$ between the parabolas $m^{2}=-3n+1$ and $m^{2}=-4n$. To find the extremum of $S=m+2n$ is to find the extremum of the intercept of the line system $n=-\frac{1}{2}m+\frac{S}{2}$. Therefore, when the line is tangent to the parabola $m^{2}+3n=1$, $S$ is maximized. From $\left\{\begin{array}{l}S=m+2n \\ m^{2}+3n=1\end{array} \Rightarrow 2m^{2}-3m+(3S-2)=0, \Delta=0\right.$, we get $S_{\text{max}}=\frac{25}{24}$.
When the line passes through the intersection point $A$ of the two parabolas in the third quadrant, $S$ is minimized. Solving, we find $A(-2,-1)$, so $S_{\text{min}}=-4$. Explanation: By substitution, the method of combining numbers and shapes simplifies the calculation.
Solution 2: For $x^{2}+xy+y^{2} \leqslant 1$, completing the square on the left side, we get $\left(x+\frac{1}{2}y\right)^{2}+\left(\frac{\sqrt{3}}{2}y\right)^{2} \leqslant 1$.
Let $x+\frac{1}{2}y=r \cos \theta, \frac{\sqrt{3}}{2}y=r \sin \theta, 0 \leqslant r \leqslant 1$, then
$$
x=r \cos \theta-\frac{\sqrt{3}}{3} r \sin \theta, y=\frac{2 \sqrt{3}}{3} r \sin \theta,
$$

Thus, $x-y+2xy=\left(r \cos \theta-\frac{\sqrt{3}}{3} r \sin \theta\right)-\frac{2 \sqrt{3}}{3} r \sin \theta+2\left(r \cos \theta-\frac{\sqrt{3}}{3} r \sin \theta\right) \frac{2 \sqrt{3}}{3} r \sin \theta$
$$
=r\left[(\cos \theta-\sqrt{3} \sin \theta)+\frac{2}{3} r\left(\sqrt{3} \sin 2 \theta-2 \sin ^{2} \theta\right)\right]
$$

Let $t=\cos \theta-\sqrt{3} \sin \theta$, then $t \in[-2,2]$, and
$$
t^{2}=\cos ^{2} \theta-2 \sqrt{3} \cos \theta \sin \theta+3 \sin ^{2} \theta,
$$

Thus, $2 \sin ^{2} \theta-\sqrt{3} \sin 2 \theta=t^{2}-1$, substituting into (1) yields
$$
x-y+2xy=r\left[t+\frac{2}{3} r\left(1-t^{2}\right)\right]=-\frac{2}{3} r^{2}\left(t-\frac{3}{4 r}\right)^{2}+\frac{2}{3} r^{2}+\frac{3}{8} \leqslant \frac{2}{3}+\frac{3}{8}=\frac{25}{24} \text{. }
$$

Equality holds if and only if $t-\frac{3}{4 r}=0, r=1$, i.e., $t=\frac{3}{4}, r=1$. Therefore, the maximum value of $x-y+2xy$ is
$\frac{25}{24}$.