関数sequence_differentiate マニュアル

(The documentation of function sequence_differentiate)

Last Update: 2022/5/6


◆機能・用途(Purpose)

時系列データを微分する。
Compute the derivative of a time series data.


◆形式(Format)

#include <sequence/operation.h>
inline struct sequence sequence_differentiate
(const struct sequence original,const double initialValue)


◆引数(Arguments)

original 微分する前の時系列データを表す構造体。
A structure that represents a time series data before the differentiation.
initialValue 微分後の時系列データの初期値\(\dot{f}(t_0)\)。
The initial value, \(\dot{f}(t_0)\), of the differential time series data.


◆戻り値(Return value)

引数originalが表す時系列データを微分した時系列データ。
The time series data obtained by differentiating the original time series data given by argument original.


◆使用例(Example)

struct sequence velocity;
struct sequence acceleration=sequence_differentiate(velocity,0.0);


◆計算式(Formula)

元々の時系列データを\(f(t)\)とする。 \(f(t)\)の微分を中心差分で近似すると \[\begin{equation} \dot{f}\left(t+\frac{\Delta t}{2}\right) =\frac{f(t+\Delta t)-f(t)}{\Delta t} \label{eq.diff.center} \end{equation}\] となるが、(\ref{eq.diff.center})式をそのまま用いると \(f(t)\)と\(\dot{f}(t)\)でサンプル時刻が\(\Delta t/2\)だけずれる。 これを避けるため、(\ref{eq.diff.center})式の左辺を算術平均で近似して \[\begin{equation} \frac{\dot{f}(t)+\dot{f}(t+\Delta t)}{2} =\frac{f(t+\Delta t)-f(t)}{\Delta t} \label{eq.diff.ave} \end{equation}\] とする。これを変形すると \[\begin{equation} \dot{f}(t+\Delta t)=-\dot{f}(t)+2\frac{f(t+\Delta t)-f(t)}{\Delta t} \label{eq.use} \end{equation}\] という漸化式が得られる。 この関数では時刻\(t=t_0\)での導関数の値\(\dot{f}(t_0)\)を引数で与え、 それ以降の各サンプル時刻での\(\dot{f}(t)\)を 漸化式(\ref{eq.use})を繰り返し用いて計算する。
Let \(f(t)\) be the original time series data. Approximating the derivative of \(f(t)\) by a central difference gives Eq. (\ref{eq.diff.center}); however, direct application of this equation results in a half-sample difference between the sample times of \(f(t)\) and \(\dot{f}(t)\). To avoid it, the left hand side of Eq. (\ref{eq.diff.center}) is approximated by an arithmetic average. Then Eq. (\ref{eq.diff.ave}) is obtained, which can be arranged to a recursive formula of Eq. (\ref{eq.use}). This function gives the initial value \(\dot{f}(t_0)\) by an argument, and computes \(\dot{f}(t)\) for later sample times by repeatedly applying the recursive formula (\ref{eq.use}).


◆使用上の注意(Note)

この関数を2度用いて2階導関数を計算すると数値不安定が起きやすい。 2階導関数の計算には関数 sequence_twice_differentiateを用いること。
Computation of the 2nd-order derivative of a time series data by applying this function twice sometimes results in numeriacl instability. Use function sequence_twice_differentiate instead for the computation of the 2nd-order derivative.