# How to use Finite Difference Method solving ODE with Boundary Value Problems?

Using these formulas, it is clear how to solve the problem: For node 1, we have the boundary value on the left side, for ex. $$u(0) = 0$$ and for node 2, we use the formula replacing $$u''$$ with $$u_{i-1} = (u_{i+1} - 2 u_i + u_{i-1})/h^2$$ and we go to node 3 etc..

But how to solve the problem, if I had this formula: ??

I would solve for node 1 with the same manner as the 1st formula for $$u''$$, but after that, should I go to node 4 directly and replace $$u_1$$, $$u_2$$, $$u_3$$, $$u_4$$, $$u_5$$, $$u_6$$, and $$u_7$$, or should I go to node 2, and take just $$u_{i-1}$$, $$u_i$$ and $$u_{i+1}$$?

Please help!

## 1 Answer

First of all, your initial idea to solve the 'problematic' nodes with the first formula is a good start. However, there are two things that you need to keep in mind:

1. You will have to use the first formula for the 2nd node as well, since using the second formula for the 2nd node will try to use a node outside your domain. This will also need to be repeated and checked properly for your other boundary as well.

2. The first formula approximates the second derivative with a second-order central difference, meaning if $$u''(x_0)$$ is the actual value of the second derivative at point $$x_0$$ and let's say $$\tilde{u}''$$ your approximation, then $$\|u'(x_0) - \tilde{u}'' \| \leq Ch^2$$, with $$C$$ being some constant. Your second formula is 6th-order accurate. Therefore, if you use the first formula for the first (and last) two nodes, you will harm the order of accuracy of your method.

An idea would be to use a 6th-order forward difference for the problematic nodes on the left side and a 6th-order backward difference for the ones on the right. You can find a helpful table for the appropriate coefficients in each case here.