Maximize product of numbers with a given sum

The problem is:

Find a set of positive real numbers which sum to 271 and has as large product as possible.

All numbers must be >0\gt0, otherwise the product would be zero.

A candidate could be [200, 71]. Could we do better? Yes. Let’s prove that an optimal solution must have all numbers equal.

Proof - all numbers must be equal

Assume the sequence is X=x1,...xNX=x_1,...x_N. Without losing generality, we can require that it is sorted such that xixjx_i\le x_j for i<ji<j, because rearranging the sequence does not affect the sum nor the product.

Assume we have a valid candidate XX. Build a new sequence Y=xm,x2,...xN1,xmY=x_m,x_2,...x_{N-1},x_m which is XX but with the first (smallest) and last (largest) element replaced with their mean xm=(x1+xN)/2x_m=(x_1+x_N)/2. The sum will be unchanged. The product will be:

Y=Xx1xN(x1+xN2)2\prod{Y}=\frac{\prod{X}}{x_1 x_N} (\frac{x_1+x_N} {2})^2

The product Y\prod{Y} will be greater than X\prod{X} if

(x1+xN)24x1xN>1\frac{(x_1+x_N)^2} {4 x_1 x_N} \gt 1

x1xN+2+xNx1>4\frac{x_1}{x_N} + 2 + \frac{x_N}{x_1} \gt 4

This can be simplified to

1a+a>2\frac{1}{a}+a > 2

which is true for positive aa fulfilling a1a\neq 1.

That means any candidate XX which has non-equal elements, can be replaced with YY having a strictly higher product. Thefore, the optimal solution must have all elements equal.

The optimal value

The problem boils down to selecting the number of terms N>0N>0 with equal elements such that the product

P=X=271N=(271N)NP=\prod{X}=\prod{\frac{271}{N}}=(\frac{271}{N})^N

is maximized.

lnP=N(ln271lnN)\ln{P}=N ( \ln{271} - \ln{N})

The derivative of this with respect to NN is

1(ln271lnN)+N1N1(\ln{271} - \ln{N}) + N \frac{1}{-N}

which means the maximum occurs at lnN=ln2711 \ln{N}= \ln{271}-1 N=271e99.67N=\frac{271}{e}\approx 99.67

Since NN must be integral, we investigate PP for N=99N=99 and N=100N=100 and find that N=100N=100 gives a slightly higher answer.