New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ulam / Hailstone / Collatz (3n+1) sequence #866

Open
metawops opened this Issue Jan 18, 2019 · 6 comments

Comments

Projects
None yet
3 participants
@metawops
Copy link

metawops commented Jan 18, 2019

Currently, it’s not possible to define the „hailstone numbers“ sequence where

u(n+1) = 3*u(n)+1, if u(n) is odd,
u(n+1) = u(n)/2, if u(n) is even.

Please allow for such kinds of sequences.

@boricj

This comment has been minimized.

Copy link
Contributor

boricj commented Jan 18, 2019

It is possible to define such a sequence, like so: u(n+1)=(3*u_n)rem(u_n,2)+(u_n/2)rem(u_n+1,2).

However, just because we can work around epsilon's limitations through creative abuse of existing functions doesn't mean we should settle for this.

@metawops

This comment has been minimized.

Copy link
Author

metawops commented Jan 18, 2019

Hey, that's a cool hack! (You missed that +1, though, in the odd part ... 😉)

Too bad it's not possible to tell the system to stop after a loop. (This sequence always ends in the loop 4-2-1 – which is still unproven, btw.!)

@metawops

This comment has been minimized.

Copy link
Author

metawops commented Jan 18, 2019

There are no other graph styles, right? Like a bar graph or a line graph for sequences ...? 😳😞

@metawops

This comment has been minimized.

Copy link
Author

metawops commented Jan 18, 2019

It is possible to define such a sequence, like so: u(n+1)=(3*u_n)rem(u_n,2)+(u_n/2)rem(u_n+1,2).

However, just because we can work around epsilon's limitations through creative abuse of existing functions doesn't mean we should settle for this.

True, especially because this hack only works for this special kind of sequence where the two parts of the definition correspond to odd and even numbers which can be simulated via the rem(p,q) function. However, generic multi-part-definitions with arbitrary conditions won't always be possible by means of such a hack. 😉

@metawops

This comment has been minimized.

Copy link
Author

metawops commented Jan 18, 2019

Also, what's the maximum value in a given interval would be an interesting fact to know.
And how many steps were neccessary to reach a certain sequence value or loop (like 4-2-1) would be nice to know ... 😉

@AlainBusser

This comment has been minimized.

Copy link

AlainBusser commented Jan 30, 2019

You can program this sequence in Python. I did it for a slightly simpler variant : https://workshop.numworks.com/python/alain-busser/collatz
By the way Ulam did not discover this sequence, the idea came to Collatz in the 1930s while he was working on his PhD. Hasse made the sequence known to american mathematicians at Syracuse University during the 1950s.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment