Why can't mma be drawn in continuous form with the Fibonacci number general formula? [closed]

Of course, I know I can use Plot and DiscretePlot plot the built-in Fibonacci[x], but why this code don't work?

We can find the formula in wiki here:

Plot[1/Sqrt[5] (((1 + Sqrt[5])/2)^x - ((1 - Sqrt[5])/2)^x), {x, 0, 26}]


Is it a bug of MMA?

4 Answers

Your expression is only valid for integer x

FunctionDomain[
1/Sqrt[5] (((1 + Sqrt[5])/2)^x - ((1 - Sqrt[5])/2)^x), x]

(* Element[x, Integers] *)


The correct expression for arbitrary real x is

f[x_] = Fibonacci[x] // FunctionExpand

(* ((1/2 (1 + Sqrt[5]))^x - (2/(1 + Sqrt[5]))^x Cos[π x])/Sqrt[5] *)

% // FullSimplify

(* (2^-x ((1 + Sqrt[5])^x - (-1 + Sqrt[5])^x Cos[π x]))/Sqrt[5] *)

Plot[f[x], {x, -5, 5}]


• I know we can plot Fibonacci[x], I just don't know why I cannot plot my that formula.. :)
– yode
Dec 2 '21 at 7:37

It is not the right function for the Fibonacci numbers. Especially, you use the term

 ((1 - Sqrt[5])/2)^x)


but $$(1 - Sqrt[5])/2)<0$$

The power function with negative base is not real for general real $$x$$

The correct way is

Plot[1/Sqrt[5]* (((1 + Sqrt[5])/2)^x - ((-1 + Sqrt[5])/2)^x), {x, 1, 26}]


with the result

• Look wiki here
– yode
Dec 2 '21 at 7:30
• Why the base cannot be less than 0?
– yode
Dec 2 '21 at 7:36
• OK, I am correcting: Your function is defined for integer x only, but in that case, it does not support the Plot function. The better version is ListPlot[(1/Sqrt[5] (((1 + Sqrt[5])/2)^# - ((1 - Sqrt[5])/2)^#)) & /@ Range[0, 26]] Dec 2 '21 at 9:23

You have these two expressions in your plot.

t = List @@ (1/Sqrt[5] ((1 + Sqrt[5])/2)^x -
1/Sqrt[5] ((1 - Sqrt[5])/2)^x)


$$\left\{-\frac{\left(\frac{1}{2} \left(1-\sqrt{5}\right)\right)^x}{\sqrt{5}},\frac{\left(\frac{1}{2} \left(\sqrt{5}+1\right)\right)^x}{\sqrt{5}}\right\}$$

The second one can be plotted for x < 0; but consider:

t[[1]] /. x -> 0.4 // N


-0.113999 - 0.350854 I

So you cannot Plot this complex number.

• Thanks very very much
– yode
Dec 2 '21 at 7:57

I can Plot it by add a Re now

Plot[Re[1/Sqrt[5] (((1 + Sqrt[5])/2)^x - ((1 - Sqrt[5])/2)^x)], {x, 1, 25}]


• So, why Re and not Abs, Re+Im? Looks like an arbitrary question (because it is not specified in what sense the interpolation should be given). Also, looks like an arbitrary answer (because not explained why certain choice is made). Dec 2 '21 at 9:16