# Finite Difference Approximations of Derivatives

We will derive the finite difference approximations for $y'(x)$ and $y''(x)$.

Let

$y'_i, y''_i$ denotes $y'(x_i)$ and $y''(x_i)$ respectively

and

$h = x_{i+1}-x_i = x_i -x_{i-1} > 0$.

We prove that

[1] $y_i' \approx \frac{y_{i+1} - y_i}{h}$

Let $x=x_{i+1}, a=x_i$, Taylor series

$y(x) = y(a) + y'(a) (x-a) + O((x-a)^2)$

is

$y(x_{i+1}) = y(x_i) + y'(x_i)(x_{i+1}-x_i)+O((x_{i+1} - x_i)^2)$

i.e.,

$y_{i+1} = y_i + y'_i h + O(h^2)$

Hence,

$\frac{y_{i+1} -y_i}{h} = y'_i + O(h)$

[2] $y_i' \approx \frac{y_{i+1}-y_{i-1}}{2h}$

Let $x = x_{i+1}, a = x_i$, Taylor series

$y(x) = y(a) + y'(a) (x-a) + \frac{y''(a)}{2!} (x-a)^2 + O((x-a)^3)$

becomes

$y(x_{i+1}) = y(x_i) + y'(x_i)(x_{i+1}-x_i) + \frac{y''_i}{2!} (x_{i+1}-x_i)^2 + O((x_{i+1}-x_i)^3)$

It follows that

$y_{i+1}= y_i + y'_i h + \frac{y''_i}{2!} h^2 + O(h^3)\quad\quad\quad(1)$

Similarly, let $x=x_{i-1}, a = x_i$,

$y_{i-1}= y_i + y'_i (x_{i-1}-x_1) + \frac{y''_i}{2!} (x_{i-1}-x_i)^2 + O((x_{x-1}-x_i)^3$

Since $x_{i-1}-x_i = -(x_i - x_{i-1}) = -h$, we have

$y_{i-1} = y_i - y'_i h + \frac{y''_i}{2!} + O(h^3)\quad\quad\quad(2)$

(1)-(2) $\implies$

$y_{i+1}-y_{i-1} = 2y'_i h + O(h^3)$

Therefore,

$\frac{y_{i+1}-y_{i-1}}{2h} = y'_i + O(h^2)$

[3] $y_i'' \approx \frac{y_{i+1}-2y_i+y_{i-1}}{h^2}$

Let $x = x_{i+1}, a=x_i$, Taylor series

$y(x) = y(a) + y'(a) (x-a) + \frac{y''(a)}{2!} (x-a)^2 + \frac{y'''(a)}{3!} (x-a)^3 + O((x-a)^4)$

becomes

$y(x_{i+1}) = y(x_i) + y'(x_i) (x_{i+1}-x_i) + \frac{y''(x_i)}{2!} (x_{i+1} - x_i)^2$

$+ \frac{y'''(x_i)}{3!}(x_{i+1} - x_i)^3 + O((x_{i+1}-x_{i})^4)$.

That is,

$y_{i+1} = y_i + y_i' h + \frac{y_i''}{2!} h^2 + \frac{y_i'''}{3!} h^3 + O(h^4)\quad\quad\quad(3)$

Similarly, let $x = x_{i-1}, a=x_i$, we have

$y(x_{i-1}) = y(x_i) + y'(x_i) (x_{i-1}-x_i) + \frac{y''(x_i)}{2!} (x_{i-1} - x_i)^2$

$+ \frac{y'''(x_i)}{3!}(x_{i-1} - x_i)^3 + O((x_{i-1}-x_{i})^4)$.

i.e.,

$y_{i-1} = y_i - y_i' h + \frac{y_i''}{2!} h^2 - \frac{y_i'''}{3!} h^3 + O(h^4)\quad\quad\quad(4)$

(3) + (4) $\implies$

$y_{i+1}+y_{i-1} = 2y_i +y_i'' h^2 + O(h^4)$.

Therefore,

$\frac{y_{i+1}-2y_i+y_{i-1}}{h^2} = y_i'' + O(h^2)$