ord2()#
- ord2(states: ndarray, dt: float, inputs=None)[source]#
Second-order forward, central, and backward differences for estimating the first derivative.
Central differences are used where possible; forward differences are used for the first point and backward differences are used for the last point:
\[\begin{split}\frac{\textup{d}}{\textup{d}t}\q(t)\bigg|_{t = t_0} &\approx \frac{1}{2\delta t}(-3\q(t_0) + 4\q(t_{1}) - \q(t_{2})), \\ \\ \frac{\textup{d}}{\textup{d}t}\q(t)\bigg|_{t = t_j} &\approx \frac{1}{2\delta t}(-\q(t_{j-1}) + \q(t_{j+1})), \quad j = 2,\ldots,k-2, \\ \\ \frac{\textup{d}}{\textup{d}t}\q(t)\bigg|_{t = t_{k-1}} &\approx \frac{1}{2\delta t}(\q(t_{k-3}) - 4\q(t_{k-2}) + 3\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
.