Results same w/ Euler, Improved Euler, & Runge-Kutta

  • Context: Undergrad 
  • Thread starter Thread starter dimensionless
  • Start date Start date
  • Tags Tags
    Euler Runge-kutta
Click For Summary

Discussion Overview

The discussion revolves around the performance and accuracy of various numerical methods for solving differential equations, specifically focusing on the Euler, improved Euler, and Runge-Kutta methods. Participants share their experiences with simulations involving mass-spring systems and explore issues related to phase accuracy and numerical stability.

Discussion Character

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

Main Points Raised

  • One participant notes that their results from the improved Euler and Runge-Kutta methods are very close to those from the Euler method, raising questions about the commonality of this occurrence and the possibility of round-off errors.
  • Another participant suggests that the effectiveness of numerical methods depends on the nature of the differential equation being solved, indicating that smoother solutions may not show significant differences between methods.
  • Concerns about phase inaccuracies in simulations are discussed, with one participant mentioning that phase mismatching occurs earlier than amplitude inaccuracies in pendulum problems.
  • Some participants propose alternative numerical methods, such as the leap-frog method, and share mixed results regarding their effectiveness compared to Euler methods.
  • There is a discussion about the implications of floating-point representation and round-off errors, with suggestions for using different data types or interpolation techniques to mitigate these issues.
  • One participant expresses skepticism about the superiority of Runge-Kutta methods over Euler methods based on their testing results, questioning if there is a hybrid method that combines features of both.

Areas of Agreement / Disagreement

Participants express a range of opinions on the effectiveness of different numerical methods, with no clear consensus on which method is superior. Some agree on the importance of considering the specific characteristics of the differential equations being solved, while others highlight the variability in results based on the methods used.

Contextual Notes

Participants mention limitations related to round-off errors and the choice of step sizes, particularly the implications of using powers of 2 versus powers of 10 in numerical simulations. There are also references to potential issues with phase accuracy and the stability of various numerical methods.

dimensionless
Messages
461
Reaction score
1
I've been trying to do some simulations using the Euler, improved Euler, and Runge-Kutta methods. My results for the improved Euler and Runge-Kutta are very close to my results with the plain old Euler method. If there is any improvement, it is negligible. This lack of improvement surprises me. Is it a common occurrence? Is it likely that I have a round off error somewhere?
 
Physics news on Phys.org
You should be able to take larger time steps with the RK and maintain accuracy. A lot depends on the DE you are solving. If the solution is smooth and slowly changing then it does not matter much what method you choose. If there are rapid changes (say a step function involved in the boundary or initial conditions) then you will see a difference.

The standard Euler method loses even a simple pendulum pretty quickly, the improved Euler and RK does much better.
 
I'm doing a mass spring. The equation for acceleration

a = -kx -bv

seems to keep things in bounds. I have, however, been having some phase problems.
 
dimensionless said:
I'm doing a mass spring. The equation for acceleration

a = -kx -bv

seems to keep things in bounds. I have, however, been having some phase problems.

This is not surprising. In pendulum problems, it is generally true that phase inaccuracies (period mismatching) will occur earlier than amplitude inaccuracies.
 
Are there other numerical methods, perhaps more obscure ones, that specifically address the issue of phase?
 
Go with RK4
 
RK4 seems to keeps things in phase a little better than the Euler. In contrast, at higher frequencies the magnitude of the oscillations seem to be better represented by the Euler.
 
Keep a VERY close eye on the Euler methods, I have seen it produce absolutly beautiful garbage. The forward step version is signifanlty more stable then the standard Euler.
 
I had a fairly good improvement using the leap-frog method instead of the Euler. In contrast, I used the Verlet method and everything seemed to be much worse than the Euler. I can't say if I'm doing the Verlet correctly, or if one should expect the Verlet method to be way off for a damped oscillator.

Integral said:
Keep a VERY close eye on the Euler methods, I have seen it produce absolutly beautiful garbage. The forward step version is significantly more stable then the standard Euler.

Point taken. I'm using an "adaptive" leap-frog scheme, but I might be able to improve my frequency of oscillation. Perhaps I will try some sort of adaptive RK4.
 
  • #10
Just a couple of aside comments.

If you take steps that are a power of 2 you will not be introducing round off errors. If you are not aware of it .1 (decimal) when translated to binary becomes the infinitely repeating fraction .00011001100... So no mater how many digits you can carry, you MUST round off .1.

To me this is a very good reason to AVOID taking a step size which is a power of 10.
 
  • #11
That's an interesting point. But what if my output data needs to have a step size that is a factor of 10? Should I use a factor of 2 that is smaller, and then interpolate?
 
  • #12
Integral has it exactly.

Floating point representations of numbers have issues. For example: in C, the float, double, and long double data types are FP's with increasing precision. As you extend precision you move the fuzz "further out", and it may sometimes defer the onset of your kind of issue to a later iteration. It does not get rid of it.

If you're using C, consider long double data types and see if it buys you anything in terms of the timing of the onset of phase issues. It may not.
I don't know what your goal is.

You could also interpolate the final results and use a factor of 2. Or find a BCD library ($$) with the precision you need for your model.
 
  • #13
If you feel you must take a power of 10 step use an integer counter to increment your steps then multiply by the step size. Do NOT add your power of 10 step to increment your process.

I recall that on my old 8 bit AppleII that the code

5 x= 0
10 x = x + .1

yielded .9999999 after 10 interations.

but
5 x = 0 : n =0 : st= .1
10 for n = 1 to 10
15 x = n*st
20 next n

gave correct results

The first method accumulates the round off error, while the second does not.
 
  • #14
I'm not sure what you are doing in your code. The first one looks like a numerical method, but the second looks like you are preparing a vector, x, for a plot.

A step size of 1 through my numbers way off. I tried setting the step size to
h = 1.0/65536.0;
and then multiplying my output array by 66536.0 and the real step size as follows
for(i=0; i<length; i++)
{

out_put = out_put*65536.0*step_size;

}
 
  • #15
I've now done a 4th order Runge-Kutta and a Euler-Cromer-Leap-Frog. The Euler-Cromer-Leap-Frog seems to win out on every test. I've long help the belief that Runge-Kuttas were better than Euleroid methods. My tests have shown this not to be the case. Am I missing something? Is there a such thing as some sort of Rung-Kutta-Leap-Frog?
 

Similar threads

  • · Replies 65 ·
3
Replies
65
Views
9K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 1 ·
Replies
1
Views
7K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 15 ·
Replies
15
Views
3K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 14 ·
Replies
14
Views
5K
  • · Replies 3 ·
Replies
3
Views
5K
  • · Replies 19 ·
Replies
19
Views
7K
Replies
8
Views
15K