Addition-chain Exponentiation

In mathematics and computer science, optimal addition-chain exponentiation is a method of exponentiation by positive integer powers that requires a minimal number of multiplications. It works by creating a shortest addition chain that generates the desired exponent. Each exponentiation in the chain can be evaluated by multiplying two of the earlier exponentiation results. More generally, addition-chain exponentiation may also refer to exponentiation by non-minimal addition chains constructed by a variety of algorithms (since a shortest addition chain is very difficult to find).

The shortest addition-chain algorithm requires no more multiplications than binary exponentiation and usually less. The first example of where it does better is for a15, where the binary method needs six multiplies but a shortest addition chain requires only five:

(binary, 6 multiplications)
(shortest addition chain, 5 multiplications).
Table demonstrating how to do Exponentiation using Addition Chains
Number of
Multiplications
Actual
Exponentiation
Specific implementation of
Addition Chains to do Exponentiation
0 a1 a
1 a2 a × a
2 a3 a × a × a
2 a4 (a × a→b) × b
3 a5 (a × a→b) × b × a
3 a6 (a × a→b) × b × b
4 a7 (a × a→b) × b × b × a
3 a8 ((a × a→b) × b→d) × d
4 a9 (a × a × a→c) × c × c
4 a10 ((a × a→b) × b→d) × d × b
5 a11 ((a × a→b) × b→d) × d × b × a
4 a12 ((a × a→b) × b→d) × d × d
5 a13 ((a × a→b) × b→d) × d × d × a
5 a14 ((a × a→b) × b→d) × d × d × b
5 a15 ((a × a→b) × b × a→e) × e × e
4 a16 (((a × a→b) × b→d) × d→h) × h

On the other hand, the addition-chain method is much more complicated, since the determination of a shortest addition chain seems quite difficult: no efficient optimal methods are currently known for arbitrary exponents, and the related problem of finding a shortest addition chain for a given set of exponents has been proven NP-complete. Even given a shortest chain, addition-chain exponentiation requires more memory than the binary method, because it must potentially store many previous exponents from the chain simultaneously. In practice, therefore, shortest addition-chain exponentiation is primarily used for small fixed exponents for which a shortest chain can be precomputed and is not too large.

However, there are also several methods to approximate a shortest addition chain, and which often require fewer multiplications than binary exponentiation. Indeed, binary exponentiation itself is a suboptimal addition-chain algorithm. The optimal algorithm choice depends on the context (such as the relative cost of the multiplication and the number of times a given exponent is re-used).

Note that the problem of finding the shortest addition chain cannot be solved by dynamic programming, because it does not satisfy the assumption of optimal substructure. That is, it is not sufficient to decompose the power into smaller powers, each of which is computed minimally, since the addition chains for the smaller powers may be related (to share computations). For example, in the shortest addition chain for a15 above, the subproblem for a6 must be computed as (a3)2 since a3 is re-used (as opposed to, say, a6 = a2(a2)2, which also requires three multiplies).

Read more about Addition-chain Exponentiation:  Addition-subtraction–chain Exponentiation