How find the maximum of the $x^3_{1}+x^3_{2}+x^3_{3}-x_{1}x_{2}x_{3}$ Let $$0\le x_{i}\le i,\, i=1,2,3$$ be real numbers. Find the maximum of the expression
$$x^3_{1}+x^3_{2}+x^3_{3}-x_{1}x_{2}x_{3}$$

My idea: I guess
$$x^3_{1}+x^3_{2}+x^3_{3}-x_{1}x_{2}x_{3}\le 0^3+2^3+3^3-0\cdot2\cdot 3=35$$ 
But I can't prove it. Can you help ?
This problem is a special case of:

 A: Hint:
As the objective function is convex and continuous, and the domain of interest is compact and convex, so we must have maximum when each $x_i \in \{0, i\}$.  This cuts down the problem (even the general $n$ variable case) to checking a few extreme cases, many of which are trivial...
A: Step 1:  rescale the variables (to see why this is valid, see the addition, below), replacing $y_1=x_1, y_2=x_2/2, y_3=x_3/3$ so that they are on $0\le y_i\le 1$.
on the interior we have
$$\nabla f= \langle 3y_1^2-y_2y_3, 3y_2^2-y_1y_3, 3y_3^2-y_1y_2\rangle=\langle 0,0,0\rangle$$
So

$$\begin{cases}3y_1^2=y_2y_3\quad (1) \\ 3y_2^2=y_1y_3\quad (2) \\ 3y_3^2=y_1y_2\quad (3)\end{cases}$$

Since the interior has $y_1y_2y_3\ne 0$ we can divide $(1)$ by $(2)$ to get ${y_1^2\over y_2^2}={y_2\over y_1}$ i.e. $y_1^3=y_2^3\iff y_1=y_2$ and by symmetry $y_1=y_2=y_3$, which means $2y_i^2=0$ impossible, hence no critical points on the interior.
The whole shape is a cube, so we have to check $6$ sides. On any of the planes where a $y_i=0$ we get a reduction to $y_j^3+y_k^3$ with $0\le y_i,y_j\le 1$ which you can solve by inspection to have the max value $2$.
The other possibilities are some $y_i=1$ on the boundary giving $y_j^3+y_k^3-y_jy_k+1$ with $0\le y_j, y_k\le 1$.
Optimizing this we need to solve
$$\langle 3y_j^2-y_k, 3y_k^2-y_j\rangle =\langle 0,0\rangle.$$
So

$$\begin{cases}3y_j^2=y_k \quad (1)'\\ 3y_k^2=y_j\quad (2)'\end{cases}$$

Again, dividing $(1)'$ by $(2)'$ we conclude $y_j=y_k=0$ which is not on the interior, so we discard it.
This just leaves the edge lines where $y_i=y_j=1$ and $0\le y_k\le 1$, this is a $1$-variable optimization problem:
We have $2+y_k^3-y_k$ i to be optimized, so that we check $3y_k^2-1=0\iff y_k=\sqrt{1\over 3}$, and the endpoint where $y_k=1$.
From here revert to $x$ coordinates and try the options out to get the max.

This method generalizes to any number of variables by induction, seeing the interior constraints will always reduce to all variables being $0$, so you can do the same sort of test after going back to normal coordinates. And if you do the computation even for just $2$ variables, you'll see how to compute without having to check them all.

Addition
For those wondering why it's sufficient to just consider the $y$ critical points instead of directly the $x$ ones, here is the justification:
Let
$$A=\begin{pmatrix} 1 & 0 & 0 \\ 0 & 2 & 0 \\ 0 & 0 & 3\end{pmatrix}$$
Then $f(y)=f(A^{-1}x)$ and $f(x)=f(Ay)$.
The critical points are where the derivative, $Df=0$ (in $x$ coordinates), that is to say:
$D_x(f(x)) = f'(Ay)$ by the chain rule since linear maps are their own derivatives. But since $A$ is invertible, $D_y(f(x))=f'(Ay)A=f'(x)A$. This is $0$ iff $f'(x)$ is, ergo we can test for critical points in either coordinate system.
It's the same idea why diffeomorphisms are Tangent bundle isomorphisms, you're doing the same process here with a simple, invertible linear map.
A: The general question: Given is
$$
f(x_1,\cdots,x_n) = \sum_k x_k^n - \prod_k x_k,
$$
and let
$$
\forall 1 \le k \le n : 0 \le x_k \le k.
$$
Find the maximum of $f(x_1,\cdots,x_n)$.

First we define
$$
x_k = k \sin^2(\phi_k),
$$
whence the condition
$$
\forall 1 \le k \le n : 0 \le x_k \le k.
$$
is satisfied.

For a maximum, we have the condition
$$
\frac{\partial f}{\partial \phi_p} = 0 \wedge
  \frac{\partial^2 f}{\partial \phi_p^2} < 0.
$$

We now have
$$
f(\phi_1,\cdots,\phi_n) = \sum_k k^n \sin^{2n}(\phi_k) - n! \prod_k \sin^2(\phi_k),
$$
whence
$$
\frac{\partial f}{\partial \phi_p} =
  \sin(2 \phi_p) \left( n p^n \sin^{2n-2}(\phi_p)  - n! \prod_{k \ne p} \sin^2(\phi_k) \right),
$$
and
$$
\begin{eqnarray}
\frac{\partial^2 f}{\partial \phi_p^2} &=&
  n(2n-2) p^n \sin^2(2 \phi_p) \sin^{2n-4}(\phi_p) \\
&& + 2\cos(2 \phi_p) \left( n p^n \sin^{2n-2}(\phi_p)  - n! \prod_{k \ne p} \sin^2(\phi_k) \right),
\end{eqnarray}
$$

The extreme value of $f(\phi_1\cdots,\phi_n)$ is given by the condition
$$
\frac{\partial f}{\partial \phi_p} = 0 \Rightarrow
  \sin(2 \phi_p) \left( n p^n \sin^{2n-2}(\phi_p)  - n! \prod_{k \ne p} \sin^2(\phi_k) \right) = 0\\
\Downarrow\\
\sin(2\phi_p) = 0 \vee \sin(\phi_p) = 0 \vee p \sin^2(\phi_p) =q \sin^2(\phi_q).
$$
We have:


*

*The condition $p \sin^2(\phi_p) =q \sin^2(\phi_q)$,
implies that $\displaystyle \frac{\partial^2 f}{\partial \phi_p^2} > 0$,
i.e. a minimum.

*The condition $\sin(\phi_p) = 0$,
implies that $\displaystyle \frac{\partial^2 f}{\partial \phi_p^2} = 0$.

*The condition $\sin(2\phi_p) = 0$,
implies that $\displaystyle \frac{\partial^2 f}{\partial \phi_p^2} = n! - np^n$,
thus $\displaystyle \frac{\partial^2 f}{\partial \phi_p^2} < 0$,
if $p>1$, i.e. een maximum for $p>1$.


The maximum is therefore given for
$$
\phi_1 = 0 \wedge p>1 : \phi_p = \pi/2,
$$
and the maximum is given by
$$
\boxed{
f_\textrm{max} = \sum_{p>1} p^n.
}
$$

A small modification due to some minor errors, thanks to Thomas Andrews!
A: Can't you just differentiate the expression and set the derivatives to 0?
$$
\frac{\partial f}{\partial x_1} = 0\\
\frac{\partial f}{\partial x_2} = 0 \\
\frac{\partial f}{\partial x_3} = 0
$$
and solve for the three variables
