Memoization#

sympy.utilities.memoization.assoc_recurrence_memo(base_seq)[source]#

Memo decorator for associated sequences defined by recurrence starting from base

base_seq(n) – callable to get base sequence elements

XXX works only for Pn0 = base_seq(0) cases XXX works only for m <= n cases

sympy.utilities.memoization.recurrence_memo(initial)[source]#

Memo decorator for sequences defined by recurrence

Examples

>>> from sympy.utilities.memoization import recurrence_memo
>>> @recurrence_memo([1]) # 0! = 1
... def factorial(n, prev):
...     return n * prev[-1]
>>> factorial(4)
24
>>> factorial(3) # use cache values
6