Obtain the maximum and minimium of the function $f$ I have to calculate the max and min of the function 
\begin{equation}
f(x_1,x_2 \ldots ,x_n)=x_1^3 + x_2^3+\cdots + x_n^3
\end{equation}
subject to
\begin{equation}
x_1 + x_2+\cdots + x_n =0
\end{equation}
\begin{equation}
x_1^2 + x_2^2+\cdots + x_n^2 =1
\end{equation}
I have applied the Lagrange theorem but i don't conclude anything. Could somebody helps me?
 A: The Lagrange multipliers tell us that there exist $\lambda$ and $\mu$ such that for all $i=1,\ldots,n$
\begin{equation}
3 x_i^2 = 2 \lambda x_i + \mu
\end{equation}
by summing these equalities one gets $3 = n\mu$. We still don't know $\lambda$ but as all the $x_i$ satisfy the same 2nd degree equation, it means that the $x_i$ can take only two values.
Multiplying by $x_i$ and summing, we get $3 f = 2 \lambda$ at the given point, so the equation can be rewritten
\begin{equation}
x_i^2 = f x_i + \frac{1}{n}
\end{equation}
Suppose that $q$ of the $x_i$ have value $\frac{f}{2} + \sqrt{\frac{f^2}{4} + \frac{1}{n}}$ and that $p=n-q$ of them have the value $\frac{f}{2} - \sqrt{\frac{f^2}{4} + \frac{1}{n}}$. The sum is
\begin{equation}
0 = \sum_i x_i = n \frac{f}{2} + (q-p) \sqrt{\frac{f^2}{4} + \frac{1}{n}}
\end{equation}
It follows that $q-p \neq 0$ otherwise $f=0$ and it is obviously not the maximum (if $n>2$). Furthermore, $\sqrt{\frac{f^2}{4} + \frac{1}{n}} = \frac{q+p}{p-q} \frac{f}{2}$ which implies that $q$ of the $x_i$ have the value $f \frac{p}{p-q}$ and $p$ of the $x_i$ have the value $-f\frac{q}{p-q}$. It also implies that $f$ and $p-q$ have the same sign. Summing the $x_i^2$ yields
\begin{equation}
1 = \sum x_i^2 = f^2 \left(\frac{q p^2}{(p-q)^2} + \frac{p q^2}{(p-q)^2}\right) = f^2\frac{npq}{(p-q)^2}
\end{equation}
Hence one has $f = \frac{p-q}{\sqrt{n p q}}$ and $q$ of the $x_i$ have the value $\frac{p }{\sqrt{npq}}$
and $p$ of them have the value $\frac{-q}{\sqrt{n p q}}$. Such a point satisfies all the constraints and the equation above with the Lagrange multipliers.
It remains to select, among all the integer choices of $p+q=n$ the value that maximizes (or minimizes, which is the opposite), the quantity
\begin{equation}
f = \frac{p-q}{\sqrt{npq}}
\end{equation}
The maximum is reached for $p=n-1$ and $q=1$ because the function $\frac{1-2x}{\sqrt{x(1-x)}}$ decreases in $[0,1]$. This gives a maximum of
\begin{equation}
f = \frac{n-2}{\sqrt{n(n-1)}}
\end{equation}
