# probsolve_ivp¶

probnum.diffeq.probsolve_ivp(f, t0, tmax, y0, df=None, method='EK0', dense_output=True, algo_order=2, adaptive=True, atol=0.01, rtol=0.01, step=None, diffusion_model='dynamic', time_stops=None)[source]

Solve an initial value problem with a filtering-based ODE solver.

Numerically computes a Gauss-Markov process which solves numerically the initial value problem (IVP) based on a system of first order ordinary differential equations (ODEs)

$\dot x(t) = f(t, x(t)), \quad x(t_0) = x_0, \quad t \in [t_0, T]$

by regarding it as a (nonlinear) Gaussian filtering (and smoothing) problem 3. For some configurations it recovers certain multistep methods 1. Convergence rates of filtering 2 and smoothing 4 are comparable to those of methods of Runge-Kutta type.

This function turns a prior-string into an ODEPrior, a method-string into a filter/smoother of class GaussFiltSmooth, creates a ODEFilter object and calls the solve() method. For advanced usage we recommend to do this process manually which enables advanced methods of tuning the algorithm.

This function supports the methods: extended Kalman filtering based on a zero-th order Taylor approximation (EKF0), extended Kalman filtering (EKF1), unscented Kalman filtering (UKF), extended Kalman smoothing based on a zero-th order Taylor approximation (EKS0), extended Kalman smoothing (EKS1), and unscented Kalman smoothing (UKS).

For adaptive step-size selection of ODE filters, we implement the scheme proposed by Schober et al. (2019), and further examined by Bosch et al (2021), where the local error estimate is derived from the local, calibrated uncertainty estimate.

Parameters
Returns

solution – Solution of the ODE problem.

Can be evaluated at and sampled from at arbitrary grid points. Further, it contains fields:

tnp.ndarray, shape=(N,)

Mesh used by the solver to compute the solution. It includes the initial time $$t_0$$ but not necessarily the final time $$T$$.

ylist of RandomVariable, length=N

Discrete-time solution at times $$t_1, ..., t_N$$, as a list of random variables. The means and covariances can be accessed with solution.y.mean and solution.y.cov.

Return type

ODEFilterSolution

Raises
• ValueError – If ‘diffusion_model’ is not in the list of supported diffusion models.

• ValueError – If ‘method’ is not in the list of supported methods.

See also

ODEFilter

Solve IVPs with Gaussian filtering and smoothing

ODEFilterSolution

Solution of ODE problems based on Gaussian filtering and smoothing.

References

1

Schober, M., Särkkä, S. and Hennig, P.. A probabilistic model for the numerical solution of initial value problems. Statistics and Computing, 2019.

2

Kersting, H., Sullivan, T.J., and Hennig, P.. Convergence rates of Gaussian ODE filters. 2019.

3

Tronarp, F., Kersting, H., Särkkä, S., and Hennig, P.. Probabilistic solutions to ordinary differential equations as non-linear Bayesian filtering: a new perspective. Statistics and Computing, 2019.

4

Tronarp, F., Särkkä, S., and Hennig, P.. Bayesian ODE solvers: the maximum a posteriori estimate. 2019.

5

Bosch, N., and Hennig, P., and Tronarp, F.. Calibrated Adaptive Probabilistic ODE Solvers. 2021.

Examples

>>> from probnum.diffeq import probsolve_ivp
>>> import numpy as np


Solve a simple logistic ODE with fixed steps.

>>>
>>> def f(t, x):
...     return 4*x*(1-x)
>>>
>>> y0 = np.array([0.15])
>>> t0, tmax = 0., 1.5
>>> solution = probsolve_ivp(f, t0, tmax, y0, step=0.1, adaptive=False)
>>> print(np.round(solution.states.mean, 2))
[[0.15]
[0.21]
[0.28]
[0.37]
[0.47]
[0.57]
[0.66]
[0.74]
[0.81]
[0.87]
[0.91]
[0.94]
[0.96]
[0.97]
[0.98]
[0.99]]


Other methods are easily accessible.

>>> def df(t, x):
...     return np.array([4. - 8 * x])
>>> solution = probsolve_ivp(
...     f, t0, tmax, y0, df=df, method="EK1",
...     algo_order=2, step=0.1, adaptive=False
... )
>>> print(np.round(solution.states.mean, 2))
[[0.15]
[0.21]
[0.28]
[0.37]
[0.47]
[0.57]
[0.66]
[0.74]
[0.81]
[0.87]
[0.91]
[0.93]
[0.96]
[0.97]
[0.98]
[0.99]]