Maximum product when the sum is constant and the variables are positive integers Today I came across an olympiad problem which after some time translated into a simple problem. I was supposed to prove that given $x+y+z = 73$ and $x,y,z ∈ I^+$. Show that the maximum value of $xyz = 14400$.
Now using the AM-GM inequality one can establish that the maximum value of the product for real values of the variable would be $≈ 14408.037037$. However we have the added clause that x,y,z must be positive integers. 
Intuitively, it seems that whenever$$\sum_{i=1}^n |\frac{x}{n}-x_{i}|$$
is minimised for the general case, the product $x_{1}x_{2}....x_{n}$ is maximized. So 24,24,25 is the case in which the value of the above expression for positive integral values of the variables is minimized and hence the product is maximized. But I would like a proof of the above result.
 A: Assume $(x_1,x_2,\ldots,x_n)\in(I^+)^n$ maximizes the product $x_1x_2\cdots x_n$ under the constraint $x_1+x_2+\ldots+x_n=s$ (a maximizer exists because there are only finitely many candidates).
Assume there are indices $i,j$ with $x_i>x_j+1$.
Then $(x_j+1)(x_i-1)=x_jx_i+x_i-x_j-1>x_jx_i$ and hence by replacing $x_i\leftarrow x_i-1$, $x_j\leftarrow x_j+1$ we obtain a better solution. We conclude $|x_i-x_j|\le 1$ for all $i$. 
Thus at most two distinct values $a,a+1$ occur among the $x_i$, say $k$ times $a+1$ and $n-k$ times $a$, and $a$ occurs at least once.
Then from $s=(n-k)a+k(a+1)=na+k$ and $0\le k<n$ we conclude that $k=s\bmod n$ and $a=\lfloor \frac sn\rfloor$.
The corresponding maximal product is then 
$$ \left\lfloor \frac sn\right\rfloor^{n-(s\bmod n)}\cdot \left\lfloor \frac sn+1\right\rfloor^{s\bmod n}.$$
For the problem at hand, $\lfloor \frac{73}{3}\rfloor = 24$ and $73\bmod 3=1$. hence the maximum value is $24^{3-1}\cdot 25^1$.
A: By AM-GM
$$xyz\leq\left(\frac{x+y+z}{3}\right)^3=14408.03...$$
The equality occurs for $x=y=z$, which says that the equality does not occur.
Thus, $xyz\leq14408.$
For $x=y=24$ and $z=25$ we get a value $14400$ and easy to check that it's a maximal value.
Because $14408=8\cdot1801$,
$14407$ is a prime number,
$14406=7^4\cdot2\cdot3$,
$14405=5\cdot43\cdot67$,
$14405=277\cdot4\cdot13$,
$14403=3\cdot4801$,
$14402=2\cdot19\cdot379$ and $14401$ is a prime number.
A: Let
$$x + y + z = c \tag{A}$$
and
$$f(x,y,z) = xyz$$
then using (A) to sub we have
\begin{align}
f(x,y) &= xy(c - x - y) \\
&=xyc - x^2y - xy^2
\end{align}
Take partial derivatives
\begin{align}
f_x(x,y) &= yc - 2xy - y^2 \tag{1}\\
f_y(x,y) &= xc - 2xy - x^2 \tag{2}
\end{align}
to find critical points of the 3d surface. So, set (1) and (2) equal to zero then subtract (2) from (1) to get
\begin{align}
(y-x)c + x^2 - y^2 &= 0 \\
(y - x)c - (y - x)(x+y) &= 0 \\
(y-x)(c - (x + y) &= 0\\
(y-x)(z) &= 0
\end{align}
So one stationary point when $z = 0$, which is clearly not a maximum for $xyz$, and a second stationary point for $y = x$. Taking second partials on (1) and (2), in order to verify this is an extremum in the plane $y = x$
\begin{align}
f_{xx}(x,y) &= -2x \\
f_{yy}(x,y) &= -2y \\
f_{xy}(x,y) &= c - 2(x + y)
\end{align}
we find that $f_{xx} < 0$ for all positive $x,y$ and
\begin{align}
D(x,y=x) &= f_{xx}(x,x)f_{yy}(x,x) - f_{xy}^2(x,x) \\
&= 4x^2 - (c^2 - 4cx + 4x^2) \\
&= c(4x - 1)
\end{align}
so $D > 0$ for all $c > 0$, and positive integers $x$. Therefore when $x,y \geq 1$, $x = y$, and $c > 0$ we have an extremum.
Now we can simplify the problem to $f(x,y = x,z) = f(x,z) = x^2z$ subject to
\begin{align}
x + x + z = 2x + z = c
\end{align}
So $z = c - 2x$, and subbing that we have $f(x,z = c - 2x) = f(x) = x^2(c-2x)$.
Take a good old fashion derivative to get
\begin{align}
f'(x) &= 2cx - 6x^2 \\
&= 2x(c - 3x)
\end{align}
So the max occurs when $x = c/3 = y$, which we can now use to say $z = c/3$ too.
We can see that our original function $f(x,y,z) = xyz$ is continuous. Secondly, we can see that the entire problem is symmetric in $x,y,z$ meaning our test for extrema would be the same for any subbing and pairing of $x,y,z$. That symmetry means that the identified extrema, $x=y=z=c/3$, is a local maximum along any approach in our plane $x + y + z = c$, meaning the shape of our function is concave along the part of plane $x + y + z = c$ of which we are concerned — and, importantly, that behavior was shown to not change for $x,y,z > 1$. Because of that concavity all we have to do is pick the closest integers to $c/3$ that satisfy x + y + z = c. In our case thats $24.33\dots$ so the closest numbers are is $24, 24, 25$.
In other words, if $x,y,z$ minimize their distance to $c/3$ in the plane $x + y + z = c$ then their product will necessarily be closer to the vertex of the paraboloid(s).
Similar to how $x = 6, 7$ maximizes the $2D$ version of this problem in the parabola defined by $xy$ in the plane $x + y = 13$. In this case $6,7$ are the closest satisfying integers to $6.5$. Visual:
https://www.desmos.com/calculator/z9jhl3fjpq
A: You already have an excellent solution and explanation from Hagen von Eitzen.  I am only going to demonstrate why your hypothesis is valid - i.e. minimising the absolute difference with the average also solves the same problem - viz. to find
$$\max \prod x_i \quad  \text{s.t.} \sum x_i = S$$
Note as $\log $ is increasing, this is equivalent to:
$$\max \sum \log(x_i) \quad  \text{s.t.} \sum x_i = S$$
Now $t \mapsto \log t$ is concave, so by Karamata's inequality, you look for $(x_1, x_2, ..., x_n)$ which is majorized by every other natural n-tuplet. 
Hence you could actually replace $\log $ with any other concave function and maximise.  Karamata's inequality would guarantee the solution is the same.  
In fact you could replace $\log $ with any convex function and minimize!  Again Karamata's inequality would guarantee the same solution.  Now you have chosen 
$$\min \sum \mid x_i - S/n \mid \quad \text{s.t.} \sum x_i = S$$ and $t \mapsto \mid t - k \mid$ in fact is convex, so your minimisation will also give the same result.
You of course have a lot of choice now to create equivalent problems, another example:
$$\min \sum e^{x_i} \quad \text{s.t.} \sum x_i = S$$
however the pertinent question is whether any of the reformulations is in fact easier to solve than the original.
