Introduction
I stumbled across an interesting paper, which shows that you can multiply two numbers by using the Collatz conjecture (and assuming it to be true for the numbers you are dealing with).
This post contains my summary and understanding of how this method works.
Background
Collatz conjecture
Definition
The Collatz conjecture, also known as the
- If the number (
n ) is even, divide it by two:\frac{n}{2} - If the number (
n ) is odd, multiply it by 3 and add one:3n + 1
The number will eventually land in the cycle
The rule can be mathematically written as:
Examples
5 16 8 4 2 1 (cycle starts)
9 28 14 7 22 11 34 17 52 26 13 40 20 10 (use above)
Method
Definitions
Collatz Function
Define the Collatz function,
Given
\text{ctz}(x) gives the number of factors of 2 in a number, i.e. count the trailing zeros of a number in binary
Collatz sequence and k
- The Collatz sequence, is the sequence of numbers produced by the Collatz
function until it reaches the number
1 for the first time - Define
k as the number of steps until the Collatz series lands on1
In other words, the Collatz sequence can be shown mathematically like so:
How to Divide: \frac{m}{a}
Let's multiply the Collatz function series by
Let
NOTES:
Assuming
- Start with
m - Use
G(m) until we get toa - Record what we've done to get there
- i.e. save the result of
\text{ctz}(3x + 1) along the way andk (the number of steps)
- Backtrack using the same form of operations (in reverse) with
F(x) whilst starting at1
i.e. we have a division algorithm using the Collatz conjecture
How to Multiply: ax
Now, how do we multiply? Simple:
- Start with
x and useF(x) until we get to1 - Record what we've done (save the
k steps)
- Record what we've done (save the
- Now, start with
a and backtrack withG(x) (with the savedk steps), which will get us toax