Here is the complete code for solving Fibonacci recursion. Please pay attention to the correct use Functionand symbols.
from sympy import *
y = Function('y')
n = symbols('n',integer=True)
f = y(n)-y(n-1)-y(n-2)
rsolve(f,y(n),{y(0):0, y(1):1})
sqrt(5)*(1/2 + sqrt(5)/2)**n/5 - sqrt(5)*(-sqrt(5)/2 + 1/2)**n/5
source
share