filmov
tv
Recursive Functions and Memoization in Python and SageMath
Показать описание
Recursive definitions are powerful tools to solve problems, but a straightforward application can lead to an exponential number of function calls, as illustrated on the example of the Fibonacci numbers. Memoization is a technique to speedup programs by storing the function calls. When the amount of storage required is linear in the dimension, then a dramatic speedup is realized over the straightforward use of the recursive definition. In Python, a dictionary is optimized for efficient lookup and well suited to implement memoization. In symbolic computation, we produce expressions and use the example of the orthogonal Chebyshev polynomials to illustrate the application of memoization, in SageMath.