verry.integrate.C1Solver#

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

Bases: object

ODE solver using variational equations.

Parameters:

Notes

A class diagram of C1Solver is shown below:

        classDiagram
    C1Solver ..> VarEqSolverFactory: use
    C1Solver ..> IntegratorFactory: use
    C1Solver ..> TrackerFactory: use
    IntegratorFactory --> Integrator: create
    TrackerFactory --> Tracker: create
    VarEqSolverFactory --> VarEqSolver: create
    VarEqSolverFactory ..> IntegratorFactory: use
    
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[[C1SolverCallbackArg], 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 C1SolverResultContent; 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 = C1Solver()
>>> 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 = C1Solver(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