Resolvepy solves linear homogenous recurrence relations using the standard "streamline" method.
git clone https://github.com/kiwirafe/resolvepy.git
cd resolvepy
python3 setup.py install
from sympy import *
from resolvepy import *
n = Symbol('n')
# create the sequence
f = Recurrence('f')
f.index = n
# input the starting items
f[0] = 1
f[1] = 2
# provide a recursive formula
f[n] = f[n-1] + f[n-2]
explicit = f.resolve()
# Output the first 10 items
for i in range(10):
value = explicit.subs(n, i).simplify()
print("x[{}] = {}".format(i, value))
Note:
- The recursive formula must be a linear homogenous recurrence relation with constant coefficients.
- The maximum depth of the recursive formula must be smaller than 5 (due to Abel–Ruffini theorem).
- The amount of starting items must match the depth of the recursive formula.