0
$\begingroup$

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

  • 0
    $\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 negative2017-01-20
  • 0
    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$.2017-01-20
  • 1
    The problem is in the implementation. Check your code.2017-01-23
  • 0
    Here the [LINK](http://ideone.com/MOXNxB). You can execute my script and see my results for $u$. Choose Octave as programming language2017-01-23
  • 0
    You are mixing up concepts here: RK4 is also a finite difference method.2017-01-25
  • 0
    I tried to describe the problem with the best words I found. You can easily edit my question if it is not accurate enough. Anyway, this problem has been solved already.2017-01-26

1 Answers 1

0

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.