Numerical solution of 2nd order ODE

Zurtex
Science Advisor
Homework Helper
Messages
1,118
Reaction score
1
Got this problem and we've been given a program which can solve for x, for the equation:
Ax = b
Where
A = \left( \begin{array}{rrrrrr}<br /> b &amp; c &amp; 0 &amp; 0 &amp; \cdots &amp; 0 \\<br /> a &amp; b &amp; c &amp; 0 &amp; \cdots &amp; 0\\<br /> 0 &amp; \ddots &amp; \ddots &amp; \ddots &amp; &amp; \vdots \\<br /> \vdots &amp; &amp; \ddots &amp; \ddots &amp; \ddots &amp; 0 \\<br /> \vdots &amp; &amp; &amp; \ddots &amp; \ddots &amp; c\\<br /> 0 &amp; \cdots &amp; \cdots &amp; 0 &amp; a &amp; b \\<br /> \end{array}<br /> \right)

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:

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

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:

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

And I have no idea where to start, any help please.
 
Last edited:
Physics news on Phys.org
Zurtex said:
Got this problem and we've been given a program which can solve for x, for the equation:
Ax = b
Where
A = \left( \begin{array}{rrrrrr}<br /> b &amp; c &amp; 0 &amp; 0 &amp; \cdots &amp; 0 \\<br /> a &amp; b &amp; c &amp; 0 &amp; \cdots &amp; 0\\<br /> 0 &amp; \ddots &amp; \ddots &amp; \ddots &amp; &amp; \vdots \\<br /> \vdots &amp; &amp; \ddots &amp; \ddots &amp; \ddots &amp; 0 \\<br /> \vdots &amp; &amp; &amp; \ddots &amp; \ddots &amp; c\\<br /> 0 &amp; \cdots &amp; \cdots &amp; 0 &amp; a &amp; b \\<br /> \end{array}<br /> \right)

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:

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

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:

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

And I have no idea where to start, any help please.

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:

\frac{d^2y}{dx^2}=\frac{x_{i+1}-2x_i+x_{i-1}}{h^2}

\frac{dy}{dx}=\frac{x_{i+1}-x_{i-1}}{2h}

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.
 
saltydog said:
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:
\frac{d^2y}{dx^2}=\frac{x_{i+1}-2x_i+x_{i-1}}{h^2}
\frac{dy}{dx}=\frac{x_{i+1}-x_{i-1}}{2h}

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

\frac{d^2y}{dx^2}=\frac{y_{i+1}-2y_i+y_{i-1}}{h^2}
\frac{dy}{dx}=\frac{y_{i+1}-y_{i-1}}{2h}

So substitute these difference quotients into the second equation:

-\left(\frac{y_{i+1}-2y_i+y_{i-1}}{h^2}\right)+20\left(\frac{y_{i+1}-y_{i-1}}{2h}\right)=1

Simplify, end up with some difference relation:

ay_{n-1}+by_n+cy_{n+1}=d

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:
*hugs saltydog* this seems so much easier now then when my lecturer explained it.
 
There are two things I don't understand about this problem. First, when finding the nth root of a number, there should in theory be n solutions. However, the formula produces n+1 roots. Here is how. The first root is simply ##\left(r\right)^{\left(\frac{1}{n}\right)}##. Then you multiply this first root by n additional expressions given by the formula, as you go through k=0,1,...n-1. So you end up with n+1 roots, which cannot be correct. Let me illustrate what I mean. For this...
Back
Top