Analytic approximation methods
Analytic approximation methods try to compute approximations to the exact solutions on suitable domains, in the form of truncated series expansions over a system of basis functions. In the SciPy stack, we have an implementation based on the Taylor series, through the routine odefun
in the module sympy.mpmath
.
Note
mpmath
is a Python library for arbitrary-precision floating-point arithmetic, hosted inside the sympy
module. Although it is independent of the numpy
machinery, they both work well together.
For more information about this library, read the official documentation at http://mpmath.org/doc/current/.
Let's see it in action, first with our trivial example y'(t) = y(t), y(0) = 1. The key here is to assess the speed and the accuracy of the approximation, as compared to the actual solution in the interval [0, 1]. Its syntax is very simple, we assume the equation is always in the form of y' = F, and we provide the routine odefun
with this functional...