When I first saw finite difference equation for the first derivative of a function "u" it seemed easy. It was just the derivative $\frac{\partial u}{\partial x} = \frac{u(x+\Delta x)}{\Delta x}$, but there's some form of art to how finite differencing really works.
Forward Difference:
\begin{equation}
\frac{\partial u}{\partial x} =\frac{u(x_0 + \Delta x, y_0) - u(x_0,y_0)}{\Delta x}
\end{equation}
Backward Difference:
\begin{equation}
\frac{\partial u}{\partial x} =\frac{ u(x_0,y_0) - u(x_0 - \Delta x, y_0)}{\Delta x}
\end{equation}
Two common schemes, we have the forward difference scheme and backward difference, but how did we get to here? In order to really understand finite difference we need to look at the Taylor Series.
\begin{equation}
u(x_0+\Delta x,y_0) = u(x_0, y_0) + \Delta x \frac{\partial u}{\partial x} + \frac{\Delta x^2}{2!} \frac{\partial^2 u}{\partial x^2} +...+ \frac{\Delta x^n}{n!} \frac{\partial^n u}{\partial x^n}
\end{equation}
Using the Taylor series we can derive the equation of the Forward Difference
\begin{equation}
\frac{u(x_0 + \Delta x, y_0) - u(x_0,y_0)}{\Delta x} = \frac{\partial u}{\partial x} + O(\Delta x)
\end{equation}
On the right hand side we have $O(\Delta x)$ this comes from the division on both sides by $\Delta x$; $\frac{O(\Delta x^2)}{\Delta x} = O(\Delta x)$ this is important when you're trying to find the order of accuracy of your finite difference equation.
To get backward differencing all we have to do is replace $\Delta x$ with $-\Delta x$
No comments:
Post a Comment