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?
 A: Well,  the equation is perfectly symmetric, so you only have to look at the partitions of 9 into 3 (possibly empty) parts.   Exhaustion works well enough here, listing them from the largest part downward:
The cases are:
$$9,0,0$$
$$8,1,0$$
$$7,2,0$$
$$7,1,1$$
$$6,3,0$$
$$6,2,1$$
$$5,4,0$$
$$5,3,1$$
$$5,2,2$$
$$4,4,1$$
$$4,3,2$$
$$3,3,3$$
So, 12 cases,  and most of the numbers are trivial and repeated.  Calculate what happens to the numbers from 0 to 9, then add them as needed as above.  
A: Without loss of generality $a \geq b \geq c$. So $c \leq 3$ and if you write down a list of all the values of $\frac{x(x-1)(9-x)}{2}$ for $0 \leq x \leq 9$ it's easy to check which pair $(a,b)$ maximises the total for each of the four possessible values of $c$, then see which of those is the greatest.
A: $\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 
