- #1

dimensionless

- 463

- 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

dimensionless

- 463

- 1

- #2

Integral

Staff Emeritus

Science Advisor

Gold Member

- 7,253

- 63

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

- #3

dimensionless

- 463

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

- 135

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

dimensionless

- 463

- 1

- #6

Integral

Staff Emeritus

Science Advisor

Gold Member

- 7,253

- 63

Go with RK4

- #7

dimensionless

- 463

- 1

- #8

Integral

Staff Emeritus

Science Advisor

Gold Member

- 7,253

- 63

- #9

dimensionless

- 463

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

- 63

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

dimensionless

- 463

- 1

- #12

jim mcnamara

Mentor

- 4,673

- 3,595

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

- 63

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

dimensionless

- 463

- 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

dimensionless

- 463

- 1

Share:

- Replies
- 10

- Views
- 590

- Replies
- 2

- Views
- 1K

- Last Post

- Replies
- 1

- Views
- 708

- Replies
- 7

- Views
- 1K

- Last Post

- Replies
- 16

- Views
- 2K

- Last Post

- Replies
- 1

- Views
- 1K

- Replies
- 16

- Views
- 1K

- Replies
- 6

- Views
- 2K

- Replies
- 2

- Views
- 3K

- Last Post

- Replies
- 4

- Views
- 1K