I'm trying to solve the Collatz conjecture, and am having some trouble designing a function that divides a number by two until it's odd.
Here is what I've thought of.
We know $a\mod b = \arctan(\tan(\frac{a\pi}{b}-\frac{\pi}2))\frac{b}\pi + \frac{b}2 $
Thus,
$$f(x) = \frac{x}2 + \frac{x}2(x \mod 2) = \frac{x}2 + \frac{x}2(arctan(\tan(\frac{x\pi}{2}-\frac{\pi}2))\frac{2}\pi + \frac{2}2) = \frac{x}2 + \frac{x}2(arctan(\tan(\frac{x\pi}{2}-\frac{\pi}2))\frac{2}\pi +1)$$
What would this do? This function would return half the number, if $ x \mod 2 = 0$, else, return the whole number, because it's already odd.
The thing is, if I want to make sure any number is odd, I'd have to iterate this infinite times. I know some functions are easily iterated, but can all functions be iterated in theory? I know it may be hard, but the whole conjecture is tough by itself, so I don't really care.
One extra question, notice
$$a\mod b = \arctan(\tan(\frac{a\pi}{b}-\frac{\pi}2))\frac{b}\pi + \frac{b}2 = (\frac{a\pi}{b}-\frac{\pi}2)\frac{b}\pi + \frac{b}2$$
Is this simplification correct?
EDIT: The simplification collapses to $ a \neq a \mod b$, so that's out of the question.

