TITLE: Find $\max\{y-x\}$
QUESTION [8 upvotes]: If $x+y+z=3, $ and $x^2+y^2+z^2=9$ , find $\max\{y-x\}$.  

I tried to do this geometrically, $x+y+z=3$ is a plane in $\Bbb{R}^3$ and $x^2+y^2+z^2=9$ is a ball with radius 3 and center of origin . So the candidate points for $y-x$ are on the intersection of the plane and the ball. But now I am confused how to choose to make $y-x$ maximized.

REPLY [5 votes]: By taking the rotation  $X=(y-x)/\sqrt{2}$ and $Y=(y+x)/\sqrt{2}$ we have that the equations become
$$\begin{cases}
X^2+Y^2+z^2=9\\
\sqrt{2}Y+z=3\end{cases}$$ 
Hence $z=3-\sqrt{2}Y$ and
$$X^2=9-(3-\sqrt{2}Y)^2-Y^2=3Y(2\sqrt{2}-Y)\leq 6$$
with equality for $Y=\sqrt{2}$ (and $z=1$).
It follows that
$$X=\frac{y-x}{\sqrt{2}}\leq \sqrt{6}\implies y-x\leq 2\sqrt{3}.$$
Equality is attained for $x=-(\sqrt{3}-1)$ , $y=\sqrt{3}+1$, and $z=1$.