9. Given real numbers $x, y$ satisfy the condition $x-3 \sqrt{x+1}=3 \sqrt{y+2}-y$, find the maximum and minimum values of the expression $P=x+y$.


9. Solution: From the condition, it can be transformed into $x+y=3(\sqrt{x+1}+\sqrt{y+2})$, which is equivalent to
$\left\{\begin{array}{l}x+y=P \\ 3(\sqrt{x+1}+\sqrt{y+2})=P\end{array}\right.$, let $u=\sqrt{x+1}, v=\sqrt{y+2}$, then we have $\left\{\begin{array}{l}u^{2}+v^{2}=P+3 \\ 3(u+v)=P\end{array}\right.$, which is also equivalent to $\left\{\begin{array}{l}u+v=\frac{P}{3} \\ u v=\frac{1}{2}\left(\frac{P^{2}}{9}-P-3\right)\end{array}\right.$,
Therefore, the system of equations has a solution if and only if the equation $18 t^{2}-6 P t+P^{2}-9 P-27=0$ has two non-negative roots,
which means $\left\{\begin{array}{l}-P^{2}+18 P+54 \geqslant 0 \\ P \geqslant 0 \\ P^{2}-9 P-27 \geqslant 0\end{array} \quad \Rightarrow \frac{9+3 \sqrt{21}}{2} \leqslant P \leqslant 9+3 \sqrt{15}\right.$, so
$P_{\min }=\frac{9+3 \sqrt{21}}{2}, P_{\max }=9+3 \sqrt{15}$.