Skip to main content
gamedev.net
🔒 Locked

Addition chains?

Started by Nice Coder 3 replies 1.1k views
Original Post
Nice Coder
Nice Coder
I was doing some addition chain exponentiation, and i was wondering: How can i make addition chains efficiently? From, Nice coder
Click here to patch the mozilla IDN exploit, or click Here then type in Network.enableidn and set its value to false. Restart the browser for the patches to work.
alvaro
alvaro
Do you mean sequences that start at 1 and in which every term is the sum of two of the preceding terms?

How big is the target number? (just a rough order of magnitude)
Nice Coder
Nice Coder
What difference does the order of the number make?

Is there a general purpose algorithm, or is there one for big numbers, and one for small numbers.

From,
Nice coder
Click here to patch the mozilla IDN exploit, or click Here then type in Network.enableidn and set its value to false. Restart the browser for the patches to work.
Punty50
Punty50
The repeated doubling until you create a term greater or equal to half of n, and then choosing the appropriate number of additional terms (given by the binary representation of n) gives you a means of having chains with length no longer than (2*log base 2 of n) - 1. Given that the obvious lower bound on the length of an addition chain is log n, you have the optimal length up to a constant factor.
Brendan"Mathematics is the Queen of the Sciences, and Arithmetic the Queen of Mathematics" -Gauss
Nice Coder
Nice Coder
ok, thanks.

How do i go and select the extra terms?

From,
Nice coder
Click here to patch the mozilla IDN exploit, or click Here then type in Network.enableidn and set its value to false. Restart the browser for the patches to work.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.