Finite Difference - Forward Difference with 2nd order Accuracy: What to do at the boundary?

1.7k Views Asked by At

I implemented a BVP using a first-order finite difference scheme after the shooting method did not work reliably. Its the first time I have worked with this. The code works but I would like to move to a more accurate scheme in order to reduce computational time.

I have $N$ points, $[1, N]$. If I use a second order forward finite difference scheme,

$u'(x_n) \approx \frac{1}{2h} \left[ - 3 u(x_n) + 4u(x_{n+1}) - u(x_{n+2}) \right]$

How do I evaluate at $x_{N-1}$? I don't have any point at $x_{N+1}$. At $x_{N}$ I impose a boundary condition, so do not need to evaluate the derivative.

Can I use another integration scheme? First-order accurate forward difference? 2nd order accurate central difference scheme?

How would those 2 choices affect my global error?

Thank you for your help.

Background

I have BVP with two regions, one with two equations and the other with three equations (5 unknown in totals). I impose 5 boundary conditions (one on the left boundary, 3 at the boundary between the two regions and one on the right hand side). I solve it by building the Jacobian from the residue, inverting it and multiplying it by the residue to find the solution with a Newton solve.

The full details can be found here, although that isn't needed to answer the question at hand