specular.ode.euler_scheme_1
euler_scheme_1(F, t_0, T, u_0, u_1, *, n_steps)
Apply the explicit two-step specular Euler method of Type 1 to a scalar initial-value problem.
Parameters
| Name | Type | 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. |
u_1 |
real scalar | Finite, externally computed starting value at the first time node t[1]. |
n_steps |
positive integer, keyword-only | Number of uniform time intervals. |
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
With \(h=(T-t_0)/N\), \(N=\texttt{n_steps}\), and \(\mathcal C=\mathcal C_1\), the recurrence is
The solver keeps the supplied u_1 unchanged. For n_steps=1, it returns
u_0 and u_1 without evaluating F. The all-ones sigma array describes the
unscaled-mean convention, including the externally supplied first interval;
it does not describe how the caller produced u_1.
This method is generically first-order consistent. A more accurate starter does not give an unconditional higher-order theorem. See Type 1. Angular means use the selected backend; the outer iteration remains scalar and the stored arrays use float64.
Examples
import specular.ode
def F(t, u):
return -u
t_0, T, u_0 = 0.0, 1.0, 1.0
n_steps = 100
h = (T - t_0) / n_steps
u_1 = u_0 + h * F(t_0, u_0)
result = specular.ode.euler_scheme_1(
F, t_0, T, u_0, u_1, n_steps=n_steps,
)
print(result.u[-1])
Source code in specular/ode/_euler.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |