1
$\begingroup$

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

$\endgroup$
  • 1
    $\begingroup$ I don't see any reason not to use the centered difference $u'(x_i)\approx \frac{1}{2h} (u_{i+1}-u_{i-1})$. If I understand correctly, you are not marching forward, but rather setting up a linear system to be solved as a whole thing. The symmetric difference leads to a more convenient linear system to solve. Caveat: I know very little about this stuff. You may consider asking at Computational Science. $\endgroup$ – user147263 Aug 26 '14 at 0:35
  • $\begingroup$ @Thursday Yes indeed. I am assembling the Jacobian from the residue and then doing a Newton solve. The reason I was using forward/backward differencing instead of central was that I found it easy to impose my boundary conditions that way at one side and march to the other side. I wasn't sure how I would deal with a boundary where I don't have a boundary condition using a central difference scheme. I think there should be no fundamental problem with switching the scheme in the middle but I'm not sure... $\endgroup$ – Edgar H Aug 26 '14 at 8:47
  • $\begingroup$ Now I don't understand. You said you have BVP, but then talk about having conditions on one side and marching to the other. That looks a lot like IVP. Could you include the actual problem in the post? $\endgroup$ – user147263 Aug 26 '14 at 12:06
  • $\begingroup$ @Thursday I added a bit of background. It is a system of 5 equations and for some of the equations I only impose a boundary condition at on side. Added some detail in the post with a link to the problem. $\endgroup$ – Edgar H Aug 26 '14 at 12:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.