Log in

No account? Create an account
The Collatz function and random meanderings thereupon. - Adventures in Engineering — LiveJournal
The wanderings of a modern ronin.

Ben Cantrick
  Date: 2008-11-22 01:57
  Subject:   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.

http://www.walterzorn.com/grapher/grapher_e.htm 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 Comment | 1 Comment | | Link

  User: nickhalfasleep
  Date: 2008-11-23 04:04 (UTC)
  Subject:   (no subject)
I think the if.. else construct of mathematics cannot always be easily turned to a discrete function, and % itself is a rather unusual mathematical function but a common digital one. And sometimes you want the discrete boundaries of a function to be that way for a reason.
Reply | Thread | Link

May 2015