<s>[INST] Given $x+y+z=3$, how do I maximize $xy+yz+zx-xyz$? Given non-negative numbers $x,y,z$ such that $x+y+z=3$. How do I maximize $xy+yz+zx-xyz$. I found out that the maximum is 2 and equality holds when one of the numbers is 1 and the other two sum up to 2 but had no idea how to prove it. Can someone help please?
 [/INST] Since the expression is symmetric, we can assume $z \leq 1$. Note that $xy+yz+zx-xyz=xy(1-z) + z(x+y) = xy(1-z)+z(3-z)$. It means that for given fixed $z \leq 1$, the maximum is reached when $xy$ is maximized (as $1-z\geq0$), and since $x+y=3-z$ is fixed, it happens when $x=y=\frac{3-z}{2}$. Therefore the expression now becomes a polynomial in $z$: $$P(z)=(\frac{3-z}{2})^2(1-z)+z(3-z)=(3-z)(\frac{(3-z)(1-z)}{4}+z)=(3-z)(\frac{z^2}{4}+\frac{3}{4})=\frac{-z^3+3z^2-3z+9}{4}$$ And we want to find it's maximum where $z \in [0,1]$. However it is easy to see that $P$ is positive and decreasing on $[0,1]$, therefore the maximum is when $z=0$ and $P(0)=\frac{9}{4}$ is the maximum. From the proof it follows that the maximum is reached when two of $x,y,z$ are equal to $\frac{3}{2}$ and the other is $0$.
</s>