<s>[INST] Finding the maximum of an expression in three variables I am trying to find the max of $\frac{(a)(a-1)(9-a)}{2} + \frac{(b)(b-1)(9-b)}{2} + \frac{(c)(c-1)(9-c)}{2}$ subject to $a+b+c=9$ over nonnegative integers. I originally tried to see if something could work with Jensen's or calculus, and I have a conjecture that I haven't been able to prove that the maximum occurs when $a=5, b=4, c=0$ by simply plugging in an initial guess $a=b=c=3$ and then trying $a=4, b=3, c=2$ and then eventually $a=4, b=4, c=1$. Then because the function $f(x) = \frac{(x)(x-1)(9-x)}{2}$ is increasing when $x<6$ and $f(0)=f(1)=0$ we know that $(5,4,0) > (4,4,1)$.
Is there a more rigorous approach to this?
 [/INST] $\dfrac{(a)(a-1)(9-a)}{2} + \dfrac{(b)(b-1)(9-b)}{2} + \dfrac{(c)(c-1)(9-c)}{2}$
$=\dfrac{-\sum a^3+10\sum a^2-9\sum a}2$
$\sum a=9$
$\sum a^2=(\sum a)^2-2\sum ab=9^2-2\sum ab$
$\sum a^3=(\sum a)\{(\sum a)^2-3\sum ab\}=9[9^2-3\sum ab]$
Finally $2[(\sum a)^2-3\sum ab]=\sum(a-b)^2\ge0$
$\implies6\sum ab\le2(\sum a)^2=2\cdot9^2$
Fortunately, this gives integer solutions 
</s>