Results 1 to 3 of 3
Like Tree1Thanks
  • 1 Post By chiro

Thread: Numerical solution of partial differential equation

  1. #1
    Senior Member
    Joined
    May 2010
    Posts
    251

    Numerical solution of partial differential equation

    Hi there. I am trying to self teach how to solve partial differential equations numerically using finite differences. I know this is a complex field, that requires much more knowledge of the theory than what I actually know, but anyway I wanted to try.


    Anyway, I've tried to build my own differential equation, probably naively. I wanted to solve a first order partial differential equation, so I thought of taking the function:


    f(x,y)=sin(x-y)


    And then, taking derivatives I build the differential equation:


    \displaystyle \frac{\partial f(x,y)}{\partial x}+\frac{\partial f(x,y)}{\partial y}=0, and I considered the interval 0\leq x \leq 1, 0\leq y \leq 1


    Then I considered the boundary conditions f(0,y)=\sin(-y), f(1,y)=\sin(1-y), f(x,0)=\sin(x) and f(x,1)=\sin(x-1).




    I think that everything is correct until here, but I'm not sure, if anything is wrong please tell me.


    Then I considered centered differences (I needed for centered difference to have the previous and forward steps in the equation, in order to propagate the solution from the boundaries). I've considered equal spacings in the y and x directions, with x_i=i\Delta x=ih, y_j=j\Delta y=j h, and h=\frac{1}{N+1}, with N being the number of interior points in each axis, being (x_0,y_j),(x_{N+1},y_j) and (x_i,y_0),(x_i,y_{N+1}) the points situated at the boundaries of the domain.


    Under this conditions I've arrived to the set of equations:


    u_{i+1,j}-u_{i-1,j}+u_{i,j+1}-u_{i,j-1}=0


    Where I thought that u_{i,j}\sim f(x_i,y_j)


    Then the discretized version of the boundary conditions would look like: [tex]u_{0,j}=\sin(-jh)[tex], u_{N+1,j}=\sin(1-jh), u_{i,0}=\sin(ih) and u_{i,N+1}=\sin(ih-1).


    But when I build the matrix and solve the linear system I get the result that the matrix is singular. So what would be the correct approach to this problem?
    Follow Math Help Forum on Facebook and Google+

  2. #2
    MHF Contributor
    Joined
    Sep 2012
    From
    Australia
    Posts
    6,572
    Thanks
    1710

    Re: Numerical solution of partial differential equation

    Hey Ulysses.

    You should look to see when the matrix you use to step through has a zero determinant.

    If you are stepping through a partial differential equation, you will be doing something along the lines of a Taylor series expansion except you will be using linear operators [which are matrices] instead of normal derivatives.

    Can you show us the scheme you are using?

    As a hint - the Euler routine is y(x) = y(a) + y'(a)[x-a] + y''(a)[x-a]^2/2 + .... and instead of the derivatives you will be using linear operators and vectors instead of normal numbers.
    Thanks from Ulysses
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Senior Member
    Joined
    May 2010
    Posts
    251

    Re: Numerical solution of partial differential equation

    Hi, thank you very much for your kind response.

    I am using, as I said, the same regular discretization in both directions with a step distance h=\frac{1}{N+1}: x_i=i\Delta x=ih and y_j=j\Delta y=jh

    with 0\leq x,y \leq 1, so that: (x_0,y_0)=(0,0) and (x_{N+1},y_{N+1})=(1,1)

    In the discrete case I have this boundary conditions:
    u_{0,j}=\sin(-y_j)=\sin(-jh), u_{N+1,j}=\sin(1-y_j)=\sin(1-jh) for all j=0,1,2,...,N+1
    u_{i,0}=\sin(x_i)=\sin(ih), u_{i,N+1}=\sin(x_i-1)=\sin(1-ih) for all i=0,1,2,...,N+1

    From centered finite differences, the differential equation is:

    u_{i+1,j}-u_{i-1,j}+u_{i,j+1}-u_{i,j-1}=0 where I considered this equation for all i,j being interior points on the domain.

    for the case N=2 from this set of equations I get this linear system:

    \begin{bmatrix} 0 & 1 & 1 & 0 \\ -1 & 0 & 0 & 1 \\ -1 & 0 & 0 & 1 \\ 0 & -1 & -1 & 0  \end{bmatrix}  \left[ \begin{array}{c} u_{1,1} \\ u_{2,1} \\ u_{1,2} \\ u_{2,2} \end{array} \right] = \left[ \begin{array}{c} u_{0,1}+u_{1,0} \\ u_{2,0}+u_{3,1} \\ u_{0,2}+u_{1,3} \\ -u_{2,3}-u_{3,2} \end{array} \right]

    I have actually tried to solve the linear system for the N=3 case, which contains a 9x9 matrix, but I think that if the problem is in the algorithm, the case N=2 should equally serve to discuss the problem.
    Last edited by Ulysses; Dec 20th 2016 at 05:01 AM.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Partial Differential Equation numerical problem
    Posted in the Differential Equations Forum
    Replies: 2
    Last Post: Nov 18th 2015, 06:35 AM
  2. Replies: 6
    Last Post: Aug 23rd 2015, 05:43 PM
  3. Numerical solution of partial differential equation
    Posted in the Advanced Math Topics Forum
    Replies: 1
    Last Post: Aug 17th 2014, 02:25 PM
  4. Advanced numerical solution of differential equation
    Posted in the Advanced Applied Math Forum
    Replies: 0
    Last Post: Apr 9th 2014, 07:03 PM
  5. Numerical solution of partial differential equation
    Posted in the Advanced Applied Math Forum
    Replies: 1
    Last Post: Oct 27th 2013, 09:58 AM

/mathhelpforum @mathhelpforum