Processing math: 0%

Wednesday, December 24, 2014

Finite Difference: 2nd Order Central, Any order

2nd order Central Difference can be found by adding the Forward and Backward Differences

Forward Difference:
\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^3}{3!} \frac{\partial^3 u}{\partial x^3} + O(\Delta x^4) \end{equation}

Backward Difference:
\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^3}{3!} \frac{\partial^3 u}{\partial x^3} + O(\Delta x^4) \end{equation}

Forward + Backward:
\begin{align} u(x_0+\Delta x,y_0) + u(x_0-\Delta x,y_0) = 2u(x_0,y_0) + \frac{2 \Delta x^2}{2!} \frac{\partial^2 u}{\partial x^2} + \frac{2 \Delta x^4}{4!} \frac{\partial^4 u}{\partial x^4} \\ \frac{u(x_0+\Delta x,y_0) -2 u(x_0,y_0)+ u(x_0-\Delta x,y_0)}{\Delta x^2} = \frac{\partial^2 u}{\partial x^2} + O(\Delta x^2) \end{align}

There's a pattern here. We can formulate finite difference schemes of any order given a set number of points. Take for example these 3 points. We can use these 3 points to find u_x with O(\Delta x^3) accuracy.


\begin{align} P(u_{i-1,j}) = u_{i,j} - \Delta x u_x + \frac{\Delta x^2}{2!} u_{xx} - \frac{\Delta x^3}{3!} u_{xxx} \\ Q(u_{i-2,j}) = u_{i,j} -2 \Delta x u_x + \frac{4 \Delta x^2}{2!} u_{xx} + \frac{3^3 \Delta x^3}{3!} u_{xxx} \end{align}

We want to set the term u_{xx}=0 and u_x = 1 we then have to solve the equation 
\frac{P}{2!} + \frac{4Q}{2!} = 0
P -2Q = 1

Substituting the coefficients P=-2,Q=1/2
-2 u_{i-1,j} + 2 u_{i,j} = -2\Delta x u_x + O(\Delta x^3)
1/2 u_{i-2,j} =  1/2 u_{i,j} - \Delta x u_x + O(\Delta x^3)
1/2 u_{i-2,j} - 2 u_{i-1,j} - 1.5 u_{i,j} = -3 \Delta x u_x + O(\Delta x^3)

We can use the same idea with 4 points and achieve a greater accuracy.





No comments:

Post a Comment