combinat
fibonacci
compute Fibonacci numbers or polynomials
Calling Sequence
Parameters
Description
Examples
fibonacci(n)
fibonacci(n, x)
n, x
-
algebraic expressions
The call fibonacci(n) computes the nth Fibonacci number F(n), if n is an integer; otherwise it returns unevaluated.
The call fibonacci(n, x) computes the nth Fibonacci polynomial in x if n is an integer; otherwise it returns unevaluated.
The Fibonacci numbers are defined by the linear recurrence
F⁡n=F⁡n−1+F⁡n−2⁢where⁢F⁡0=0⁢and⁢F⁡1=1
The Fibonacci polynomials are defined similarly by
F⁡n,x=x⁢F⁡n−1,x+F⁡n−2,x⁢where⁢F⁡0,x=0⁢and⁢F⁡1,x=1
Note that F⁡n=F⁡n,1.
The method used to compute F(n) is, however, based on the following identity: Let A be the two by two matrix 1,1,1,0. Observe that F⁡n+1,F⁡n=A·F⁡n,F⁡n−1. Thus F(n) can be computed quickly (in time O⁡log⁡n3 instead of O⁡n2) by computing An using binary powering.
The generating function for F(n, x) is
t−t2−x⁢t+1=∑n=0∞⁡F⁡n,x⁢tn
The command with(combinat,fibonacci) allows the use of the abbreviated form of this command.
with⁡combinat,fibonacci:
fibonacci⁡5
5
seq⁡fibonacci⁡i,i=0..10
0,1,1,2,3,5,8,13,21,34,55
seq⁡fibonacci⁡i,i=−10..0
−55,34,−21,13,−8,5,−3,2,−1,1,0
seq⁡fibonacci⁡i,x,i=1..5
1,x,x2+1,x3+2⁢x,x4+3⁢x2+1
fibonacci⁡n
See Also
Download Help Document