Runge-Kutta vs Euler: Solving Two-Dimensional Differential Equation

  • Thread starter Thread starter mrsvan
  • Start date Start date
  • Tags Tags
    Euler Runge-kutta
Click For Summary
The discussion revolves around solving a two-dimensional differential equation, specifically dx/dt = (-y, x), which describes circular motion. The user initially finds the simple Euler method to be more precise than the fourth-order Runge-Kutta method, leading to frustration and confusion after debugging their code for two days. They question whether there are scenarios where Runge-Kutta performs worse than Euler or if their implementation contains an error. Ultimately, the user discovers a mistake related to an extra time increment in their code, resolving the issue. This highlights the importance of careful coding and debugging in numerical methods.
mrsvan
Messages
2
Reaction score
0
Hi, I don't know if this is the right forum to adress, but I will try nevertheless
Im solving a simple two-dimensional differential equation:

dx/dt = (-y,x)

which will give a circle when integrating over time.

Now, the problem is that the simple euler scheme seems to be a lot more precise than the runge-kutta fourth order method. I've spend two whole days trying to debug my code and I feel stuck. so, are there some special cases where rk is worse than euler -- or is there no other explanation than I have made a mistake somewhere (it's four lines of code and my supervisors have had a look without the error popping up.)
 
Mathematics news on Phys.org
great monday... just after complaining in here i found that I've messed an extra time-increment in somewhere in the code :p sorry for the inconvenience
 
Here is a little puzzle from the book 100 Geometric Games by Pierre Berloquin. The side of a small square is one meter long and the side of a larger square one and a half meters long. One vertex of the large square is at the center of the small square. The side of the large square cuts two sides of the small square into one- third parts and two-thirds parts. What is the area where the squares overlap?

Similar threads

  • · Replies 65 ·
3
Replies
65
Views
7K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 3 ·
Replies
3
Views
7K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 7 ·
Replies
7
Views
3K
Replies
2
Views
2K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 4 ·
Replies
4
Views
8K
  • · Replies 19 ·
Replies
19
Views
7K
  • · Replies 1 ·
Replies
1
Views
6K