Maximum sum of squares

combinationscombinatoricsmaxima-minimaoptimization

I'm interested in finding the maximum value of a constrained sum of squares. The sum I want to maximize is $\sum_{i=1}^d n_i^2$ under the constraints that $n_1+\cdots+n_d=N-1$, where $N$ and the $n_i$ are natural numbers such that $N,n_i\ge 1$. Formally, I'm looking for a closed expression of the value of
$$\max_{n_1+\cdots+n_d=N-1} \left\{\sum_{i=1}^d n_i^2\right\}$$

I made my own conjecture that the maximum is achieved by $n_1=N-d$ and $n_i=1$ for $i$ such that $2\le i\le d$, for any $d\ge 1$, so

$$\max_{n_1+\cdots+n_d=N-1} \left\{\sum_{i=1}^d n_i^2\right\} = (N – d)^2 + (d – 1)$$

Am I right? Whether I am right or not, is there anywhere with an explanation of a solution? (something that can be cited) In case a written solution is nowhere to be found, can I assume that this could be (easily) proved using induction or even by contradiction?

Thank you.

Best Answer

Hint: for $a > b $, we have $a^{2} + b^{2} < (a+1)^{2} + (b-1)^{2}$. Using this, show that if the maximum is attained by $(n_1, \dots, n_d)$ where $n_1 \leq \dots \leq n_d$ and $n_{d-1} > 1$, then $(n_1, \dots, n_{d-2}, n_{d} - 1, n_{d} + 1)$ gives larger sum of squares.

Related Question