*** Welcome to piglix ***

Addition chain


In mathematics, an addition chain for computing a positive integer n can be given by a sequence of natural numbers v and a sequence of index pairs w such that each term in v is the sum of two previous terms, the indices of those terms being specified by w:

Often only v is given since it is easy to extract w from v, but sometimes w is not uniquely reconstructible. The length of an addition chain is the number of sums needed to express all its numbers, which is one less than the cardinality of the sequence of numbers. An introduction is given by Knuth.

As an example: v = (1,2,3,6,12,24,30,31) is an addition chain for 31 of length 7, since

Addition chains can be used for addition-chain exponentiation: so for example we only need 7 multiplications to calculate 531:

Calculating an addition chain of minimal length is not easy; a generalized version of the problem, in which one must find a chain that simultaneously forms each of a sequence of values, is NP-complete. There is no known algorithm which can calculate a minimal addition chain for a given number with any guarantees of reasonable timing or small memory usage. However, several techniques to calculate relatively short chains exist. One very well known technique to calculate relatively short addition chains is the binary method, similar to exponentiation by squaring. Other well-known methods are the factor method and window method.

Let denote the smallest s so that there exists an addition chain of length s which computes n. It is known that


...
Wikipedia

...