Skip to content
Specular Differentiation

specular.ode.euler_scheme_5

euler_scheme_5(F, t_0, T, u_0, *, n_steps, atol=1e-12, rtol=1e-10, max_iter=100)

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(t, u) 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.
n_steps positive integer, keyword-only Number of uniform time intervals.
atol real scalar, default 1e-12 Finite nonnegative absolute tolerance for the nonlinear solve.
rtol real scalar, default 1e-10 Finite nonnegative relative tolerance for the nonlinear solve. At least one of atol and rtol must be positive.
max_iter positive integer, default 100 Limit for each nonlinear iteration or root-refinement phase. Bracket searches may make additional field evaluations.

All parameters after u_0 are keyword-only.

Returns

ODEResult: NumPy float64 arrays t and u of shape (n_steps + 1,), an array sigma of n_steps ones, and the number of solver calls to F.

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, where \(h=(T-t_0)/N\) and \(N=\texttt{n_steps}\). Unlike the two-step Euler methods, it does not require an external u_1. See Type 5.

Fixed-point iteration uses an Euler predictor, with a local bracket and bisection fallback. Convergence is conditional; a failed solve 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 t, u: -u,
    0.0,
    1.0,
    1.0,
    n_steps=100,
)
print(result.u[-1])
Source code in specular/ode/_euler.py
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
def euler_scheme_5(
    F: ScalarField,
    t_0: RealScalar,
    T: RealScalar,
    u_0: RealScalar,
    *,
    n_steps: int,
    atol: RealScalar = 1e-12,
    rtol: RealScalar = 1e-10,
    max_iter: int = 100,
) -> ODEResult:
    r"""Apply the implicit one-step specular Euler method of Type 5.

    This is exactly the specular ellipse method with the fixed scale
    :math:`\sigma_n=1`.
    """

    return ellipse_scheme(
        F,
        t_0,
        T,
        u_0,
        n_steps=n_steps,
        sigma_n=1.0,
        atol=atol,
        rtol=rtol,
        max_iter=max_iter,
    )