verry.integrate.C0Solver#

class verry.integrate.C0Solver(integrator=None, tracker=None)#

Bases: object

ODE solver.

Parameters:
solve(fun, t0, y0, t_bound, callback=None)#

Solve an initial value problem for a system of ODEs.

Parameters:
  • fun (Callable) – Right-hand side of the system. The calling signature is fun(t, *y).

  • t0 (Interval) – Initial time.

  • y0 (IntervalMatrix | Sequence[Interval]) – Initial state.

  • t_bound (Interval) – Boundary time. Its infimum must be greater than the supremum of t0.

  • callback (Callable[[C0SolverCallbackArg], None], optional) – Callback function called at each step. You can abort the solver by raising AbortSolving.

Returns:

r – If r.status is "SUCCESS", r.content is C0SolverResultContent; otherwise, r.content is None.

Return type:

SolverResult

Warning

fun must be a \(C^\infty\)-function on some open interval that contains t0 and t_bound. Furthermore, fun must neither be a constant nor contain conditional branches (cf. Common pitfalls).

Examples

This example computes \(\cos(x)\) and \(\sin(x)\).

>>> from verry import FloatInterval as FI
>>> from verry import function as vrf
>>> PI = vrf.pi(FI())
>>> solver = C0Solver()
>>> r = solver.solve(lambda t, x, y: (y, -x), FI(0), [FI(1), FI(0)], PI)
>>> print(r.status)
SUCCESS
>>> print(r.content.y[0])
[-1.00001, -0.99999]

The next example fails due to the blow-up of the solution.

>>> from verry.integrate import eilo, affine
>>> solver = C0Solver(eilo(min_step=1e-4), affine)
>>> r = solver.solve(lambda t, x: (x**2,), FI(0), [FI(1)], FI(2))
>>> print(r.status)
FAILURE
>>> print(r.message)
failed to determine a step size