I'm trying to develop my knowledge about numerical methods. When studying finite difference methods in the boundary value problem I try to realize my code solving problem I came up with.

I start thinking about easy problem $u''=1, u(0)=0, u'(0)=0, x\in [0,1]$. I took $h=0.1$, and used the second finite difference $$\frac{u_{i-1} -2u_i+u_{i+1}}{h^2}=1, u_0 = 0, \frac{u_1-u_0}{h}=0$$

Having solved the finite difference system on the grid with 10 nodes I noticed that my solution differs with analytical one sharply. I realized then that I actually should have solved initial value problem instead of boundary value problem. Then I used RK4 for solving this problem and it gave good results.

I wonder why finite difference method produce this result with my first formulation of the problem? What is the problem I solved at the first time?

Graphic Results with difference method

  • $\begingroup$ $\dfrac{u_{i-1} -2u_i+u_{i+1}}{h^2}=1$ is going to lead to a quadratic solution and your blue line seems to meet this, looking like a parabola with roughly the correct curvature. But it is in the wrong position, and in particular I cannot see what made you think it would go negative $\endgroup$ – Henry Jan 20 '17 at 9:52
  • $\begingroup$ My questions were why finite different method cannot solve initial value formulation of the problem I came up with and what have been solved by me actually when using finite difference method? As you can see the blue line is more like a solution of the boundary problem $u_0 = 0, u_n = 1$. $\endgroup$ – lR55 Jan 20 '17 at 16:31
  • 1
    $\begingroup$ The problem is in the implementation. Check your code. $\endgroup$ – Eliad Jan 23 '17 at 16:14
  • $\begingroup$ Here the LINK. You can execute my script and see my results for $u$. Choose Octave as programming language $\endgroup$ – lR55 Jan 23 '17 at 17:59
  • $\begingroup$ You are mixing up concepts here: RK4 is also a finite difference method. $\endgroup$ – Winther Jan 25 '17 at 23:05

If somebody is interested this question was fully investigated already. My matrix for finite difference method was badly organized as Eliad supposed, so it produced wrong result.

The finite difference method works for this problem well, it converges to the actual solution. Full answer is here.


Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.