[Shootout-list] n-body anomalies

Will M. Farr farr@MIT.EDU
Thu, 5 May 2005 22:01:27 -0400


Hello again,

Actually, the question of energy conservation is a bit deeper.  The 
integrator here has the property of being symplectic---meaning that it 
conserves phase space area in the evolution---but not exactly energy 
conserving.  You are seeing both truncation and round-off error in the 
energy.  However, symplectic integration algorithms have the property 
that when evolving a particular system, they are producing the *exact* 
(up to small terms which vanish exponentially in the timestep) 
evolution of a similar conservative system.  Since the similar system 
is conservative, the evolution remains on a constant-energy subspace of 
the phase space for this system; this constant energy subspace is 
typically close to the constant-energy subspace of the original system, 
and thus the trajectory of the numerically-evolved system doesn't stray 
too far from the constant energy subspace of the original system.  
That's a long-winded way of saying that, while symplectic integrators 
such as this one are not exactly energy conserving, they typically 
produce trajectories which oscillate about the true energy, rather than 
being dissipative as is typical with standard methods (i.e. Runge-Kutta 
and Burlisch-Stoer).

Will

P.S.--Symplectic integrators and n-body simulations are a hobby of 
mine, so if anyone is interested, I'd be happy to point toward 
references in the literature.

On 5 May 2005, at 8:48 PM, Jon Harrop wrote:

> On Friday 06 May 2005 01:29, Greg Buchholz wrote:
>> --- Jon Harrop <jon@ffconsultancy.com> wrote:
>>> On Thursday 05 May 2005 03:44, Greg Buchholz wrote:
>>>>     Just a few questions about the n-body test.  It looks like we're
>>>> mostly computing the amount of round-off error in simulating our
>>>> algorithm, correct?
>>>
>>> Do you mean most of the code or most of the time is spent computing
>>> round-off error?
>>
>>     Both?  It looks to me like it is computing the energy of the 
>> bodies
>> before the simulation, performing the simulation, calculating the 
>> final
>> energy, and comparing how well the energy was conserved.  Assuming the
>> physics is correct, the only energy lost from the system is from
>> round-off error.
>
> Yes, I believe that is correct.
>
>> Using rational numbers instead of doubles would have resulted in zero
>> difference in the two answers.
>
> The algorithm features sqrt, which cannot be represented exactly in 
> rational
> arithmetic, so switching to rational arithmetic would not produce zero 
> error.
> It would also take a prohibitively long time. You could accumulate a 
> symbolic
> answer but that is essentially just writing down the problem, rather 
> than
> giving the answer.
>
> These are the reasons that real scientific computing often uses 
> floating
> point. Many of the numbers found in such programs are theoretically
> irrational.
>
> Arguably, the answer should not be the round-off error but something 
> more
> interesting like the time until the next eclipse. Personally, I'd 
> rather see
> an n-body simulation with n >> 5, like n = 10^5.
>
> -- 
> Dr Jon D Harrop, Flying Frog Consultancy Ltd.
> Objective CAML for Scientists
> http://www.ffconsultancy.com/products/ocaml_for_scientists
>
> _______________________________________________
> Shootout-list mailing list
> Shootout-list@lists.alioth.debian.org
> http://lists.alioth.debian.org/mailman/listinfo/shootout-list