comp.lang.ada
 help / color / mirror / Atom feed
From: "Robert I. Eachus" <rieachus@comcast.net>
Subject: Re: [OT] Hints for an algorithm - avoiding O(n^2)
Date: Fri, 12 Mar 2004 09:29:23 -0500
Date: 2004-03-12T09:29:23-05:00	[thread overview]
Message-ID: <n76dnaYyIaHZVMzdRVn-gw@comcast.com> (raw)
In-Reply-To: <1Yi4c.85891$dP1.243229@newsc.telia.net>

Bj�rn Persson wrote:

> If that were true, the moon would orbit the sun and not the Earth (if we 
> ignore the rest of the universe).

Actually it does.  If you compute the gravitational force of the Earth 
on the Moon, and compare it to the gravitational force of the Sun, the 
Sun has a much greater effect.  In fact, the orbit of the Moon around 
the Sun is everywhere convex.

However, back to the OP's question.  The first thing you want to do is 
not use brute force, but use Runga-Kutta for each pair of objects.  This 
makes the calculation about ten times as complex, but gives a much 
better fit.  Second when two objects are "close" you should do the 
Runga-Kutta interpolation much more often.  This usually means 
calculating the effects of all gravitational attractions on the objects 
that are in close proximity more often as well.  (You don't have to do 
the reverse, because the effect of the two nearby objects on remote 
objects will be that of their center of mass.)  Of course you also have 
to allow for the possibility that there are several objects that are 
gravitationally close.  The normal way to do this is to, at the end of 
every major cycle look at the positions of all the objects, and decide 
which ones get the intermediate steps.  It is not worth the effort to 
work with two pairs instead of four 'close' objects.


-- 
                                           Robert I. Eachus

"The only thing necessary for the triumph of evil is for good men to do 
nothing." --Edmund Burke




  parent reply	other threads:[~2004-03-12 14:29 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-12  9:15 [OT] Hints for an algorithm - avoiding O(n^2) Jano
2004-03-12 11:06 ` Jean-Pierre Rosen
2004-03-12 12:53   ` Stuart Palin
2004-03-12 12:55   ` Stuart Palin
2004-03-12 13:48     ` Dmitry A. Kazakov
2004-03-17  1:16       ` jtg
2004-03-12 13:30   ` Björn Persson
2004-03-12 13:42     ` James Rogers
2004-03-12 14:29     ` Robert I. Eachus [this message]
2004-03-12 23:44       ` Björn Persson
2004-03-13 15:21         ` Robert I. Eachus
2004-03-14 17:27           ` Jano
2004-03-15  5:34             ` Robert I. Eachus
2004-03-14 17:27   ` Jano
2004-03-13  0:12 ` Wes Groleau
2004-03-17  2:24 ` jtg
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox