this post was submitted on 07 Nov 2023
-5 points (27.3% liked)

General Programming Discussion

7728 readers
14 users here now

A general programming discussion community.

Rules:

  1. Be civil.
  2. Please start discussions that spark conversation

Other communities

Systems

Functional Programming

Also related

founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] xhduqetz@lemmy.ml 1 points 10 months ago

At the same time, it is also worth noting that the closed form formula is working with irrational numbers which can only be represented approximately in computers, and thus in some rare cases the method may produce incorrect result due to approximation errors.

I'm nitpicking, but golden ratio can actually be represented exactly in computers. This is because the golden ratio is not merely an irrational number, but also an algebraic number. By definition, any real algebraic number can be represented as an integer vector, which contains a polynomial and two rationals that identify a root of the polynomial. Alas, the multiplication of algebraic numbers is quite involved and certainly far slower than the linear algebra approach for Fibonacci numbers.