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

General Programming Discussion

7785 readers
1 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
top 1 comments
sorted by: hot top controversial new old
[–] xhduqetz@lemmy.ml 1 points 1 year 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.