An addition-subtraction chain, a generalization of addition chains to include subtraction, is a sequence a0, a1, a2, a3, ... that satisfies
An addition-subtraction chain for n, of length L, is an addition-subtraction chain such that
By definition, every addition chain is also an addition-subtraction chain, but not vice versa. Therefore, the length of the shortest addition-subtraction chain for n is bounded above by the length of the shortest addition chain for n. In general, however, the determination of a minimal addition-subtraction chain (like the problem of determining a minimum addition chain) is a difficult problem for which no efficient algorithms are currently known. The related problem of finding an optimal addition sequence is NP-complete (Downey et al., 1981), but it is not known for certain whether finding optimal addition or addition-subtraction chains is NP-hard.
For example, one addition-subtraction chain is:
Like an addition chain, an addition-subtraction chain can be used for addition-chain exponentiation: given the addition-subtraction chain of length L for n, the power
Some hardware multipliers multiply by n using an addition chain described by n in binary:
n = 31 = 0 0 0 1 1 1 1 1 (binary).Other hardware multipliers multiply by n using an addition-subtraction chain described by n in Booth encoding:
n = 31 = 0 0 1 0 0 0 0 -1 (Booth encoding).