Skip to content
Specular Differentiation

specular.ode.euler_scheme_5

euler_scheme_5(F, t_0, T, u_0, *, h, atol=1e-12, rtol=0.0, max_iter=100, domain=None, admissible=None)

Apply the implicit one-step specular Euler method of Type 5 to a scalar initial-value problem. This is ellipse_scheme with the fixed scale \(\sigma_n=1\).

Parameters

Name Type and default Description
F callable Field F(point) receiving the NumPy float64 vector [t, u] and returning a finite real scalar.
t_0 real scalar Finite initial time.
T real scalar Finite final time, strictly greater than t_0.
u_0 real scalar Finite initial value at t_0.
h positive real scalar, keyword-only Prescribed constant step, with 0 < h <= T - t_0.
atol real scalar, default 1e-12 Finite positive absolute tolerance; accept only when abs(v_next - v) < atol.
rtol real scalar, default 0.0 Compatibility parameter; must be zero.
max_iter positive integer, default 100 Maximum number of fixed-point updates per step.
domain callable or None, default None Boolean predicate domain(t, u) for the field domain.
admissible callable or None, default None Boolean predicate admissible(t_next, v) checked before and after each update.

All parameters after u_0 are keyword-only.

Returns

ODEResult: NumPy float64 arrays t and u of shape (N_h + 1,), an array sigma of N_h ones, and the number of solver calls to F, where N_h = floor((T - t_0)/h).

Notes

The method solves

\[ u_{n+1}=u_n+h\mathcal C_1\!\left( F(t_{n+1},u_{n+1}),F(t_n,u_n)\right) \]

at each step using the prescribed \(h\). The preallocated nodes are \(t_n=t_0+nh\), \(n=0,\ldots,N_h\); no shortened final step is added. Unlike the two-step Euler methods, it does not require an external u_1. See Type 5.

Fixed-point iteration uses an Euler predictor and returns the updated trial value when the strict absolute stopping condition holds. An inadmissible trial or failure after max_iter updates raises RuntimeError. See Nonlinear solve controls. Angular means use the selected backend; the outer iteration remains scalar and the stored arrays use float64.

Examples

import specular.ode

result = specular.ode.euler_scheme_5(
    lambda point: -point[1],
    0.0,
    1.0,
    1.0,
    h=0.01,
)
print(result.u[-1])
Source code in specular/ode/solver.py
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
def euler_scheme_5(
    F: VectorToScalarFunc,
    t_0: Scalar,
    T: Scalar,
    u_0: Scalar,
    *,
    h: Scalar,
    atol: Scalar = 1e-12,
    rtol: Scalar = 0.0,
    max_iter: int = 100,
    domain: Callable[[float, float], bool] | None = None,
    admissible: Callable[[float, float], bool] | None = None,
) -> ODEResult:
    r"""Apply Type 5, the ellipse method with fixed scale :math:`\sigma_n=1`.

    The mesh is ``t_n = t_0 + n*h`` through ``floor((T-t_0)/h)`` steps.
    """

    return ellipse_scheme(
        F, t_0, T, u_0, h=h, sigma_n=1.0,
        atol=atol, rtol=rtol, max_iter=max_iter,
        domain=domain, admissible=admissible,
    )