Lena Bell

2022-07-14

I would like to maximize the function:
$\frac{1}{2}\sum _{i=1}^{N}|{x}_{i}-\frac{1}{N}|$
under the constrains $\sum _{i=1}^{N}{x}_{i}=1$ and $\mathrm{\forall }i\in \left(1,...,N\right)$
I have done some test for small values of $N$ and I have the feeling that the solution is $1-\frac{1}{N}$ but I can't figure out how to solve it analytically.

### Answer & Explanation

Kaylie Mcdonald

Look at the point in which the function takes the maximum value. If there are two numbers that lie on the different sides of $1/N$, i.e. ${x}_{i}<1/N<{x}_{j}$ (otherwise you can make ${x}_{i}$ a little bit smaller and ${x}_{j}$ the same little bit larger so that the function value will grow) then either ${x}_{i}=0$ or ${x}_{j}=1$. Lets assume that none of the numbers is equal to one.

Now look at all nonzero numbers. They are either all greater then $1/N$ all smaller. The latter is impossible. So all numbers are greater then $1/N$. But then the value of your function is $1-m/N$ where $m$ is the number of nonzero ${x}_{i}$s.

Do you have a similar question?

Recalculate according to your conditions!