학교수업/수치해석

[Numerical Analysis] 14. Ordinary Differential Equations

hwijin97 2022. 6. 14. 15:15

Ordinary Differential Equations

$y'(x) = f(x,y)$

 

Euler's Method

  > extremely simple approximation with low accuracy

  > Suppose tha twe know an initial state $y(x_0) = y_0$

  > Approximate $y$ at $x = x_0 + h$, $h$ is a small step size

     $\frac{y(x_0+h) -y_0}{h} = f(x,y)$ => $y(x_0 +h) = y_0 + h f(x,y)$

- General formula

  > $x_{i+1} = x_i +h$

  > $y_{i+1} = y_i + h f(x_i, y_i)$

 

Talyor Series

- Approximating $f(x)$ near $x=c$

  > $p_n(x) = a_0 + a_1(x-c) + a_2(x-c)^2 + \cdots + a_n(x-c)^n \approx f(x)$

- Derivatives of $p_n(x)$

  > $p'_n(c) = a_1$

  > $p''_n(c) = 2a_2$

  > $p^{(n)}_n (c) = n! a_n$

- $p_n(x)$ is given by : $p_n(x) = f(c) + f'(c)(x-c) + \frac{f''(c)}{2!}(x-c)^2 + \cdots + \frac{f^{(n)}(c)}{n!}(x-c)^n$

- We define the error term $r_n(x)$

  > $f(x) = p_n(x) + r_n(x)$

  > $f(x) = \sum_{k=0}^{\infty} \frac{f^{(k)}(c)}{k!}(x-c)^k$

 

- General form

  : $y(x_i + h) = y(x_i) + hF(x_i, y_i)$

- Talyor Series

  1. $y(x_i + h) = y(x_i) + hy'(x_i) +\frac{h^2}{2!}y''(x_i) + \cdots $

  2. $y^{(n)}(x) = f^{(n-1)}(x,y)$

  3. y(x_i + h) \approx y_i + hf(x_i, y_i) + \frac{h^2}{2!} f'(x_i, y_i) + \cdots + \frac{h^k}{k!}f^{(k-1)}(x_i, y_i)$

  > If $k=1$, same as Euler's method

 

Runge-Kutta Method

- General form : $y(x_i + h) = y(x_i) + hF(x_i, y_i)$

- RK method : $F(x_i, y_i) = \sum_{j=1}^m w_j f(u_j, v_j) \approx T_k(x_i, y_i)$

- Choose $(u_j, v_j)$ and $w_j$ so that $F(x_i, y_i)$ matches to k-th order Taylor series function $T_k(x_i, y_i)$

- Consider only second order

  > $F(x_i, y_i) = w_i f(x_i, y_i) + w_2 f(x_i + ah, y_i ahf(x_i, y_i))$

  > We want this mathces $T_2(x_i, y_i)$

  > Expand $f(x_i + ah, y_i + ahf(x_i, y_i))$

- Choose $a = \frac{1}{2}$ (modified Euler's method)

  > $y_{i+1} = y_i + hf(x_i + \frac{h}{2}, y_i + \frac{h}{2}f(x_i, y_i))

- Choose $a = 1$ (Heun's method)

  > $y_{i+1} = y_i + \frac{h}{2}[ f(x_i, y_i) + f(x_i + h, y_i + hf(x_i, y_i))]$

 

- 4-th order (RK4 Method)

Higher Order Differential Equation

- second order $y''(x) = f(x,y,y')$ -> $y(x)$

  > $y'(x) = z(x)$, $z'(x) = f(x,y,z)$

- Euler's Method

  > $x_{i+1} = x_i + h$, $y_{i+1} = y_i + hz_i$, $z_{i+1} = z_i + hf(x_i, y_i, z_i)$

 

- n-th order differential equation : $y^{(n)}(x) = f(x, y, y', \cdots, y^{(n-1)})$

- Vector form

  > $x_{i+1} = x_i + h$