4 ms·
After watching this video, how many of us wrote a program to see if we could just randomly find a case which didn't converge? I wrote one, but of course, the pr
by hashmash 5y ago
After watching this video, how many of us wrote a program to see if we could just randomly find a case which didn't converge? I wrote one, but of course, the program didn't prove the 3x+1 problem wrong.
- malux85 5y agoHahahaha I came here to see if anyone else did this! I didn’t think that a bit of coding was going to outpace hundreds of years of genius mathematicians - but a few minutes coding was a cheap price to pay to satisfy that ceaseless curiosity
- WJW 5y agoI wrote one many years ago as part of going through (I think) the project Euler series. No hope of actually solving it ofc. It's a fascinating problem because it just seems so simple. I wouldn't be surprised if it turns out in the end that it's connected to some other seemingly unrelated (lack of) order in mathematics like prime numbers or whatnot.
- monopoledance 5y agoTwin primes come to mind. Feels very similar in nature. Overall, there might be a connection to complex systems and ontogenesis. Maybe our struggling with this is all down to some original sin in our perception. Some false axiom we all carry. Pathogenic, hereditary logic, which prevents us from seeing beyond the chaos. 3x+1 seems to capture the pleasing ordered imperfection of real living things, not artificial "organic" structures made by humans. Unrelated: https://www.bigbiology.org/season-2#episode39 https://www.bigbiology.org/season-2#episode39
- Twirrim 5y agoLikewise, but more as a way to experiment with a big integer crate for rust.
- lapetitejort 5y agoI wrote one years ago, and whenever I got bored I'd revisit it and tweak certain things. Weird thing is, I felt like I found a reproduceable pattern in how numbers converged. Unfortunately I haven't been able to effectively communicate the pattern and I don't have the mathematical know-how to google for it.
- deleted 5y ago[deleted]
- threatofrain 5y agoPeople have been brute forcing the Collatz problem for awhile (up to values around 2.95×10^20); just like computing Pi to set glory records, you have to be prepared to rent Amazon hardware. I think there was a proof that demonstrated that if the Collatz conjecture were false, then the cycle has to be immensely large.
- imperialdrive 5y agoI know so little about programming but this video absolutely left me up late trying to follow along: $count = 1 do { $count++ $i = $count [string]$array = "$i" $range = $i - 1 do { if ($i % 2 -eq 0) {$i = $i / 2} else {$i = (3 \* $i) + 1} $array = "$array" + ",$i" if ($i - $count -gt $range) {$range = $i - $count} if ($i -eq 2) {$i = "Break"} } while ($i -ne "Break") $array = "$array" + ",1" $hits = (($array -split ",") | Measure-Object).count Set-Content -Path "${count}_${hits}Hits_${range}MaxRange.txt" -Value "$array" -NoNewline -Force } while ($count -lt 1000) Does anyone know how to make this work with big numbers? At a certain point the value gets returned with something like 2.05891132094649E+44 at which point I can no longer simply add 1 to it. Edit: Found it... $count = [bigint][math]::pow(10,44) Awesome! I love code!
- mgarciaisaia 5y agoI found in Wikipedia that Somebody Else™ checked that there are no counterexamples up until 2^68. So my attempt to find a counterexample is to start at (2^68)+1, and perform the 3x+1 or halving until I get to a number that's lower than the one I'm testing - then I know it's not a counterexample. Since even numbers start by halving (ie, getting lower), I only test odd numbers. 295147905503560000001 and counting. No counter-examples found yet.
- bob1029 5y agoHere's a C# example: using System.Numerics; using System; var myBigStartingNumber = BigInteger.Parse("12893123812148934789012378957891325789012357891238912319824589123589012358915891589158989125"); Collatz(myBigStartingNumber); Console.WriteLine("Collatz returned 1"); static int Collatz(BigInteger x) { Console.WriteLine(x); return x == 1 ? 1 : x % 2 == 0 ? Collatz(x / 2) : Collatz(3 * x + 1); } (stack overflows virtually guaranteed!)
- vintermann 5y agoYes, unless C# does tail call elimination (it doesn't, right? I'm a bit behind the times on such things) that will blow through the stack very quickly. But something which is worth doing while playing with such programs, (besides writing it nonrecursively), is looking into alternative BigNum representations. Tree based number representations can make huge numbers expressible through few operations much smaller, at the cost of making "typical" numbers (those that can't be expressed by arithmetic expressions much shorter than themselves) only slightly larger. Knuth made one such representation, called TCALC, which lets you do arithmetic on numbers far too large to fit into computer memory in regular byte string bignum representation. A US academic, Paul Tarau, has made similar huge-num libraries (slightly more elegant since representations are unique) for modern programming languages.
- mcphage 5y agoThere’s a problem that’s simple to state: find positive integers A, B, and C such that: A/(B+C) + B/(A+C) + C/(A+B) = 4 It seems simple, like you could try a few examples and figure it out. And there is a solution. But for the smallest solution, A, B, and C each have 80 digits. Way too big to brute force.
- Jyaif 5y agothe video addresses this: you are very unlikely of finding a case that does not converge by chance.
- deleted 5y ago[deleted]
- D7x7w9pHnT 5y agolol totally Did this in Haskell, and since all the lower numbers are known, started searching at 2^361 To end the recursion I just have it print -1 when it reaches 1 f :: Integer -> Integer f n | n == 1 = -1 | even n = f (n `div` 2) | odd n = f (3*n + 1) main = print $ map f [2^361..]
- ryankrage77 5y agoHere's my attempt in python, https://gist.github.com/ryankrage77/345419fd223a8029699e12ee609dc794 https://gist.github.com/ryankrage77/345419fd223a8029699e12ee...