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

  • Thread starter Thread starter mrsvan
  • Start date Start date
  • Tags Tags
    Euler Runge-kutta
AI Thread 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
 
Seemingly by some mathematical coincidence, a hexagon of sides 2,2,7,7, 11, and 11 can be inscribed in a circle of radius 7. The other day I saw a math problem on line, which they said came from a Polish Olympiad, where you compute the length x of the 3rd side which is the same as the radius, so that the sides of length 2,x, and 11 are inscribed on the arc of a semi-circle. The law of cosines applied twice gives the answer for x of exactly 7, but the arithmetic is so complex that the...
Back
Top