Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accumulate gravitational interactions in DoublePrecision #1351

Closed
eggrobin opened this issue Apr 30, 2017 · 7 comments
Closed

Accumulate gravitational interactions in DoublePrecision #1351

eggrobin opened this issue Apr 30, 2017 · 7 comments
Assignees

Comments

@eggrobin
Copy link
Member

Different behaviour due to non-associativity being amplified by the uncorrected stock system's terrible Ляпунов exponent is expected, but Aardvark being stabler than Kerbol which is stabler than Sun points to a systematic error due to cancellation.

@pleroy
Copy link
Member

pleroy commented May 27, 2017

Tried this, and it doesn't help, the system remains sensitive to the order.

@pleroy
Copy link
Member

pleroy commented Aug 12, 2017

It turns out that using compensated summation (Increment or Decrement) is not correct: these methods are only valid if the addend is smaller that the current value. For accelerations we don't have any guarantees to that effect, and it's clear that reordering the bodies will affect the final result. Experiments with Mathematica show that reordering the bodies results in an error which is of 52 bits at the beginning (fine) but which occasionally jumps to 40 bits. When these errors accumulate the trajectories of the planets end up being affected significantly (remember that the stock system is very unstable).

Using full double precision fixes the problem, but we probably don't want to pay the cost of 10 additions/subtractions instead of 1 in the inner loop of the force computation. For a stable solar system these inaccuracies have no effect whatsoever.

@pleroy
Copy link
Member

pleroy commented Aug 12, 2017

Code pushed to pleroy/1351.

@oscardssmith
Copy link

Would either pairwise summation, or Kahan summation help this?

@pleroy
Copy link
Member

pleroy commented Nov 30, 2017

See the reference to "compensated summation" in the comment above, which is another name for "Kahan summation". Kahan summation can yield large relative errors for ill-conditioned sums. That's one of these cases.

@oscardssmith
Copy link

And pairwise isn't helping enough?

Sorry, something went wrong.

@pleroy
Copy link
Member

pleroy commented Nov 30, 2017

Pairwise is less precise than Kahan and has the same conditioning properties.

The numerical analysis above was mostly done to check that the sensitivity to order doesn't hide a bug. It doesn't. Done. The problem of accurately predicting the Kerbin system over long periods of time is spectacularly uninteresting as that system is extremely unstable (on a scale of months in the stock game).

Sorry, something went wrong.

@pleroy pleroy closed this as completed May 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants