3 ms·
For fun I went ahead and wrote a little javascript to calculate the sequence. I realized that a lot of work would end up repeated as soon as you encountered an
by brundolf 6y ago
For fun I went ahead and wrote a little javascript to calculate the sequence. I realized that a lot of work would end up repeated as soon as you encountered an earlier number again (it's directed-graph traversal, really), so it records the ones that it's solved and bails out when it finds them again (denoted by the ->). You can paste the following into your browser console to get a feel for what it looks like.
let memo = {}
function conjecture(n) {
let str = "";
while (n !== 1) {
str += n + " ";
if (memo[n] != null) {
str += "->";
return str;
} else {
if (n % 2 === 0) n = memo[n] = n / 2;
else n = memo[n] = n * 3 + 1;
}
}
str += n + " ";
return str;
}
function rangeTo(end) {
return new Array(end).fill(null).map((_, i) => i + 1)
}
for (const n of rangeTo(1000)) {
console.log(conjecture(n))
}
A neat thing is that this terminates (at 1) for seemingly every number you try (I disabled console-logs and the process terminated for every number up to a range of 10,000,000, which is as high as I tested). It's just the formal proof that missing. There also seems to be a vague pattern to the results, but that may just be cloud-pictures.
- rowanG077 6y agoJust to let you know the memoization technique you used is called dynamic programming.
- brundolf 6y agoI'm aware, I was just commenting on it as an interesting trait of the problem. There might be an n+1 aspect, where if you can prove that each sequence will eventually reach some previous number that reduces to 1 then that higher one will too
- nickysielicki 6y ago"Dynamic programming" is such a dumb name for what it is and I hope that we can all eventually stop calling it that.
- WORLD_ENDS_SOON 6y agoThe history behind the term is pretty interesting to me: https://en.wikipedia.org/wiki/Dynamic_programming#History https://en.wikipedia.org/wiki/Dynamic_programming#History The original research on the subject was published in engineering / optimization as opposed to computer science, and the term "programming" was used differently there ("linear programming" and "quadratic programming" for example). Now we think of it not as an optimization problem but as an algorithm design technique, but the name still stuck around.
- waterhouse 6y agoEmphatically agreed. For those not aware, the person who chose the name (for what were originally called "multistage decision processes", which is far more descriptive) says he chose "dynamic" in significant part because it sounded impressive to a hard-nosed boss: "... It also has a very interesting property as an adjective, and that is it's impossible to use the word dynamic in a pejorative sense. Try thinking of some combination that will possibly give it a pejorative meaning. It's impossible. Thus, I thought dynamic programming was a good name. It was something not even a Congressman could object to. So I used it as an umbrella for my activities." https://en.wikipedia.org/wiki/Dynamic_programming#History https://en.wikipedia.org/wiki/Dynamic_programming#History Also, by the way, to the extent that "dynamic programming" has a definition (the words have little to do with what it means, so it's hard to fix the term to a specific definition), it generally refers to a superset of memoization. So memoization is the more specific term, and should be preferred. I think we may be able to help kill usage of the term by observing that its initialization, DP, which some people are fond of using, has a much more graphic alternate meaning. Then modern puritanism may make people reluctant to say it anymore.
- smabie 6y agoA recursive memorized solution would be more elegant. Or even a mutually recursive solution.
- schoen 6y ago> the process terminated for every number up to a range of 10,000,000, which is as high as I tested Other people have taken this experiment a bit further already: https://en.wikipedia.org/wiki/Collatz_conjecture#Experimental_evidence https://en.wikipedia.org/wiki/Collatz_conjecture#Experimenta... > As of 2020, the conjecture has been checked by computer for all starting values up to 2⁶⁸.
- thomasahle 6y ago> the process terminated for every number up to a range of 10,000,000, which is as high as I tested. It's just the formal proof that missing. As well as the rest of the numbers between ten million and infinity. And I suppose, an understanding of why.
- vecter 6y ago> It's just the formal proof that missing. That's the only thing that actually matters. You've demonstrated something analogous to the following: "Claim: there are no numbers larger than 100,000,000,000,000,000." You've then gone and checked all the numbers from 1 to 10 million, concluded that it's true, and then just say that we're missing a formal proof. I don't mean to be rude, but from an actual mathematical point of view, you've basically demonstrated nothing. 10 million is mindboggling tiny when it comes to all the numbers. Consider this counterexample to Polya's conjecture: https://www.youtube.com/watch?v=eQCUPQdi6DY https://www.youtube.com/watch?v=eQCUPQdi6DY Or so many other examples: https://math.stackexchange.com/questions/514/conjectures-that-have-been-disproved-with-extremely-large-counterexamples https://math.stackexchange.com/questions/514/conjectures-tha...
- throwaway357920 6y ago>Claim: there are no numbers larger than 100,000,000,000,000,000. https://en.wikipedia.org/wiki/Ultrafinitism https://en.wikipedia.org/wiki/Ultrafinitism
- brundolf 6y ago> I don't mean to be rude Well that's how it comes off. Obviously I didn't think I'd made some breakthrough in five minutes with some JavaScript, and obviously I know that the formal proof is the important thing. I was just poking at the phenomenon and expressing my curiosity. There's no need to be so eager to jump in and shut that down.