\(P=x^2-x\left(15-x\right)+\left(15-x\right)^2=3x^2-45x+225\)
\(P=3x\left(x-9\right)+225\)
Do \(0\le x\le6\Rightarrow x-9< 0\Rightarrow3x\left(x-9\right)\le0\)
\(\Rightarrow P\le225\)
\(P_{max}=225\) khi \(\left(x;y\right)=\left(0;15\right)\)
\(P=3x^2-45x+162+63=3\left(9-x\right)\left(6-x\right)+63\)
Do \(x\le6\Rightarrow\left\{{}\begin{matrix}9-x>0\\6-x\ge0\end{matrix}\right.\) \(\Rightarrow3\left(9-x\right)\left(6-x\right)\ge0\)
\(\Rightarrow P\ge63\)
\(P_{min}=63\) khi \(\left(x;y\right)=\left(6;9\right)\)