http://primepuzzle.com/tunxis/product-and-sum-problem.txt lrb - 10/8,9,11/2009 ref: http://www.yofx.org/?p=460 Product and sum problem (and its continuous analog) *** Please note: For an .html version of this, please visit *** http://primepuzzle.com/tunxis/product-and-sum-problem.html Pick positive integers that sum to 20, like 2, 3, 3, 6, 6. Form the product of these integers. In this case, the product would be 2*3*3*6*6, which is equal to 648. What would you have to pick so that the sum is still 20 but the product is as large as possible? The answer to this problem ends up being 3, 3, 3, 3, 3, 3, 2. 3*3*3*3*3*3*2=1458 Notice that these numbers are (almost) all the same number, namely 3. And that there are 20/3 of them, where / stands for "integer division" (i.e. drop remainders). That is, 20/3 is equal to 6. So, 6*3+2=20 and 3^6*2 is maximal. The product is maximal when you pick the same number (almost) every time. Here's the "continuous analog" to the above problem. Don't limit yourself to positive integers. Can we find a single non-integral number, call it x, such that repeated addition (we call this multiplication) of it a certain (probably non-integral) number of times, namely 20/x "times," would give us the same sum as before, namely (20/x)*x=20 and the "product" of all these (now all identical) terms, namely x^(20/x) is maximal? This "product" would not have an integral number of terms. Since we're now dealing with a continuous function of a real variable we can use calculus. Let f(x)=x^(20/x) It can be seen that f(x)=e^((20/x)*ln(x)) (take ln of both sides to see this) f'(x)=e^((20/x)*ln(x))*((20/x)/x+ln(x)*(-20/(x^2)) (chain rule, product rule, etc.) Setting this to 0, we get 20/(x^2)-ln(x)*20/(x^2)=0 So, ln(x)=1 So x=e The maximal "product" is e^(20/e)=1568.05115 Recall that 3*3*3*3*3*3*2=1458 In a sense, we shrank each 3 down a bit (to 2.71828) and bumped the single 2 up some (to 2.71828) to get a higher product. The integral number of terms in the sum used to be 7 (six 3's and one 2). It is now 20/e, which equals 7.35758, which of course is not integral. It's not hard to see that 20 has no real importance in this problem. Any number will work. You'll just get more (or fewer) terms in the sum and the maximal product will be bigger (or smaller). The cool thing is that the base of natural logarithms, e, 2.71828, will always be the best value to pick for the repeating term.