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

  • MATLAB
  • Thread starter vendtfan
  • Start date
  • Tags
    Ode
In summary, the conversation is about coming up with an algorithm for solving second-order ode problems using Euler's method in Matlab. The person is struggling with their minimal Matlab skills and is seeking help. It is suggested to convert the problem into two first-order equations and use a matrix form of Euler's method to track the solution. The output should only include the values of y since the original equation was in terms of y.
  • #1
vendtfan
1
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
  • #2
Can't you just use a system of first-order equations to solve it?
 
  • #3
arildno said:
Can't you just use a system of first-order equations to solve it?

So for example, my function is:

[tex]\frac{d^2y}{dt^2}=-9y[/tex]

So converting it into two first orders would be:

[tex]\frac{dy}{dt} = z[/tex]

and

[tex]\frac{dz}{dt} = -9y[/tex]

So as I understand,

[tex]y' = \int{\frac{dz}{dt}} = -9yt[/tex]

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.
 
  • #4
No, once you have defined z to be dy/dt you have the second equation in your system.

So your system will be:

[tex]\frac{dz}{dt}=-9y[/tex]
[tex]\frac{dy}{dt}=z[/tex]

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.
 

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

1. What is a second-order ODE Euler's?

A second-order ODE (ordinary differential equation) is an equation that contains a second derivative of a function. Euler's method is a numerical method used to approximate solutions to such equations by breaking the interval into small subintervals and using linear approximations.

2. How is Euler's method used to solve second-order ODEs?

Euler's method involves using a finite difference approximation to approximate the derivatives in a second-order ODE and then using this approximation to iteratively find the values of the function at different points on the interval.

3. What are the advantages and disadvantages of using Euler's method for second-order ODEs?

The advantages of using Euler's method include its simplicity and ease of implementation. However, the method can introduce significant error, especially when the subintervals are large, and it may not converge to the true solution for all types of equations.

4. Can Euler's method be used for all types of second-order ODEs?

No, Euler's method may not converge to the true solution for all types of equations. It is typically more accurate for linear equations and can introduce significant error for nonlinear equations.

5. Are there any other methods for solving second-order ODEs?

Yes, there are many other numerical methods for solving second-order ODEs, including Runge-Kutta methods, Adams-Bashforth methods, and finite difference methods. Each method has its own advantages and disadvantages, and the choice of method depends on the specific problem being solved.

Similar threads

Replies
1
Views
3K
Replies
2
Views
3K
Replies
1
Views
6K
Replies
7
Views
3K
Replies
1
Views
3K
Replies
1
Views
4K
Replies
1
Views
3K
Back
Top