Lets say that I know that $n$ values $x_i$ sums up to $\mu$: $$ \mu=\sum_{i=1}^n x_i $$ I also now that $0\leq x_i\leq 1$ for all $i=1\cdots n$.
I want to find an upper bound as tight as possible for the sum of their squares $\sum_{i=1}^n x_i^2$ as a function of $\mu$ and $n$.
I know that in general $\sum_{i=1}^n x_i^2 \leq (\sum_{i=1}^n x_i)^2=\mu^2$, but in this case if $\mu=n$ because of the costraints it results $\sum_{i=1}^n x_i^2=n=\mu<\mu^2=n^2$ which is too loose for what I need.
Any ideas?
You want as many of the $x_i$ to be $1$ as possible. If you have $0 \lt x_1,x_2 \lt 1$ you can increase $x_1^2+x_2^2$ by increasing the larger and decreasing the smaller. So the maximum sum of squares will be $\lfloor \mu \rfloor + (\mu-\lfloor \mu \rfloor)^2$ as long as $\mu \lt n$. If $\mu \gt n$ there is no solution.