# What is a Fibonacci Number?

Fibonacci numbers are the numbers in the Fibonacci sequence 0, 1, 1, 2, 3, 5, 8, 13, 21, . . . , each of which, after the second is the sum of the two previous ones.

Fibonacci numbers can also be considered as a function of non-negative integers:

### ``` n = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, ... F(n) = 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ... ```

The exact closed form solution for this function is called the Binet formula:

### ``` F(n) = (Phi^n ñ PhiP^n)/Sqrt(5) (good for all integer n >= 0 or n < 0), where Phi = (1 + Sqrt(5))/2 = the Golden Ratio = 1.61803398874989484820..., and PhiP = Phi Prime = (1 ñ Sqrt(5))/2 = 1 ñ Phi = ñ1/Phi = ñ0.61803398874989484820..., ```

Since F(n) is an integer and the magnitude of PhiP^n/Sqrt(5) is less than 1/2 for n >= 0, a variant form of the formula is:

### ``` F(n) = Round(Phi^n / Sqrt(5)), n >= 0. ```

If you have a Fibonacci Number you can compute its index, n = AFib(F(n)) or AFib(x) = ArcFibonacciNumber(|x|), an integer. The formula is:

### ``` AFib(x) = 0 if |x| < 1, else AFib(x) = Round(Ln(sqrt(5)*|x|) / Ln(Phi)). ```

For example, AFib(144) = 12. This is only accurate if x is a Fibonacci number.

Fibonacci numbers can also be defined for negative n:

### ``` F(ñ2*n) = ñF(2*n) F(ñ2*n ñ 1) = F(2*n + 1) n = ..., ñ6, ñ5, ñ4, ñ3, ñ2, ñ1, 0, 1, 2, 3, 4, 5, 6, ... F(n) = ..., ñ8, 5, ñ3, 2, ñ1, 1, 0, 1, 1, 2, 3, 5, 8, ... ```

Define IsFib(X) = 1 (True) if X is a Fibonacci number, else 0:

Set equal to 1 (True) if |x| is a Fibonacci number, else it is set to 0 (False). True iff x = 0 or z = |x| is an integer and the closed interval [Phi*z ñ 1/z, Phi*z + 1/z] contains a positive integer. Extra testing is performed if x < 0 and |x| is a Fibonacci number. 144, 233, and ñ144 are Fibonacci number, but ñ233 is not. For x < 0 to be a Fibonacci number, |x| must be a Fibonacci number and AFib(|x|) must be even.

IsFib2(X) = IsFib(X) by second method:

Same as IsFib(X) except true iff x = 0 or z = |x| is an integer and 5*x^2 + 4 or 5*x^2 ñ 4 is a perfect square.

The continuous analytic function:

### ``` Fe(x) = (Phi^x ñ 1 / Phi^x) / Sqrt(5), ```

passes through all Fibonacci numbers of even n = x (n positive or negative).

The continuous analytic function:

### ``` Fo(x) = (Phi^x + 1 / Phi^x) / Sqrt(5), ```

passes through all Fibonacci numbers of odd n = x (n positive or negative).

The continuous analytic function:

### ``` Fib(x) = (1 + cos(x*Pi))*Fe(x)/2 + (1 ñ cos(x*Pi))*Fo(x)/2, ```

passes through all Fibonacci numbers for all n = x (n positive or negative).

This last expression can be reduced to:

### ``` Fib(x) = (Phi^x ñ cos(x*Pi) / Phi^x) / sqrt(5). ```

Just as factorials can be generalized using the gamma function, Fibonacci numbers can be generalized using this Fib(x) function.

This formula can even be used to compute the generalized Fibonacci function of a complex variable. For example Fib(3 + 4*i) = ñ5248.51130,72837,20182,8... ñ14195.96228,83530,10885,8... * i.

It is still true that Fib(x+2) = Fib(x+1) + Fib(x). For example Fib(3.6 + 4.7*i) = Fib(2.6 + 4.7*i) + Fib(1.6 + 4.7*i). Fo(x) plot in blue
Fe(x) plot in magenta
Fib(x) plot in red

This page accessed times since October 20, 2004.