Numerical solution of 2nd order ODE

Click For Summary

Homework Help Overview

The discussion revolves around setting up a numerical solution for a second-order ordinary differential equation (ODE) using a tridiagonal matrix approach. The original poster is working with the equation -d²y/dx² + y = 1 and is attempting to extend this to a new equation -d²y/dx² + 20 dy/dx = 1, with specified boundary conditions.

Discussion Character

  • Exploratory, Problem interpretation, Assumption checking

Approaches and Questions Raised

  • Participants discuss the need to represent the differential equations in terms of difference equations using central differences. There are attempts to clarify the setup of the tridiagonal matrix and the implications of boundary conditions on the unknowns.

Discussion Status

Some participants provide guidance on how to formulate the difference equations and set up the corresponding matrix. There is an acknowledgment of the original poster's confusion, but no consensus has been reached on the final setup of the new system.

Contextual Notes

The original poster is working under the constraints of specific boundary conditions and is transitioning from one differential equation to another, which introduces complexity in the formulation of the new system.

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
[tex]A = \left( \begin{array}{rrrrrr}<br /> b & c & 0 & 0 & \cdots & 0 \\<br /> a & b & c & 0 & \cdots & 0\\<br /> 0 & \ddots & \ddots & \ddots & & \vdots \\<br /> \vdots & & \ddots & \ddots & \ddots & 0 \\<br /> \vdots & & & \ddots & \ddots & c\\<br /> 0 & \cdots & \cdots & 0 & a & b \\<br /> \end{array}<br /> \right)[/tex]

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:
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
[tex]A = \left( \begin{array}{rrrrrr}<br /> b & c & 0 & 0 & \cdots & 0 \\<br /> a & b & c & 0 & \cdots & 0\\<br /> 0 & \ddots & \ddots & \ddots & & \vdots \\<br /> \vdots & & \ddots & \ddots & \ddots & 0 \\<br /> \vdots & & & \ddots & \ddots & c\\<br /> 0 & \cdots & \cdots & 0 & a & b \\<br /> \end{array}<br /> \right)[/tex]

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.

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:

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

[tex]\frac{dy}{dx}=\frac{x_{i+1}-x_{i-1}}{2h}[/tex]

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:
[tex]\frac{d^2y}{dx^2}=\frac{x_{i+1}-2x_i+x_{i-1}}{h^2}[/tex]
[tex]\frac{dy}{dx}=\frac{x_{i+1}-x_{i-1}}{2h}[/tex]

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

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

So substitute these difference quotients into the second equation:

[tex]-\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[/tex]

Simplify, end up with some difference relation:

[tex]ay_{n-1}+by_n+cy_{n+1}=d[/tex]

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.
 

Similar threads

Replies
3
Views
2K
Replies
6
Views
2K
Replies
4
Views
2K
Replies
5
Views
3K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
5
Views
2K
Replies
3
Views
3K
Replies
6
Views
2K
Replies
8
Views
2K