Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Summands
Michael Ioshpe
January 24, 2015
Abstract
Given a natural number, we give it's precise decomposition to summands
whose multiplication is maximal. We present two solutions, the rst is
purely computational, whereas the second uses pure-mathematical tools.
This problem and it's solution(s) is a classical example to the phenomena where (pure) mathematics gives an easy solution to an algorithmic
problem.
Let
nN
xi
n = x1 + ... + xk ,
where
the summands.
Both
and
xi
are considered as variables, i.e. one can change both the number
A computational approach
The Main Question has the obvious solution - run over all possible decompositions and nd the one with maximal multiplication. We describe this in detail:
2.1
n;
n),
(i) In each iteration, call the recursion with the current iteration-number and
Rec(k, n)).
num in the
1 a n,
call
To sum up, The algorithm puts in each iteration the next element of the decomposition, and in the last iteration the value that gives the needed sum.
Via recursion one easily sees that all the possible decompositions are being
reached (more than once).
Now, one easily sees the huge problem - the complexity of this algorithm is
absurd! Moreover, the use of O(n) space seems rather irritating.
See section 4 for some statistics.
Remark: Note that this algorithm is the most naive one; modications can be
made, but the purpose of this paper is to show that this is unnecessary - We
look for a (much) simpler solution.
A Mathematical Approach
3.1
Fix
n;
k,
dene:
xi 6= 0),
to the constraint
x1 + ... + xk = n
In other words, we have:
=
xj (n x1 ... xk1 xi )
xi
j6=i
Thus we get
thatO = 0
when:
subject
2
1
...
1
1 ...
2 ...
... ...
1 ...
x1
n
1
x2 n
1
=
On the
n
...
xk =
is a solution. Thus, x1
k
is the solution; the kind reader will check that this is a maximal
xi =
n
... nk
k
point, e.g. by the Hessian criterion.
3.2
n
(k) = ( )k
k
optimal k 1.
d
n
n
= ( )k (log(( ) 1)
dk
k
k
= e, i.e.k = ne (say n 3).
n
k
Again, by the second derivative test, one veries that this is a maximal point.
This is zero when
n to real summands of
n
'times', and the maximal
e
3.3
e + e + ... + e,
ee.
Back to
3 + ... + 3
times) holds.
(ii) Remainder 2: The decomposition
3 + ... + 3 + 2
n
3
(iii) Remainder 1: This is the hardest case. We have two natural candidates,
3 + ... + 3 + 1
and
3 + ... + 3 + 2 + 2.
But since
n to summands with
3|n
3 + ... + 3
3 + ... + 3 + 2 + 2 3|n 1
3 + ... + 3 + 2
3|n 2
And the maximal multiplication is:
n
0
3 3 2
n1
3 3 1 22
n2
3 3 21
3|n
3|n 1
3|n 2
To sum up, we see that no computational algorithm is needed. The most ecient
solution is given by pure mathematical aspects.
Here is the comparison of the running times of the two algorithms:
15
20
22
24
26
28
30
32
0.047
0.234
0.938
3.75
16.897
72.417
325.376