C++ Alternatives to Euler's Method for Solving ODEs

Click For Summary

Discussion Overview

The discussion focuses on alternatives to Euler's method for solving ordinary differential equations (ODEs), exploring various numerical methods and their efficiencies. Participants share experiences with different techniques, including Runge-Kutta methods and variations of Euler's method, while also discussing the accuracy and stability of these methods in specific scenarios.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • Some participants propose Runge-Kutta methods as alternatives to Euler's method for solving ODEs, citing their efficiency.
  • Others mention variations on Euler's method, such as linear multistep methods and Euler-Richardson methods, as potentially effective depending on the problem's nature.
  • A participant shares personal results comparing Euler's method and RK4, noting significant differences in accuracy for a specific ODE.
  • Concerns are raised about the stability of the Euler method, with multiple participants suggesting it should be avoided in certain contexts.
  • One participant highlights that Runge-Kutta methods may not perform well for stiff equations and recommends exploring the GNU Scientific Library for additional methods.

Areas of Agreement / Disagreement

Participants express a general consensus that Euler's method has limitations, particularly regarding stability and accuracy. However, there is no agreement on a single best alternative method, as various approaches are discussed, and some participants emphasize different contexts where specific methods may excel or fail.

Contextual Notes

Participants discuss specific cases and results, but there are unresolved questions about the conditions under which each method performs best. The discussion includes references to specific mathematical examples and deviations observed, which may depend on the parameters chosen.

Who May Find This Useful

This discussion may be useful for individuals interested in numerical methods for solving ordinary differential equations, particularly those exploring the efficiency and accuracy of different approaches in computational contexts.

ChrisVer
Science Advisor
Messages
3,372
Reaction score
465
Hi,

Apart from the Euler's method, is there any other method (with better efficiency) that can let us solve an Ordinary Differential Equation of the form [itex]\frac{dy}{dx}= f(x,y)[/itex]?
 
Physics news on Phys.org
Thanks, I will try to solve an ODE I solved with Euler method using RK4 this time and see how it goes...
 
I am not sure if that can be actually an answerable question, but I will give it a try...
Is it possible for the Euler method to give a deviation from the actual solution of around 0.5%
While the RK4 method gives a deviation of 0.8 *10^(-9) % ?
The correction seems enormous if you asked me...

I solved for the two methods the ODE:
[itex]\frac{dy(x)}{dx} = ay(x)[/itex]
which I know the exact solution: [itex]y(X)= y_0 e^{aX}[/itex]
For [itex]y_0=1[/itex] and [itex]a=1[/itex] and an interval [itex]X=1[/itex] this is just the value of e=2.71828...
Euler method for 100 steps gave me 2.70481 ( [itex]\frac{|e-2.70481|}{e} \approx 0.005[/itex] ) and the RungeKuta4 for 100 steps gave me 2.71828 ( [itex]\frac{|e-RK4|}{e} \approx 8 \times 10^{-12}[/itex]) -i got the last result by letting the program do the calculation of the deviation for me. Otherwise the values as given are indistinguishable.

Not to say that things get even worse for EulerMethod when I apply it for example at [itex]y(X)=10 e^{60}[/itex] where the EM gives almost double the actual value (86% off) while the RK4 keeps itself safe (10^-6 % off).
 
Last edited:
The Euler method can be unstable and should be avoided.
 
  • Like
Likes   Reactions: ChrisVer
DrClaude said:
The Euler method can be unstable and should be avoided.

I also tried the example wiki uses: [itex]y=1 \cdot e^{-2.3 X}[/itex] with 5 (as I see steps)...
The exact solution for X=5 is [itex]10^{-5}[/itex]
Euler gives a very bad result indeed [itex]=-3.71[/itex]...
RK4 gives a bad result as well [itex]0.0263[/itex]...
Things become better for RK4 at >20 steps...
 
Runge-Kutta is not wonderful for stiff equations. Have a look at the GNU Scientific Library (GSL). You will find different methods implemented in there, including some that are well suited to stiff equations.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 7 ·
Replies
7
Views
5K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
10K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 11 ·
Replies
11
Views
22K
  • · Replies 4 ·
Replies
4
Views
2K