i was not expecting to see WYSI in a section of this video wtf
@treelibrarian7618Сағат бұрын
(before watching for your solution) since the fibonacci sequence simplifies to just a+=b; b+=a; and each of those is a single add instruction which takes 1 cycle, you should be able to get 1 number per cycle... except you run out of bits in a u64 after 93 numbers... so using adc's for additional bits will allow 128 bit math in 2 cycles (and due to how CPU's work it'll be able to do 2,3,4 additions concurrently) until you run out of GPR registers (7 pairs useable) which would get you up to fib(651) in a still very tiny amount of time... (93*(1+2+3+4+5+6+7)/4=651 clock cycles estimated) from here, perhaps using memory and GPR's will work best for ever increasing lengths of numbers (increase by 64 bits each time it overflows after 93 iterations). This ends up limited by write bandwidth to 1 op/cycle, so the overall N in 1 sec ends up being sqrt((clocks/sec)*2/93)*93. for my 4.4GHz cpu that would be fib(904654), with the numbers being 622558 bits long by the end... now to watch the vid...
@Charky32Сағат бұрын
Was studying this kinda stuff this year, didn't think I'd see it outside of university, nice video
@MasterhaendСағат бұрын
4:31 math jumpscare
@adnzip8198Сағат бұрын
Maybe I should go back to my trig identities...
@KaelygonСағат бұрын
This sounds similar to a side project I had. I wanted to find positive integer solution for d^3 = a^3 + b^3 + c^3 where d=13238717 . This took 8 hours to compute as I couldn't figure any better solution than big O(n^2). Where I searched a,b and then calculated c by newton's method, but at least it was faster than the naive approach which i estimated to take 3000 years to calculate which was O(n^3).
@lel7531Сағат бұрын
Gauss discovering the Fourier Transforms good one
@adampaul7905Сағат бұрын
Dark blue is really not a good choice for a black background
@le90382 сағат бұрын
My disappointment is immense for I believed you used your intelect to compute and therefor, my day is ruined.
@yarno80862 сағат бұрын
Great video!
@wimtek52802 сағат бұрын
i understood something until like 1/3 of a video but graphs were vibin'
@spaghetticapellini16163 сағат бұрын
I just stumbled upon your channel on my recommended page after prepping for a probability exam and oh boy what a great find this is! Please please please make more!!!
@TerjeMathisen3 сағат бұрын
Very nice! I spent the first 20 minutes or so waiting for the Binet formula, did not expect you to get close to the limit for fft multiplication...
@omarsamraxyz3 сағат бұрын
I'm so happy! You're begging to get the recognition you deserve!
@GewoonFinn-3 сағат бұрын
Chemical engineer confused in chemical engineering
@r75shell3 сағат бұрын
I don't like explanations of asymptotics, because nowhere mentioned that number of digits in fibonacci number is O(n). I'm also lazy to verify statements about asymptotics so... whatever.
@samucinko81243 сағат бұрын
Amazing channel!
@nekko26453 сағат бұрын
17:27 no way its an osu reference
@MoreDenseThanRationals3 сағат бұрын
I was watching it without headphones and it took me a good ten minutes to figure out where the cat sounds were coming from
@Gbriel_rbl3 сағат бұрын
Subbed instantly, great video!
@user-fp8zc3mx3e4 сағат бұрын
based
@seanseal62654 сағат бұрын
I giggled at a big faster but it took a second
@lesliejohnrichardson4 сағат бұрын
I'd love to see this again but for a larger time frame and/or other algorithms/concepts
@CraigGidney5 сағат бұрын
The identity F_{3n} = 5F_n^3 - 3F_n for odd n could be used to climb in base 3 while only using one accumulator value (instead of two like in the 1,sqrt(5) ring) with the only expensive step being the cubing. Doing the cubing via FFT multiplication like you do in the video should only take one FFT and one inverse FFT.
@RishabhBohra135 сағат бұрын
You'll reach 1M subs soon. Remember Me.
@dangernoodle03786 сағат бұрын
Not to be "that" mathematician, but why not just use the explicit formula for Fibonacci numbers? Not only is it super interesting in its own right (because in some sense it extends the sequence to the complex field) but also it allows you to compute an arbitrary Fibonacci number with one operation. Granted the formula's a bit messy, but still
@dangernoodle03786 сағат бұрын
For those interested, the relevant formula is called Binet's formula, and can be derived as the solution of a set of difference equations
@keef0r206 сағат бұрын
What about an alterate approach to this question. Since we are doing a running calculation and stopping after 1 second, what if we start at a known Fibonacci number and calcuate the next one? What then would be the largest that could be calcuated in 1 second?
@muhammadmonib4886 сағат бұрын
The matrix diagonalization would be the first thing I thought about post-linear algebra class 😂
@the_emoreira6 сағат бұрын
This is such a cool video. Have you thought about doing tricks with modulo arithmetic? I mean calculating Fib(n) in O(log(n)) time modulo some prime P. If you do that for a list o M primes P1, P2, ... , PM, you can recover the actual number mod (P1 * P2 * ... * PM) with the Chinese Remainder Theorem for a total runtime of O(M * log(n)) + O(M * multiplication). I think this could be a cool way of computing large numbers.
@user-jx4bl6yk6w6 сағат бұрын
Please gib resources to understand this spaghetti of awesomeness
@DustinRodriguez1_06 сағат бұрын
"Memoisation" is, in fact, a typo. It's memoization.
@whatinthesam6 сағат бұрын
Nitpick (and I might be wrong) but at ~7:40 wouldn’t the big O be O(nm)? Here n is the number of Fibonacci numbers you need to calculate and m is the number of digits to sum. The reason you don’t just say n squared is because m might be related to n in a non linear way. E.g. if the digits to sum were on the order of log(n) then the total big O would be nlog(n). The system is definitely super linear but not necessarily quadratic.
@official-obama6 сағат бұрын
man, i managed to predict most of the plot twists!
@chubphd7 сағат бұрын
“[It] is known as the Cooley-Tukey algorithm, so-called because these insights are due to none other than the same person who discovered the Fourier transform… Gauss.” LMAOOO
@ijosakawi7 сағат бұрын
It's interesting how if you only compute values that are direct powers of two, it gets much more efficient to computer larger values. You can keep a running matrix for the matrix-based algorithm, square it as many times as you can in a single second, and then multiply it by the final [0 1]. A crude JavaScript implementation gets you the 2^25th fibonacci numbers, or 33,554,432. // square the matrix function s([a, b, c, d]) { return [a*a+b*c, a*b+b*d, c*a+d*c, c*b+d*d] } // run the algorithm for a given amount of time function run(time) { const end = Date.now() + time let c = [0n, 1n, 1n, 1n] let x = 0 while (Date.now() < end) { c = s(c) x += 1 } return [c[1], x] // c[1] is the value, x is the power of two it got to } run(1000)
@AntonBourbon7 сағат бұрын
A 13-line Python program below calculates Fibonacci(2^27) (that's *134,217,728th Fibonacci number* ) in ~1.04 seconds on my desktop PC built in 2013. In 2024, any decent laptop will be under 1 second. When you get older, you'll *likely* learn Lesson N+1: however smart ( _you think_ ) you are, there are people smarter than you (especially those _mathematicians who can't program_ ) who have already implemented in fast and tested code (libraries) something, even approaching what will take you months of hard work. And using those libraries will save you those months. The Python code: from gmpy2 import mpz def fibo(n: int): f = mpz(1) L = mpz(3) two = mpz(2) for k in range(n.bit_length() - 2): f *= L L *= L L -= two return f fibo_n = fibo(1 << 27)
@user-ny5hh9wv3l7 сағат бұрын
The reasoning at 8:16 feels wrong - To me this sounds like “This statement is disprovable if we add this one rule, so if we remove this rule, we are no longer able to verify it”, like, if I want to prove if Goldbach Conjecture is unprovable, then I add a rule say that “Goldbach is false”, which it obviously is in that ruleset, and then I remove that rule, thus complete the proof that Goldbach is unprovable? Thank you.
@blamethefranchise14737 сағат бұрын
18:30 radiohead reference
@Kreypossukr7 сағат бұрын
« Merci d’avoir regardé » ?? Wtf man I didn’t click on this video to be insulted in my own language !!
@idontknowanygoodnames14987 сағат бұрын
C++ constexpr laughing rn
@thomasthevenon9487 сағат бұрын
By the way, the following code: ```hs import Data.Semigroup data FibM = FibM Integer Integer instance Semigroup FibM where (FibM a b) <> (FibM c d) = FibM (a * c + b * d) (b * (c - d) + a * d) instance Monoid FibM where mempty = FibM 1 0 fib :: Integer -> Integer fib n = (\(FibM a b) -> b) $ stimesMonoid n (FibM 1 1) main = print . fib . read =<< getLine ``` Took a measured 180 milliseconds (using my Surface Pro 7 with an i5-1135G7) to calculate the 4192540th fib number and write it to a file (I assume input handling and displaying the string takes a fairly long time here). I measured 80 milliseconds in GHCi to calculate the log base 10 of this value. I get 876188, with the first digits being "4917774873...." (Of course since this uses GMP you might consider this cheating somewhat, but the code is very short).
@anthonyrolland14687 сағат бұрын
The exact kind of KZbinr I want to be. Love this content
@mattgsm8 сағат бұрын
Have you considered putting this into the SoME4 event?
@chikianglim36328 сағат бұрын
I like your funny symbols magic man
@sieni2218 сағат бұрын
Ive seen the matrix algorithm in matlab class during undergrad.
@lolfunne8 сағат бұрын
spoiler alert: this video is 25:55 minutes long, not 1 second. unsubscribed