近似式
- ある時刻 $t_0$ の値を初期値とすると、次の時刻 $t_1 = t_0 + \Delta t$ での値は
$$
f(t_1) \approx f(t_0) + f'(t_0) \cdot \Delta t
$$
となる。
- 同様に
$$
f(t_2) \approx f(t_1) + f'(t_1) \cdot \Delta t
$$
$$
f(t_3) \approx f(t_2) + f'(t_2) \cdot \Delta t
$$
と逐次的に未来を予測できる。
未来を予測する式(積分形)
$$
f(t_1) = f(t_0) + \int_{t_0}^{t_1} f'(t) , dt
$$
これは 「未来の値 = 初期値 + 傾きの積分」 という関係を示す。
工学的な意味
-
微分方程式
各点での「傾き」$f'(t)$ が対象の振る舞いを表す物理法則。
例:力学の運動方程式、電気回路の微分方程式。 -
微分
傾きを調べる操作。
例:速度 = 位置の時間微分、電流 = 電荷の時間微分。 -
積分
傾き(微分方程式)をもとにグラフ全体を構成する操作。
例:位置 = 速度の積分、電荷 = 電流の積分。
import numpy as np
import matplotlib.pyplot as plt
# ================= Parameters =================
fs = 100 # Sampling frequency [Hz]
fin = 2 # Input sine frequency [Hz]
N = 200 # Number of samples
dt = 1.0 / fs # Sampling interval
t = np.arange(N) * dt # Time axis
# ================= True sine wave =================
f_true = np.sin(2 * np.pi * fin * t)
# ================= Derivative (analytical) =================
# df/dt = 2πf cos(2πft)
f_deriv = 2 * np.pi * fin * np.cos(2 * np.pi * fin * t)
# ================= Future prediction (Euler method) =================
f_pred = np.zeros(N)
f_pred[0] = 0.0 # initial value f(0)=0
for n in range(N - 1):
f_pred[n+1] = f_pred[n] + f_deriv[n] * dt # Euler step
# ================= Plot =================
plt.figure(figsize=(10,6))
plt.plot(t, f_true, label="True sine wave", linewidth=2)
plt.plot(t, f_pred, 'r--', label="Predicted (Euler)", linewidth=2)
plt.xlabel("Time [s]")
plt.ylabel("Amplitude")
plt.title("Future Prediction by Euler vs True Sine Wave")
plt.legend()
plt.grid(True)
plt.show()
