- #1

- 458

- 1

- Thread starter dimensionless
- Start date

- #1

- 458

- 1

- #2

Integral

Staff Emeritus

Science Advisor

Gold Member

- 7,201

- 56

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

- #3

- 458

- 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

- 9,970

- 132

This is not surprising. In pendulum problems, it is generally true that phase inaccuracies (period mismatching) will occur earlier than amplitude inaccuracies.

a = -kx -bv

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

- #5

- 458

- 1

- #6

Integral

Staff Emeritus

Science Advisor

Gold Member

- 7,201

- 56

Go with RK4

- #7

- 458

- 1

- #8

Integral

Staff Emeritus

Science Advisor

Gold Member

- 7,201

- 56

- #9

- 458

- 1

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.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.

- #10

Integral

Staff Emeritus

Science Advisor

Gold Member

- 7,201

- 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

- 458

- 1

- #12

jim mcnamara

Mentor

- 4,098

- 2,590

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,201

- 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

- 458

- 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

- 458

- 1

- Replies
- 4

- Views
- 17K

- Last Post

- Replies
- 1

- Views
- 6K

- Last Post

- Replies
- 4

- Views
- 2K

- Last Post

- Replies
- 5

- Views
- 6K

- Last Post

- Replies
- 7

- Views
- 2K

- Last Post

- Replies
- 16

- Views
- 1K

- Last Post

- Replies
- 5

- Views
- 3K

- Last Post

- Replies
- 6

- Views
- 19K

- Last Post

- Replies
- 2

- Views
- 2K

- Last Post

- Replies
- 3

- Views
- 693