User talk:Krypton Liverwurst

Partition function (number theory)
Hi! I reverted your edit on Partition function (number theory). The previous version was correct, the bounds for $$k$$ are not symmetrical. They can be derived from $$n-k(3k-1)/2 \geq 0$$ using the quadratic formula. — Chrisahn (talk) 11:39, 3 September 2023 (UTC)


 * Are you sure about that? I used the recurrence relation to code a recursive function, and I got a different answer to p(100) than the one on the wiki page. But when I changed the bounds, it gave me the correct answer. Krypton Liverwurst (talk) 19:10, 3 September 2023 (UTC)


 * I'm sure about the bounds, their derivation is pretty simple. I guess there's a rounding error in your code, possibly in the square root function – some math libraries might produce e.g. 48.99999... for sqrt(2401). I just wrote this bit of code which uses the correct bounds, and it produces the correct results on my machine. — Chrisahn (talk) 21:14, 3 September 2023 (UTC)
 * Oops! My bad! :) I think you're right.. In my version of the code, the variable `s` was divided by 6. Then `kmin` and `kmax` were `1/6-s` and `1/6+s` respectively. That didn't work, so I 'fixed' it by changing `kmin` to `-(1/6+s)`. I was convinced that must be right, because I even used that code to find the number from this puzzle here (https://projecteuler.net/problem=78). However, it seems that distributing the fraction was the bug in my code: https://godbolt.org/z/Gva6KhKxY... :/ Krypton Liverwurst (talk) 07:28, 4 September 2023 (UTC)


 * Oh, the joys of floating-point arithmetic! The results start to go wrong at n=7, because  is , but   is  . :-) https://godbolt.org/z/8x36vhG5T — Chrisahn (talk) 08:04, 4 September 2023 (UTC)