1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Numerical solution of 2nd order ODE

  1. Nov 7, 2005 #1


    User Avatar
    Science Advisor
    Homework Helper

    Got this problem and we've been given a program which can solve for x, for the equation:
    Ax = b
    [tex]A = \left( \begin{array}{rrrrrr}
    b & c & 0 & 0 & \cdots & 0 \\
    a & b & c & 0 & \cdots & 0\\
    0 & \ddots & \ddots & \ddots & & \vdots \\
    \vdots & & \ddots & \ddots & \ddots & 0 \\
    \vdots & & & \ddots & \ddots & c\\
    0 & \cdots & \cdots & 0 & a & b \\

    If I left a = - 1, c = -1 and b = 2 + (1/n^2) (for my number of intervals n) and b = [1/n^2, 1/n^2, ..., 1/n^2]

    Then I am approximation solutions to:

    [tex]-\frac{d^2y}{dx^2} + y = 1 \quad \text{and} \quad y(0)=0 \quad y(1)=0[/tex]

    I kind of understand that (or at least I have notes in front of me which seem to conclude that fairly logically). However I am now asked to set up a similar system for:

    [tex]-\frac{d^2y}{dx^2} + 20 \frac{dy}{dx} = 1 \quad \text{and} \quad y(0)=0 \quad y(1)=0[/tex]

    And I have no idea where to start, any help please.
    Last edited: Nov 7, 2005
  2. jcsd
  3. Nov 7, 2005 #2


    User Avatar
    Science Advisor
    Homework Helper

    Hello Zurtex.

    You start by representing the differential equation in the form of a difference equation right? I assume you're using a central difference:



    Now substitute these difference equations into the DE and then arrange these m equations in m unknowns into a tri-diagonal matrix. First try and obtain the matrix you already posted using the definitions of the central differences for the derivatives.

    I notice you're using n, the total number of points rather than the constant difference in x-values which is h above. 1/n and 1/n^2 is the same thing.

    Remember, the equations start from x_2 and go to x_(n-1) since you already know the boundary points.
  4. Nov 8, 2005 #3


    User Avatar
    Science Advisor
    Homework Helper

    Hey Zurtex, I made a typo above. Should have been all y's. Sorry:


    So substitute these difference quotients into the second equation:


    Simplify, end up with some difference relation:


    Ok, so for example, split up the interval (0,1) into 10 parts. You already know what y1 and y10 are right? That's the boundary conditions. So you have 8 unknowns left: y2, y3 . . . y8. Now set up that matrix equation which expresses these 8 unknowns in terms of 8 equations. The coefficient matrix is then the tridiagonal matrix.
    Last edited: Nov 8, 2005
  5. Nov 8, 2005 #4


    User Avatar
    Science Advisor
    Homework Helper

    *hugs saltydog* this seems so much easier now then when my lecturer explained it.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook