Ben Cantrick (mackys) wrote,
Ben Cantrick

The Collatz function and random meanderings thereupon.

We take any whole number N, greater than 0. If N is even, we halve it (N/2), else we do "triple plus one" and get 3N+1. Repeat. The conjecture is that for all numbers this process converges to 1.

I don't like mathematical equations formulated with "if ... else ..." constructs. They're not amenable to algebraic manipulation. Let's reformulate the Collatz function as a sum:

f(n) = ((3n + 1) * n%2) + (n/2 * (1 - n%2))

How does this work? When n is even, n%2 will be zero, and the (3n + 1) half of the equation will become zero also. When n is odd, (1 - n%2) will be zero, and the n/2 half of the equation will become zero.

Now we can do algebra.

Also, we can graph the function. That is, if we can find a graphing calculator that doesn't puke all over itself when asked to compute a modulo. You'd be shocked how many online graphics calcs can't handle that. (Yes, I know you can synthesize (a mod b) from (a - b * floor(a/b)) - perhaps you could tell that to the people who make graphing calc programs without modulo?) Of course, my old HP-48 GX does it just fine. But I guess matching the functionality of a calculator made 15 years ago (srsly, 1993!) was just too hard for them. will graph it:

(Warning - it will also crash your browser constantly. Gotta love JavaScript.)

Some very interesting self-similarity there. You think there's fractal nature in this equation? Yup!

Also interesting to me is that the function seems to have a very linear envelope, top and bottom. The top bounding line seems to have a slope of about 5.4 and the bottom one about 0.5.

What does all this prove? Absolutely nothing. (Well, okay, the fact that I'm graphing the Collatz function on a Friday night might prove that I'm a huge nerd...)
  • Post a new comment


    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 1 comment