Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Numerically checking surprising identities regarding the sums involving Fibonacci numbers
from sympy import *
mfib = Matrix([[0,1],[1,1]])
fib0 = Matrix([0,1])
luc0 = Matrix([2,1])
eye = Matrix([[1,0],[0,1]])
def fibo(n):
return (mfib**n*fib0)[0,0]
def luca(n):
return (mfib**n*luc0)[0,0]
assert [fibo(i) for i in range(6)] == [0,1,1,2,3,5]
assert [luca(i) for i in range(6)] == [2,1,3,4,7,11]
print("Checking Diego Rattagi's identity: ...=4")
s = 0
for n in range(1,10):
s += Rational(3,fibo(2**n)**2) + Rational(5,luca(2**n)**2)
print(n, "Sn - 4=",float(s-4),"=", s-4)
print("Checking Srinivasa Raghava K's identity ...=620/147")
s = 0
for n in range(1,10):
t = Rational(3*fibo(n),fibo(2**n)**2) + Rational(5*luca(n),luca(2**n)**2)
s += t
print(n, "Sn-620/147=",float(s-620/147), "=", s-Rational(620,147), "term is:",float(t))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.