Numerical solution of 2nd order ODE

In summary, Zurtex has provided a program which can solve for x, for the equation Ax = b. If one leaves a = -1, c = -1 and b = 2 + (1/n^2) (for their number of intervals n), then the program gives approximation solutions to y(0) = 0, y(1) = 0. However, if one is asked to set up a similar system for y(0) = 0, y(1) = 0 with a larger number of intervals, they have no idea where to start.
  • #1
Zurtex
Science Advisor
Homework Helper
1,120
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}
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 \\
\end{array}
\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
  • #2
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}
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 \\
\end{array}
\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.
 
  • #3
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:
  • #4
*hugs saltydog* this seems so much easier now then when my lecturer explained it.
 

1. What is a 2nd order ODE?

A 2nd order ODE (Ordinary Differential Equation) is a type of mathematical equation that involves a function of one variable and its first and second derivatives. These equations are used to model various physical phenomena in science and engineering.

2. Why is numerical solution necessary for 2nd order ODEs?

Numerical solution is necessary for 2nd order ODEs because they often cannot be solved analytically using traditional mathematical methods. This means that a numerical approach, using computers and algorithms, is needed to approximate the solution.

3. How is a 2nd order ODE solved numerically?

A 2nd order ODE is solved numerically by first converting it into a system of first order ODEs using a technique called variable substitution. Then, numerical methods such as Euler's method or the Runge-Kutta method can be used to approximate the solution at discrete points.

4. What are the advantages of using numerical methods to solve 2nd order ODEs?

One advantage of using numerical methods is that they can handle complex and nonlinear equations that may not have a closed-form solution. Additionally, they can provide a quick and efficient way to approximate the solution without needing to solve the equation analytically.

5. What are the limitations of numerical solutions for 2nd order ODEs?

One limitation of numerical solutions is that they are only approximations and may not be entirely accurate. The accuracy of the solution depends on the step size and the chosen method, so it is important to carefully select these parameters. Additionally, numerical methods may have difficulty handling stiff equations or those with discontinuities.

Similar threads

  • Calculus and Beyond Homework Help
Replies
6
Views
517
  • Calculus and Beyond Homework Help
Replies
3
Views
482
  • Calculus and Beyond Homework Help
Replies
3
Views
225
  • Calculus and Beyond Homework Help
Replies
6
Views
739
  • Calculus and Beyond Homework Help
Replies
8
Views
197
Replies
5
Views
1K
  • Calculus and Beyond Homework Help
Replies
2
Views
447
  • Calculus and Beyond Homework Help
Replies
5
Views
603
  • Calculus and Beyond Homework Help
Replies
2
Views
154
  • Calculus and Beyond Homework Help
Replies
4
Views
478
Back
Top