Shortest Addition Chains

Introduction

A finite sequence of positive integers a0, a1, ..., ar is called an addition chain iff for each element ai, but the first a0 which equals 1, there exist elements in the list with smaller indexes j and k such that ai = aj + ak.
Preciser this is called an addition chain of length r for its last number ar. It can be interpreted like calculating n = ar starting from 1 by addition of only previous calculated numbers. Let us restrict the definition a bit more: addition chains should be strictly monotonic increasing. This can be achived by reordering and dropping multiple numbers. As a consequence a1=2 and a2=3 or 4 always (as long as r > 1). Now ask for the minimal length of an addition chain for a given number n and call this value l(n). If we demand that j or k equals i-1 for all positive indices i -- each ai in the chain requires the previous ai-1, we call such a chain a star-chain and denote its minimal length by l*(n).
I highly recommand Knuth's survey in section 4.6.3 of The Art of Computer Programming, Volume 2: Seminumerical Algorithmus (3. edition appeared 1997). To illustrate shortest addition chains for each n < 149 one may track the path from the root 1 to the corresponding node n in the following tree:
Addition Chain Tree
Such a tree can't be extended gapless to larger n because in the triple 43, 77, 149 any two numbers exclude the third for a shortest addition chain representation in a common tree.

Lower and Upper Bounds of l(n)

Write n in its binary representation and denote by v(n) the number of ones in this representation and by λ(n) the binary logarithm of n rounded to the next integer down in the case it is not already integer (floor-function). Then it is obvious through construction of an addition chain according by the russian multiplication, that l(n) <= λ(n) + v(n) - 1. An open conjecture states a lower limit of λ(n) + log2(v(n)).

Notation

Notice: The definitions of v(n) and λ(n) are given in the previous paragraph.
s(n)
the number of small steps of n defined as the difference of the length of its shortest addition chain and the binary logarithm (rounded down).
s(n) = l(n)-λ(n)
Double step
ai = ai-1 + ai-1
Star step
ai = ai-1 + aj with j < i
Small step
λ(ai) = λ(ai-1)
Standard step
ai = aj + ak with i > j > k

L(r)
the set of numbers which have a shortest addition chain of length r
L(r) = { i: l(i)=r }
c(r)
the smallest number which has a shortest addition chain of length r
c(r) = min L(r)
2r
the largest number which has an addition chain of length r
2^r = max L(r) holds trivally
m(r)
the median of numbers which have a shortest addition chain of length r
m(r) = med L(r)
μ(r)
the arithemtic average of numbers which have a shortest addition chain of length r
μ(r) = 1/d(r) ∑i ∈ L(r) i
g(r)
the geometric average of numbers which have a shortest addition chain of length r
g(r) = exp( 1/d(r) ∑i ∈ L(r) ln i )
p(r)
the "most probable" number which has a shortest addition chain of length r
p(r) = i: fr(i) = maxh fr(h) with fr(i) = ∑k ∈ N |{ j ∈ L(r): |i-j|=k }|/4k
σ(r)
the standard deviation of the numbers which have a shortest addition chain of length r
σ2(r) = 1/d(r) ∑i ∈ L(r) i2 - μ(r)2
d(r)
the number of numbers which have a shortest addition chain of length r
d(r) = | L(r) |


Table of Characterizing Values

r c(r) s(c(r))v(c(r)) μ(r) g(r) m(r)p(r)σ(r) d(r) L(r)
0 1 0 1 1.0 1.0 1= 10 1{1}
1 2 0 1 2.0 2.0 2= 20 1{2}
2 3 1 2 3.5 3.5 3+ 3+0.5 2{3,4}
3 5 1 2 6.3 6.2 6= 61.2 3{5,6,8}
4 7 2 3 10.8 10.4 10= 103.1 5{7,9,10,12,16}
5 11 2 3 18.2 17.3 17= 146.1 9{11,13,14,15,17,18,20,24,32}
6 19 2 3 31.7 30.1 28= 2611.4 15{19,21,22,23,25,26,27,28,30,33,34,36,40,48,64}
7 29 3 4 54.5 51.3 49+ 43 21.2 26
8 47 3 5 94.6 88.5 84+ 84 39.0 44
9 71 3 4 162.4 151.0 147+ 116 70.5 78
10 127 4 7 283.1 262.8 248+ 230 125.6 136
11 191 4 7 491.5 456.1 435+ 455 220.8 246
12 379 4 7 869.8 809.4 781+ 840 387.5 432
13 607 4 7 1535.4 1429.4 1372+ 1136 682.3 772
14 1087 4 7 2725.8 2540.0 2461+ 2028 1201.5 1382
15 1903 5 9 4855.4 4527.9 4379= 4047 2122.4 2481
16 3583 5 11 8672.1 8097.2 7813+ 6832 3748.3 4490
17 6271 5 9 15571.7 14570.0 14101+ 12048 6611.3 8170
18 11231 5 11 28094.6 26343.0 25641+ 24096 11694.2 14866
19 18287 5 10 50861.7 47784.4 46466+ 48156 20748.0 27128
20 34303 5 11 92379.2 86937.2 84764+ 89120 36960.6 49544
21 65131 6 12 168192.7 158468.7 154745= 146480 66224.1 90371
22 110591 6 15 306531.6 289025.3 282128+ 290858 119165.8 165432
23 196591 6 16 559476.7 527913.7 514285= 520240 215048.9 303475
24 357887 6 15 1023051.3 966288.1 942710= 1155126 388500.7 558275
25 685951 6 15 1874869.11772876.31732716+ 2310196 702737.4 1028508
26 1176431 6 14 3443135.03259501.83191985+ 2801503 1273563.8 1896704
27 2211837 6 16 6333417.26001516.05881151= 5612462 2313684.8 3501029
28 4169527 7 17 11667084.111064752.410848521+ 9412704 4214352.7 6465774
29 7624319 7 15 21516285.220418193.420044424+ 16905070 7697737.3 11947258
30 14143037 7 16 39714338.937704137.937013874= 41615456 14098404.4 22087489
31 25450463 7 15 73345796.769658962.368327129+ 83230816 25868797.8 40886910
32 46444543 7 18 135563778.8128804664.5126581547+ 132022368 47516034.6 75763102
33 89209343 7 18 250780403.3238406628.4234114742=28495063587306216.3140588339
34 155691199 7 16 464437430.0441801858.5434295820+397507456160480247.6261070184
35 298695487 7 19 861008497.3819556624.5806226456+680509066295231415.9485074788
36 550040063 7 17 1597540092.51521468390.11497772469+1511488768543803959.0901751654
37 994660991 8 18 1677060520
38 1886023151 8 19 3119775195
39 3502562143 8 18 5804404206
40 6490123999 8 21 10804952217
41 11889505663 8 21
42 22899028607 8 21
43 41866170239 8 25

In the median column the sign = means the value is unique and the character + indicates it lies between the given index and the next index with this r-value because d(r) is even.
With bold font in the previous c(r)-column the sequence of smallest numbers ni is high-lighted which need at least i= s(c(r)) small steps in their addition chain: 1,3,7,29,127,1903,65131,4169527,994660991,....
Moreover here are the graphs of c(r) and d(r) together with an approximation function plotted. And the quotient of c(r) and d(r) with the asymptotic approximation function. Finally the distribution of the number of shortest addition chains with fixed small step number depending on the range of λ(n).


Generally Solved Small Step Cases

0-small-step case
Trivial
1-small-step case
<= 1894 solved
2-small-step case
<= 1973 solved
3-small-step case
1991 solved


History: What was calculated When and by Whom

In July 2004 the data calculated 1997 by Flammenkamp was completely and independently checked. Hereby Neill Clift uncovered four l(n)-errors, which he attributed to a typo in Flammenkamp's program effecting only n-values > 2500000.
On 30th May 2008, Neill Clift discovered the first and smallest n such that l(n) > l(2n).


Data Access

Thanks to Neill Clift's computations you can download the lengths of all shortest additions chains for n up to n=231 as bziped2 binary data of 210 MB size. The uncompressed values are coded as l(n)-λ(n)-ceil(log2(v(n))) into 2 bits each which the exception of l(2135101487) #. To decipher this you can download ddt.c compile it and run it as ddt inputfile linelength. You will get all values starting from 1 and broken into lines each containing linelength values onto your stdout from the base-36 alphabet (0,1,2,..,9,a,b,c,..,z) or as a 1 or 2 digit decimal value. A second helper l.c outputs l(n), λ(n), s(n) and v(n) for each given input n which data is in the datafile.
Now you can download all l(n) with n <= 233 as bziped2 binary data of 820 MB size. To display these you must also download ddt4l.c, compile it and run it as ddt4l datafile [first n [total number [linelength] ] ]. You will get all or total number-many values starting from 1 or first n and broken into lines each containing linelength values onto your stdout from the base-42 alphabet (0,1,2,..,9,a,b,c,..,z,A,B,C,..,F).
Now you can download all l(n) with n <= 235 as bziped2 binary data of 3197 MB size. To display these you must also download ddt4ln.c, compile it and run it as ddt4ln datafile [-O?] [first n [total number [linelength] ] ]. You will get all or total number-many values starting from 1 or first n and broken into lines (or pages) each containing linelength values onto your stdout. This ? after the -O controls the output format and must take values ∈ {0,1,2,3,4}. The default is 0 and means no output, but data integrity check only. Thus in generally you will need this output-option. The options -O1 and -O2 are the old formats known from ddt and ddtl4.The parameter -O4 produces a format very similar to this of the above old helper-program l.
Now you can download all l(n) with n <= 236 as bziped2 binary data of 6397 MB size. To display these you must also use ddt4ln.c like in the case of the 235-many values.

Look up in the database of the first 231 many l(n) values

starting from index the following values
Table Raw

The effort to compute these values up to n=220 is here visible. The number of cases checked to get l(n) is plotted in red against λ(n) for each number 28 <= n < 220. In blue the number of cases are marked to compute n=c(r) and finally in dark green the average number of cases is drawn which is needed to calculate l(n) for all numbers from 1 up to n (the last gives a good estimate of the average run time of the algorithm).

Generate a Shortest Addition Chain for any given number < 227

n= fast difficult

# The smallest n such that l(n)-λ(n)-ceil(log2(v(n))) equals 0,1,2,3,4,... are 1, 29, 3691, 919627, 2135101487, ... .


Conjectures

l(2n-1) <= n + l(n) - 1
The outstanding Scholz-Brauer-Conjecture of 1937. If l(n) is achievable by a star chain then it holds. Therefore only values of n need to be considered with l(n) < l*(n). But the smallest of these numbers is 12509. In August 2005 Clift reported to have confirmed the Scholz-Brauer inequality for all n < 5784689. +
l(2n-1) = n + l(n) - 1
This narrow related equation is proved only for n <= 66 and n=68,72,80,96  *.
l(n) >= λ(n)+log2(v(n))
This famous lower bound was formulated first a bit differently by Stolarsky 1969 and nearly proved 1974 by Schönhage who showed that l(n) >= log2(n)+log2(v(n))-2.123164629... holds for each n. Thurber showed 1973 that it holds for all n with v(n) <= 16. In October 2008 Clift confirmed the conjecture for all n <= 264.
log2(c(r)) ~ r - r/log2r
That is the 1997 stated conjecture by Flammenkamp for the asymptotic growth of c(r) outdating the 1991 given assertation that log2(c(r)) ~ r - 2log2r.
Computing l(n) for given n is NP-hard.
Downey, Leony and Sethi didn't prove anything about this statement in their 1981 SIAM article. They proved a similar one, if a set of numbers is given! Many people (and even experts) overlooked this important difference!
d(r) <= d(r+1) <= 2d(r)
Already 1981 D. Knuth stated "there is no evident way to prove that d(r) is an increasing function in r".
+This number 5784689 = 222+97*214+65*24+97 is also the smallest Non-Hansen number (also identified by Neill Clift in 2005 as such).
*In August 2005 Neill Clift reported to have proved equality without any further assumption for all n <= 28 and n = 30. Furthermore in December 2007 he showed equality without any further assumption even for n = 29. Moreover until May 2009 he proved it for all n <= 64 and in May 2016 for n ∈ {65,66,68,72,80,96}.


Unsorted new stuff


References

legend:
# reviewed journal article
# thesis
# report, memorandum, paper
# conference proceedings
# monography
# unclassified or other

I like to thank Neill Clift, Kirkland, Washington, U.S.A., for far the most references in the preceeding bibliography list.


Achim Flammenkamp
Last update: 2016-11-08 18:02:40 UTC+2