Can anyone help me solve 2nd-order ODEs using Euler's method in MATLAB?

  • Context: MATLAB 
  • Thread starter Thread starter vendtfan
  • Start date Start date
  • Tags Tags
    Ode
Click For Summary

Discussion Overview

The discussion revolves around solving second-order ordinary differential equations (ODEs) using Euler's method in MATLAB. Participants explore the conversion of second-order ODEs into a system of first-order equations and seek guidance on implementing this approach in MATLAB.

Discussion Character

  • Homework-related
  • Mathematical reasoning
  • Technical explanation

Main Points Raised

  • One participant expresses difficulty in using MATLAB for solving second-order ODEs and seeks direction.
  • Another participant suggests converting the second-order ODE into a system of first-order equations as a potential solution.
  • A participant provides an example of a second-order ODE, \(\frac{d^2y}{dt^2}=-9y\), and outlines the conversion to first-order equations: \(\frac{dy}{dt} = z\) and \(\frac{dz}{dt} = -9y\).
  • The same participant describes an issue where their MATLAB implementation appears to work initially but then levels off to zero, questioning whether they should treat the second equation as a conceptual tool or if it requires further manipulation.
  • Another participant clarifies that defining \(z\) as \(\frac{dy}{dt}\) provides the second equation in the system and emphasizes the need to track both \(z\) and \(y\) using a matrix form of Euler's method.

Areas of Agreement / Disagreement

Participants generally agree on the approach of converting the second-order ODE into a system of first-order equations. However, there is some uncertainty regarding the implementation details in MATLAB and the behavior of the solution over time.

Contextual Notes

Participants express confusion regarding the behavior of the solution in MATLAB, particularly about the leveling off of values and the correct treatment of the equations in the Euler method context.

Who May Find This Useful

Individuals interested in numerical methods for solving differential equations, particularly those using MATLAB, as well as students learning about ODEs and Euler's method.

vendtfan
Messages
1
Reaction score
0
I'm trying to come up with an algorithm for solving second-order ode problems with euler's on matlab. the problem is that my MATLAB skills are very minimal! If anyone can point me in the right direction, it would be greatly appreciated!
 
Physics news on Phys.org
Can't you just use a system of first-order equations to solve it?
 
arildno said:
Can't you just use a system of first-order equations to solve it?

So for example, my function is:

\frac{d^2y}{dt^2}=-9y

So converting it into two first orders would be:

\frac{dy}{dt} = z

and

\frac{dz}{dt} = -9y

So as I understand,

y' = \int{\frac{dz}{dt}} = -9yt

When I plug this into Matlab (with a Euler's ODE solver and initial guess of 1), it looks good for about a quarter of a period then levels off to zero. Should I be doing something with the z equation, or do I use it as a conceptual tool to solve the one equation?

I'm sorry, this is very confusing for me, any help would be awesome.
 
No, once you have defined z to be dy/dt you have the second equation in your system.

So your system will be:

\frac{dz}{dt}=-9y
\frac{dy}{dt}=z

You "track" the solution (both z and y) using a matrix form of Euler's method. But since the original equation was in terms of y, you'll output only the values of y.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
7K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 7 ·
Replies
7
Views
4K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K