- #1

- 459

- 1

You are using an out of date browser. It may not display this or other websites correctly.

You should upgrade or use an alternative browser.

You should upgrade or use an alternative browser.

- Thread starter dimensionless
- Start date

- #1

- 459

- 1

- #2

Integral

Staff Emeritus

Science Advisor

Gold Member

- 7,212

- 56

The standard Euler method loses even a simple pendulum pretty quickly, the improved Euler and RK does much better.

- #3

- 459

- 1

a = -kx -bv

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

- #4

arildno

Science Advisor

Homework Helper

Gold Member

Dearly Missed

- 10,025

- 134

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.

- #5

- 459

- 1

- #6

Integral

Staff Emeritus

Science Advisor

Gold Member

- 7,212

- 56

Go with RK4

- #7

- 459

- 1

- #8

Integral

Staff Emeritus

Science Advisor

Gold Member

- 7,212

- 56

- #9

- 459

- 1

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

Integral

Staff Emeritus

Science Advisor

Gold Member

- 7,212

- 56

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

- 459

- 1

- #12

jim mcnamara

Mentor

- 4,469

- 3,232

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

Integral

Staff Emeritus

Science Advisor

Gold Member

- 7,212

- 56

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

- 459

- 1

A step size of 1 through my numbers way off. I tried setting the step size to

and then multiplying my output array by 66536.0 and the real step size as followsh = 1.0/65536.0;

for(i=0; i<length; i++)

{

out_put= out_put*65536.0*step_size;

}

- #15

- 459

- 1

Share: