dde_euler_step

Contents

dde_euler_step#

class braintools.quad.dde_euler_step(f, y, t, history_fn, delays, *args, **kwargs)#

Explicit Euler step for delay differential equations.

Implements a single forward Euler step for DDEs of the form:

dy/dt = f(t, y(t), y(t-τ), *args)

or with multiple delays:

dy/dt = f(t, y(t), y(t-τ₁), y(t-τ₂), …, *args)

Parameters:
  • f (Callable[[Array | ndarray | bool | number | bool | int | float | complex | Quantity, PyTree, PyTree, ...], PyTree]) – Right-hand side function f(t, y, y_delayed_1, y_delayed_2, ..., *args) that computes the time-derivative. The delayed terms are passed as separate arguments in the order of the delays list.

  • y (PyTree) – Current state at time t.

  • t (Array | ndarray | bool | number | bool | int | float | complex | Quantity) – Current time.

  • history_fn (Callable[[Array | ndarray | bool | number | bool | int | float | complex | Quantity], PyTree]) – Function that returns the solution at past times: history_fn(t_past) -> PyTree. Should handle interpolation for non-grid times.

  • delays (Array | ndarray | bool | number | bool | int | float | complex | Quantity | Sequence[Array | ndarray | bool | number | bool | int | float | complex | Quantity]) – Delay value(s) τ. If a sequence, multiple delayed terms y(t-τᵢ) will be passed to f in order.

  • *args – Additional arguments forwarded to f.

Returns:

The updated state y_{n+1} after one Euler step.

Return type:

PyTree

Examples

Single delay case:

>>> def f(t, y, y_delayed):
...     return -y + y_delayed  # Simple delayed feedback
>>> y_next = dde_euler_step(f, y, t, history_fn, delays=1.0)

Multiple delays case:

>>> def f(t, y, y_delay1, y_delay2):
...     return -y + 0.5*y_delay1 + 0.3*y_delay2
>>> y_next = dde_euler_step(f, y, t, history_fn, delays=[1.0, 2.0])