ord4()#
- ord4(states: ndarray, dt: float, inputs=None)[source]#
Fourth-order forward, central, and backward differences for estimating the first derivative.
Central differences are used where possible; forward differences are used for the first two points and backward differences are used for the last two points:
\[\begin{split}\frac{\textup{d}}{\textup{d}t}\q(t)\bigg|_{t = t_0} &\approx \frac{1}{12\delta t}(-25\q(t_0) + 48\q(t_{1}) - 36\q(t_{2}) + 16\q(t_{3}) - 3\q(t_{4})), \\ \frac{\textup{d}}{\textup{d}t}\q(t)\bigg|_{t = t_1} &\approx \frac{1}{12\delta t}(-3\q(t_0) - 10\q(t_{1}) + 18\q(t_{2}) - 6\q(t_{3}) + \q(t_{4})), \\ \\ \frac{\textup{d}}{\textup{d}t}\q(t)\bigg|_{t = t_j} &\approx \frac{1}{12\delta t} (\q(t_{j-2}) - 8\q(t_{j-1}) + 8\q(t_{j+1}) - \q(t_{j+2})), \quad j = 2,\ldots,k-3, \\ \\ \frac{\textup{d}}{\textup{d}t}\q(t)\bigg|_{t = t_{k-2}} &\approx \frac{1}{12\delta t}(-\q(t_{k-5}) + 6\q(t_{k-4}) - 18\q(t_{k-3}) + 10\q(t_{k-2}) + 3\q(t_{k-1})), \\ \frac{\textup{d}}{\textup{d}t}\q(t)\bigg|_{t = t_{k-1}} &\approx \frac{1}{12\delta t}(3\q(t_{k-5}) - 16\q(t_{k-4}) + 36\q(t_{k-3}) - 48\q(t_{k-2}) + 25\q(t_{k-1})),\end{split}\]where \(\delta t = t_{j+1} - t_j\) for all \(j\).
- Parameters:
- states(r, k) ndarray
State snapshots:
states[:, j]
is the state at time \(t_j\).- dtfloat
Time step between snapshots.
- inputs(m, k) or (k,) ndarray or None
Inputs corresponding to the states, if applicable.
- Returns:
- states(r, k) ndarray
State snapshots.
- ddts(r, k) ndarray
Time derivative estimates corresponding to the state snapshots.
- inputs(m, k) or (k,) ndarray or None
Inputs corresponding to
_states
, if applicable. Only returned ifinputs
is notNone
.