Generalised Addition Chains
Generalised Addition Chains
#A16
Abstract
Given integers d 1, and g 2, a g-addition chain for d is a sequence of integers
a0 = 1, a1 , a2 , . . . , ar 1 , ar = d where ai = aj1 + aj2 + + ajk , with 2 k g, and
0 j1 j2 jk i 1. The length of a g-addition chain is r, the number
of terms following 1 in the sequence. We denote by lg (d) the length of a shortest
addition chain for d. Many results have been established in the case g = 2. Our
aim is to establish the same sort of results for arbitrary fixed g. In particular, we
adapt methods for constructing g-addition chains when g = 2 to the case g > 2 and
we study the asymptotic behavior of lg .
1. Introduction
Given integers d
1, and g
a0 = 1, a1 , a2 , . . . , ar
1 , ar
=d
INTEGERS: 14 (2014)
addition chain itself, meaning 2-addition chain, was coined and formally defined in
1937 by Scholz [9]. While many conjectures (and theorems!) concerning addition
chains rose and fell over the years, the celebrated 1937 Scholz-Brauer conjecture,
claiming that l2 (2n 1) n 1 + l2 (n), remains open today.
The Scholz-Brauer conjecture and the intriguing behavior of the l2 function led
to an abundant literature on addition chains. Knuth [8, Section 4.6.3] is a careful
source of facts and historical details covering the period up to 1973. Further developments, including world records and a bibliography reaching until 2008, can be
found at [6].
To the best of our knowledge, none of the above literature considers g-addition
chains for g > 2. We begin investigating such generalized addition chains here.
Specifically, Section 2 describes three algorithms to generate g-addition chains. In
Section 3, we establish upper and lower bounds on lg (d) and we bound the main
term and the error term in the asymptotic behavior of lg (d). Section 4 concludes
by recalling the algebraic complexity theory context in which the study of addition
chains can be cast and by listing open questions and suggestions for future work.
When & is a sequence of integers i1 , . . . , ij and m is an integer, we let m & stand
for m i1 , . . . , m ij . We also adopt the following notation:
bxc
floor of x;
g (n)
blogg (n); c
dxe
g (n)
lg (n)
o(1)
ceiling of x ;
number of nonzero digits in the representation of n in basis g;
length of a minimal g-addition chain for n;
function f : N ! R such that f (n) goes to 0 when n goes to infinity.
INTEGERS: 14 (2014)
out duplicates from the sequence fac[d], defined by induction on d as
8
>
if d g,
>
<1, dh
i
d (d mod g)
fac
, d (d mod g), d
else, if d is prime,
g
>
>
:fac[p p p ], (p p p ) fac[p p
1 2
i
1 2
i
i+1 i+2 pm ] otherwise
fac[p1
1
where i and 0 < i 2i are the smallest integers such that p2
pi i
g.
1
21
i
2
Indeed since g does not divide (g + 1) , we have p1 pi
g + 1. Also, since
21
21
21
i
i
1 +1
k > 1, p
divides
p
p
,
so
p
p
=
6
g
+
1.
Hence
p
pi i g + 2.
1
1
1
1
i
i
2
2
(g + 1)
(g + 1)
i
i
k
Therefore, since
< g + 1, i.e.,
g, we have p2
p2
g.
i
k
g+2
g+2
So that the induced addition chain has length 3. Note that when g is prime, the
factor method produces a g-addition chain of length at least e + 3 for g e (g + 1)2 .
In the case k = 1, the factor method induces the g-addition chain
k
1, p
k
2k
k
, p
k , pk
k
, p2
if k > 1,
k
and
1, pk
1, pk , pk (pk
1), p2k if k = 1.
INTEGERS: 14 (2014)
k
1
Example 2.2. Consider d = g 2 , where g = p
1 pk is the prime decomposition
of g with p1 < < pk and assume that k > 1. Then the factor method induces
the g-addition chain
1
1
1
i
k
1, p2
pi i 1 , p2
pi i , p2
p2
p2
1
1
1
i
k
1
where i and 0 < i 2i are the smallest integers such that p2
pi i
g.
1
1
1 +1
21
Also, since k > 1, and thus p1 < g, we have that p1
divides p1 pi i , so
1
1
p2
pi i 6= g. Hence p2
pi i > g. This addition chain has length 3.
1
1
e+2
Note that in fact, d = g
requires at least 3+e steps. Indeed, the first iteration
of the algorithm of the factor method produces
d
1, fac[q1 ], q1 fac
q1
for some q1 where g < q1 gpk . Since q1 > g, we know that fac[q1 ] contributes at
d
least 2 to the length of the chain. Now applying the algorithm to
produces
q1
d
1, fac[q2 ], q2 fac
,
q1 q2
for some q2 where g < q2 gpk . Since q2 > g, we know that q1 fac[q2 ] contributes
at least another 2 terms to the chain. We can repeat this argument at least
loggpk g 2+e =
logg g 2+e
2+e
>
logg gpk
2
times, where each time, the length of the chain increases by 2 at least. Therefore,
the final g-addition chain has length at least 3 + e.
2k
k
When k = 1, the method induces the g-addition chain 1, p
of length 2.
k , pk
2.2. The m-ary Method
The m-ary method consists of expressing d as d = dk mk + + d1 m + d0 , where
0 di < m for 0 i k = blogm dc, and appending to 1 the sequence
m, dk m, dk m+dk
2
1 , (dk m+dk 1 )m, dk m +dk 1 m+dk 2 ,
, (dk mk
+ +d1 )m, d
of length at most blogm dc + m (d) when m < g. When m g, the method begins
with 1, dk (if 1 < dk < g), g, g + 1, g + 2, . . . , m 1 and appends instead
dk &,
dk m + dk
(dk m + dk
1,
1)
&,
INTEGERS: 14 (2014)
dk m2 + dk
1m
+ dk
2,
..
.
(dk mk
+ + d1 ) &,
d
where & is a fixed g-addition chain for m. Only the digits di that are non-zero
contribute a non-& step to the above sequence. Given an optimal &, the length of
the sequence produced when m > g is thus at most
(m
1).
(1)
g + blogg dc + m (d)
(2)
INTEGERS: 14 (2014)
Remark 2.5. In the following example, we solely use the argument that if an
integer d is at the level k of the tree, then the integer gd is at worst at the level
k + 1 of the tree.
Example 2.6. Consider d = g 2 (2g + 1). From the tree generated by the tree
method, we see that g belongs to level 2, so 2g + 1 belongs to level 3. Hence
g(2g + 1) is at worst at level 4, and g 2 (2g + 1) is at worst at level 5. So the length
of the induced addition chain is at most 4.
As the number of steps in the g-addition chain for gn using the tree method is at
most the one for n plus one, the tree method induces a g-addition chain of length
at most 4 + k for d = g 2+k (2g + 1).
2.4. Comparison of Methods
Table 1 summarizes the relative performances of our three methods on selected
families of integers. The rows in the table are justified next.
Compared methods
factor > g-ary
factor > g-ary
factor > g-ary
g-ary > factor
tree > factor
g-ary > factor
tree > factor
g 2 -ary > factor
tree > factor
tree > g-ary
Property of g
g + 1 not a power of a prime
g > 2 prime, g + 1 not a power of 2
g + 1 = p , g > 2, p prime
Witness Element/Family
(g + 1)2
g k (g + 1)2
2p2
g 2+k
2pk+1
g prime
(p 1)2 p2k
g 2+k (2g + 1)
INTEGERS: 14 (2014)
1, (p
1)2 , p(p
1)2 , p2 (p
1)2 , p3 (p
1)2 , , p2k (p
1)2 p2k ,
1)2
of length 2 + 2k. The factor method induces a longer g-addition chain of length at
least 3 + 2k. Indeed, since p 1 is even, the first iteration of the inductive algorithm
of the factor method for d produces 22 q, where q is a divisor of ( p 2 1 )2 such that
22 q
p. Now p does not divide ( p 2 1 )2 so 22 q > p, therefore the factor method
requires two steps to produce 22 q. Also, q 6= ( p 2 1 )2 . Indeed, assume p 2 1 divides
q. Since 22 p 2 1 > p, q would have to be equal to p 2 1 . Hence, the p2 -ary method
produces a g-addition chain of length 2 + 2k for d = (p 1)2 p2k , shorter than the
one of length at least 3 + 2k produced by the factor method.
To justify row 7, we combine examples 2.4 and 2.6 and deduce that for each g,
there is an infinite set of integers d of the form g 2+k (2g + 1), where k 1, such that
the tree method induces a g-addition chain of length at most 4 + k shorter than the
one by the g-ary method of length k + 5.
2.5. Practical Issues
Suppose that g 2 is a fixed integer. As Theorem 3.1 below makes clear, the m-ary
method with m = g implies that the length of an optimal g-addition chain for a
number d is no longer than twice logg (d). Two computational problems thus arise:
Given d in binary or decimal notation, compute:
(1) an optimal g-addition chain for d;
(2) a g-addition chain for d no longer than twice the optimal.
In complexity theory, efficiency as a first approximation is taken to mean the
existence of an algorithm that runs in time bounded by some polynomial in terms
of the problem input length. At present, no efficient algorithm is known to solve
problem (1) even when g = 2.
But we note that problem (2) is solved efficiently by the m-ary method (Sketch:
efficient arithmetic to compute the g-ary representation of d from its binary or
decimal expansion is well-known [8], and a straighforward implementation of the
INTEGERS: 14 (2014)
1.
INTEGERS: 14 (2014)
Theorem 3.4. For all g
2, we have lg (n)
g (n) + (1 + o(1))
g (n)
g(
g (n))
. (This
logg g
k+1
= gk +
logg n.
logg g k
k
Let
k=b
Then,
g (n)
lg (n) g
g ( g (n))
logg n +
We have
2 g ( g ( g (n)))
g2
2(
g
logg n
b g ( g (n)) 2 g (
g (n)
g (n))
g 2 g (n)
= o(1)
2 ( (n))
g g
g ( g ( g (n)))c.
g ( g (n))
logg n
b g ( g (n)) 2 g (
= (1 + o(1))
g ( g (n))
g ( g (n))
1
2 g(
g ( g (n)))c
g ( g (n)))c
g (n)
g ( g (n))
g ( g (n))
g (n)
g ( g ( g (n))c
logg n
since
1 = 0.
since
lim
n!1
+ 1+
g ( g (n)))c
logg n
n!1 g (n) b
lim
Also,
g ( g (n))
g2
= 0.
g ( g (n))
2, we have lim
n!1
lg (n)
= 1. (This result is in [2] in
g (n)
n!1
(1 + o(1)) g (n)
= 0.
g (n) g ( g (n))
Exploiting Erd
os ideas in the case g = 2 as in [5], and developing the necessary
g (n)
tools, we show that the main term is larger than g (n) +
.
8g loge g g ( g (n))
10
INTEGERS: 14 (2014)
Theorem 3.6. Let g
g (n)
= m and r m +
(1 ")m
8g loge g g (m)
= m
(3)
for < g and m large enough. In other words, the number of g-addition chains
short enough is substantially less than (g 1)g m , which is the number of n such
that g (n) = m, for m large enough.
Proof. Consider an addition chain
1 = a0 < < ar = n with
g (n)
= m.
Fix a positive integer K < g. Let A0 be the number of g-steps in this chain. For
such steps, for i 2, we have ai g 2 ai 2 , and for i = 1, we have a1 = ga0 = g.
For 1 k K, let Ak be the number of steps i such that
ai = (g
k)ai
+ aj1 + + ajh ,
ai 1 > aj1
k)ai
+ kai
(g(g
k) + k)ai
2.
K)ai
+ Kai
(g(g
K) + K)ai
2.
K) + K)B
K
K
+ 2 )B
g
g
K
Y
(g(g
k) + k)Ak
k=1
K
Y
(1
k=1
k
k
+ 2 )Ak .
g
g
11
INTEGERS: 14 (2014)
Taking logarithms in base e, and using
k
k
+ 2)
g
g
loge (1
k
k
k gk
+ 2 =
and loge (1
g
g
g2
K
K
K gK
+ 2)
,
g
g
g2
we get
K
X gk k
gK K
B+
Ak 2(r
2
g
g2
1
m + ) loge g.
2
k=1
(4)
Now
X
(3)
P
A0 +B+ K Ak =r
P K gk k k=1
gK K
B+ k=1 g2 Ak 2(r m+ 12 ) loge g
g2
A0 !B!
r!
QK
k=1 Ak !
rgB
K
Y
rkAk .
(5)
k=1
The number of terms in the sum (5) is bounded by 3g(K + 1)(r m + 12 ) loge g since
B, Ak , k = 1, K are bounded by 3g(r m + 12 ) loge g. Also,
r!
rr
A0 !
A0
PK
= rB+
k=1
Ak
K
g
P
)B+ K
k=1 (k
k
g )Ak
r2(r
m+ 12 )g loge g
we obtain:
1
m + ) loge g
2
P
B+ K
Ak
k=1
r
r2(r
Choosing K = d g2 e implies
6(r
m+
1
)g loge g
2
3(K
K
X
K
)B +
3(k
g
k=1
PK
m+ 12 )g loge g (g K+ K
k=1
g )B+
k
)Ak
g
(g
K+
k
g Ak
(6)
K
k
+ 1)B + ( + 1)Ak
g
g
m (1
")
m) loge g) + (8(r
g (m)
m+ 12 )g loge g
1)g m ) = logg (g
(7)
1) + m, we
1
m + )g loge g) logg r
2
(8)
12
INTEGERS: 14 (2014)
Corollary 3.7. Let g
g (n)
g (n)
8gloge g
g ( g (n))
i.e., the proportion of integers not satisfying this inequality goes to zero when n goes
to infinity.
4. Open Questions
Many questions regarding 2-addition chains remain unsettled. Their g-analogs seem
interesting and are at least as hard.
Recall the Scholz-Brauers conjecture [9], concerned with the worst case behavior
of the 2-ary method when g = 2: the conjecture states that for all n 1,
l2 (2n
1) n
1 + l2 (n).
Brauer [2] and Hansen [7] established a similar inequality, where certain restrictions
are imposed on the 2-addition chain, yet the conjecture remains open. What can
we say about
lg ((g n 1) + (g + 2g 2 + + (g 2)g g 2 ))
which seems to be the worst case for the g-ary method?
The conjecture
l2 (n)
2 (n) + dlog2 (2 (n))e
also remains open, although Sch
onhage showed that
l2 (n)
2.13e
q0 q0
qk1 qk2 ,
qi qj ,
k1 , k2 < k,
i, j < l2 (d).
INTEGERS: 14 (2014)
13
Obviously, lg (d) for g > 2 captures the optimum length of such a {}-program for xd
in which each step now carries out the product of up to g factors. More interestingly,
{+, , }-programs, in which the initial polynomials are 1 and x and a step can
now perform qi + qj or qi qj or qi qj , are a crucial object of study in algebraic
complexity theory [3]. A peripheral yet nagging question in that model has remained
open since the 1970s [1, p. 26]: does there exist a polynomial q 2 Z[x] computable
by a {+, , }-program that uses fewer than l2 (degree(q)) product steps? The
answer at first glance is a resounding no, until one realizes that cancellation of
terms of degree higher than degree(q) could be helpful. Such a possibility is tied
to the behavior of the l2 (d) function. The same question now arises in the setting
generalized to g-ary {+, , }-programs and lg (d) for g > 2.
Acknowledgment We would like to thank Andrew Granville for his contribution
to the proof of Theorem 3.6 and Michel Boyer for some meticulous remarks on the
document [4] which was the starting point of the present paper.
References
[1] A. Borodin and I. Munro. The computational complexity of algebraic and numeric problems. Elsevier Computer Science Library, Theory of Computation Series. American Elsevier,
(1975).
[2] A. Brauer. On addition chains. Bull. Amer. Math. Soc., 45 :736739, (1939).
[3] P. Burgisser, M. Clausen, and A. Shokrollahi. Algebraic Complexity Theory. Grundlehren
Math. Wiss. Springer, (1997).
[4] Y. Elias. Repr
esentation dun polyn
ome par un circuit arithm
etique et chanes additives.
Masters thesis, Universit
e de Montr
eal, (2011).
[5] P. Erd
os. Remarks on number theory. III. On addition chains. Acta Arith., 6:7781, (1960).
[6] A. Flammenkamp. http:// wwwhomes.uni-bielefeld.de/ achim/ addition chain.html, (2011).
[7] W. Hansen. Zum Scholz-Brauerschen problem. J.Reine Angew. Math., 202:129136, (1959).
[8] D. E. Knuth. The Art of Computer Programming Vol. II: Fundamental Algorithms. AddisonWesley, (1997).
[9] A. Scholz. Jahresber. dtsch. math.-ver. Theot. Comput. Sci., 47 :4143, (1937).
[10] A. Schonhage. A lower bound for the length of addition chains. Theoret. Comput. Sci.,
1:112, (1975).