<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://dynamo.iro.umontreal.ca/wiki/skins/common/feed.css?270"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://dynamo.iro.umontreal.ca/~gambit/wiki/index.php?title=Programming_language_shootout:_n-body&amp;feed=atom&amp;action=history</id>
		<title>Programming language shootout: n-body - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://dynamo.iro.umontreal.ca/~gambit/wiki/index.php?title=Programming_language_shootout:_n-body&amp;feed=atom&amp;action=history"/>
		<link rel="alternate" type="text/html" href="http://dynamo.iro.umontreal.ca/wiki/index.php?title=Programming_language_shootout:_n-body&amp;action=history"/>
		<updated>2013-05-20T03:50:19Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.16.4</generator>

	<entry>
		<id>http://dynamo.iro.umontreal.ca/wiki/index.php?title=Programming_language_shootout:_n-body&amp;diff=67&amp;oldid=prev</id>
		<title>Bjlucier: correct link to alioth</title>
		<link rel="alternate" type="text/html" href="http://dynamo.iro.umontreal.ca/wiki/index.php?title=Programming_language_shootout:_n-body&amp;diff=67&amp;oldid=prev"/>
				<updated>2008-02-22T21:59:24Z</updated>
		
		<summary type="html">&lt;p&gt;correct link to alioth&lt;/p&gt;
&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
		&lt;tr valign='top'&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 21:59, 22 February 2008&lt;/td&gt;
		&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This is a Gambit implementation of the [http://shootout.alioth.debian.org/&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;gp4&lt;/del&gt;/benchmark.php?test=&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;n-body&lt;/del&gt;&amp;amp;lang=all n-body] benchmark of the [[Programming language shootout|Computer Language Benchmarks Game]].&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This is a Gambit implementation of the [http://shootout.alioth.debian.org/&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;gp4sandbox&lt;/ins&gt;/benchmark.php?test=&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;nbody&lt;/ins&gt;&amp;amp;lang=all n-body] benchmark of the [[Programming language shootout|Computer Language Benchmarks Game]].&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;==The program==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;==The program==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Bjlucier</name></author>	</entry>

	<entry>
		<id>http://dynamo.iro.umontreal.ca/wiki/index.php?title=Programming_language_shootout:_n-body&amp;diff=52&amp;oldid=prev</id>
		<title>Bjlucier: specialize two inequalities to fixnums</title>
		<link rel="alternate" type="text/html" href="http://dynamo.iro.umontreal.ca/wiki/index.php?title=Programming_language_shootout:_n-body&amp;diff=52&amp;oldid=prev"/>
				<updated>2008-02-22T20:59:33Z</updated>
		
		<summary type="html">&lt;p&gt;specialize two inequalities to fixnums&lt;/p&gt;
&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
		&lt;tr valign='top'&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 20:59, 22 February 2008&lt;/td&gt;
		&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 173:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 173:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;;; -------------------------------&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;;; -------------------------------&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;(define (main . args)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;(define (main . args)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; (let ((n (if (&amp;lt; (length args) 1)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; (let ((n (if (&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;fx&lt;/ins&gt;&amp;lt; (length args) 1)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;  1&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;  1&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;  (string-&amp;gt;number (car args))))&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;  (string-&amp;gt;number (car args))))&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 180:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 180:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; (display (roundto 9 (energy system))) (newline)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; (display (roundto 9 (energy system))) (newline)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; (do ((i 1 (fx+ i 1)))&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; (do ((i 1 (fx+ i 1)))&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ((&amp;lt; n i))&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ((&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;fx&lt;/ins&gt;&amp;lt; n i))&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; (advance system 0.01))&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; (advance system 0.01))&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; (display (roundto 9 (energy system))) (newline)))&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; (display (roundto 9 (energy system))) (newline)))&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Bjlucier</name></author>	</entry>

	<entry>
		<id>http://dynamo.iro.umontreal.ca/wiki/index.php?title=Programming_language_shootout:_n-body&amp;diff=51&amp;oldid=prev</id>
		<title>Bjlucier: Add n-body alioth benchmark</title>
		<link rel="alternate" type="text/html" href="http://dynamo.iro.umontreal.ca/wiki/index.php?title=Programming_language_shootout:_n-body&amp;diff=51&amp;oldid=prev"/>
				<updated>2008-02-22T20:58:01Z</updated>
		
		<summary type="html">&lt;p&gt;Add n-body alioth benchmark&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This is a Gambit implementation of the [http://shootout.alioth.debian.org/gp4/benchmark.php?test=n-body&amp;amp;lang=all n-body] benchmark of the [[Programming language shootout|Computer Language Benchmarks Game]].&lt;br /&gt;
&lt;br /&gt;
==The program==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!gsi-script&lt;br /&gt;
&lt;br /&gt;
;; The Computer Language Benchmarks Game&lt;br /&gt;
;; http://shootout.alioth.debian.org/&lt;br /&gt;
;;&lt;br /&gt;
;; Derived by Bradley Lucier from the Ikarus variant&lt;br /&gt;
;; Derived by Michael D. Adams from the MzScheme variant&lt;br /&gt;
&lt;br /&gt;
#|&lt;br /&gt;
Correct output N = 1000 is&lt;br /&gt;
&lt;br /&gt;
-0.169075164&lt;br /&gt;
-0.169087605&lt;br /&gt;
|#&lt;br /&gt;
&lt;br /&gt;
(declare (standard-bindings)(extended-bindings)(block)(not safe))&lt;br /&gt;
&lt;br /&gt;
(define-macro (unless test . body)&lt;br /&gt;
  `(if (not ,test)&lt;br /&gt;
       (begin&lt;br /&gt;
	 ,@body)))&lt;br /&gt;
&lt;br /&gt;
;;; Stupid boiler-plate for formatting floating point values&lt;br /&gt;
(define (roundto digits n)&lt;br /&gt;
  (let* ([e (expt 10 digits)]&lt;br /&gt;
         [num (round (abs (* e (inexact-&amp;gt;exact n))))]&lt;br /&gt;
         [str (number-&amp;gt;string (modulo num e))])&lt;br /&gt;
    (string-append&lt;br /&gt;
     (if (negative? n) &amp;quot;-&amp;quot; &amp;quot;&amp;quot;)&lt;br /&gt;
     (number-&amp;gt;string (quotient num e))&lt;br /&gt;
     &amp;quot;.&amp;quot;&lt;br /&gt;
     (make-string (- digits (string-length str)) #\0)&lt;br /&gt;
     str)))&lt;br /&gt;
&lt;br /&gt;
;; ------------------------------&lt;br /&gt;
;; define planetary masses, initial positions &amp;amp; velocity&lt;br /&gt;
&lt;br /&gt;
(define *pi* 3.141592653589793)&lt;br /&gt;
(define *days-per-year* 365.24)&lt;br /&gt;
&lt;br /&gt;
(define *solar-mass* (* 4 *pi* *pi*))&lt;br /&gt;
&lt;br /&gt;
(define (make-body x y z vx vy vz mass)&lt;br /&gt;
  (f64vector x y z vx vy vz mass))&lt;br /&gt;
&lt;br /&gt;
(define (body-x body)           (f64vector-ref  body 0))&lt;br /&gt;
(define (body-x-set! body val)  (f64vector-set! body 0 val))&lt;br /&gt;
(define (body-y body)           (f64vector-ref  body 1))&lt;br /&gt;
(define (body-y-set! body val)  (f64vector-set! body 1 val))&lt;br /&gt;
(define (body-z body)           (f64vector-ref  body 2))&lt;br /&gt;
(define (body-z-set! body val)  (f64vector-set! body 2 val))&lt;br /&gt;
(define (body-vx body)          (f64vector-ref  body 3))&lt;br /&gt;
(define (body-vx-set! body val) (f64vector-set! body 3 val))&lt;br /&gt;
(define (body-vy body)          (f64vector-ref  body 4))&lt;br /&gt;
(define (body-vy-set! body val) (f64vector-set! body 4 val))&lt;br /&gt;
(define (body-vz body)          (f64vector-ref  body 5))&lt;br /&gt;
(define (body-vz-set! body val) (f64vector-set! body 5 val))&lt;br /&gt;
;; mass is immutable&lt;br /&gt;
(define (body-mass body) (f64vector-ref body 6))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(define *sun*&lt;br /&gt;
  (make-body 0.0 0.0 0.0 0.0 0.0 0.0 *solar-mass*))&lt;br /&gt;
&lt;br /&gt;
(define *jupiter*&lt;br /&gt;
  (make-body 4.84143144246472090&lt;br /&gt;
             -1.16032004402742839&lt;br /&gt;
             -1.03622044471123109e-1&lt;br /&gt;
             (* 1.66007664274403694e-3 *days-per-year*)&lt;br /&gt;
             (* 7.69901118419740425e-3 *days-per-year*)&lt;br /&gt;
             (* -6.90460016972063023e-5 *days-per-year*)&lt;br /&gt;
             (* 9.54791938424326609e-4 *solar-mass*)))&lt;br /&gt;
&lt;br /&gt;
(define *saturn*&lt;br /&gt;
  (make-body 8.34336671824457987&lt;br /&gt;
             4.12479856412430479&lt;br /&gt;
             -4.03523417114321381e-1&lt;br /&gt;
             (* -2.76742510726862411e-3 *days-per-year*)&lt;br /&gt;
             (* 4.99852801234917238e-3 *days-per-year*)&lt;br /&gt;
             (* 2.30417297573763929e-5 *days-per-year*)&lt;br /&gt;
             (* 2.85885980666130812e-4 *solar-mass*)))&lt;br /&gt;
&lt;br /&gt;
(define *uranus*&lt;br /&gt;
  (make-body 1.28943695621391310e1&lt;br /&gt;
             -1.51111514016986312e1&lt;br /&gt;
             -2.23307578892655734e-1&lt;br /&gt;
             (* 2.96460137564761618e-03 *days-per-year*)&lt;br /&gt;
             (* 2.37847173959480950e-03 *days-per-year*)&lt;br /&gt;
             (* -2.96589568540237556e-05 *days-per-year*)&lt;br /&gt;
             (*  4.36624404335156298e-05 *solar-mass*)))&lt;br /&gt;
&lt;br /&gt;
(define *neptune*&lt;br /&gt;
  (make-body 1.53796971148509165e+01&lt;br /&gt;
             -2.59193146099879641e+01&lt;br /&gt;
             1.79258772950371181e-01&lt;br /&gt;
             (* 2.68067772490389322e-03 *days-per-year*)&lt;br /&gt;
             (* 1.62824170038242295e-03 *days-per-year*)&lt;br /&gt;
             (* -9.51592254519715870e-05 *days-per-year*)&lt;br /&gt;
             (* 5.15138902046611451e-05 *solar-mass*)))&lt;br /&gt;
&lt;br /&gt;
;; -------------------------------&lt;br /&gt;
(define (offset-momentum system)&lt;br /&gt;
  (let loop-i ((i system) (px 0.0) (py 0.0) (pz 0.0))&lt;br /&gt;
    (if (null? i)&lt;br /&gt;
        (begin&lt;br /&gt;
          (body-vx-set! (car system) (fl/ (fl- px) *solar-mass*))&lt;br /&gt;
          (body-vy-set! (car system) (fl/ (fl- py) *solar-mass*))&lt;br /&gt;
          (body-vz-set! (car system) (fl/ (fl- pz) *solar-mass*)))&lt;br /&gt;
        (loop-i (cdr i)&lt;br /&gt;
                (fl+ px (fl* (body-vx (car i)) (body-mass (car i))))&lt;br /&gt;
                (fl+ py (fl* (body-vy (car i)) (body-mass (car i))))&lt;br /&gt;
                (fl+ pz (fl* (body-vz (car i)) (body-mass (car i))))))))&lt;br /&gt;
&lt;br /&gt;
;; -------------------------------&lt;br /&gt;
(define (energy system)&lt;br /&gt;
  (let loop-o ((o system) (e 0.0))&lt;br /&gt;
    (if (null? o)&lt;br /&gt;
        e&lt;br /&gt;
        (let ([e (fl+ e (fl* 0.5 (body-mass (car o))&lt;br /&gt;
                             (fl+ (fl* (body-vx (car o)) (body-vx (car o)))&lt;br /&gt;
                                  (fl* (body-vy (car o)) (body-vy (car o)))&lt;br /&gt;
                                  (fl* (body-vz (car o)) (body-vz (car o))))))])&lt;br /&gt;
          (let loop-i ((i (cdr o)) (e e))&lt;br /&gt;
            (if (null? i)&lt;br /&gt;
                (loop-o (cdr o) e)&lt;br /&gt;
                (let* ((dx (fl- (body-x (car o)) (body-x (car i))))&lt;br /&gt;
                       (dy (fl- (body-y (car o)) (body-y (car i))))&lt;br /&gt;
                       (dz (fl- (body-z (car o)) (body-z (car i))))&lt;br /&gt;
                       (distance (flsqrt (fl+ (fl* dx dx) (fl* dy dy) (fl* dz dz)))))&lt;br /&gt;
                  (let ([e  (fl- e (fl/ (fl* (body-mass (car o)) (body-mass (car i))) distance))])&lt;br /&gt;
                    (loop-i (cdr i) e)))))))))&lt;br /&gt;
&lt;br /&gt;
;; -------------------------------&lt;br /&gt;
(define (advance system dt)&lt;br /&gt;
  (let loop-o ((o system))&lt;br /&gt;
    (unless (null? o)&lt;br /&gt;
            (let loop-i ((i (cdr o)))&lt;br /&gt;
              (unless (null? i)&lt;br /&gt;
                      (let* ((o1 (car o))&lt;br /&gt;
                             (i1 (car i))&lt;br /&gt;
                             (dx (fl- (body-x o1) (body-x i1)))&lt;br /&gt;
                             (dy (fl- (body-y o1) (body-y i1)))&lt;br /&gt;
                             (dz (fl- (body-z o1) (body-z i1)))&lt;br /&gt;
                             (distance (flsqrt (fl+ (fl* dx dx)&lt;br /&gt;
                                                    (fl* dy dy)&lt;br /&gt;
                                                    (fl* dz dz))))&lt;br /&gt;
                             (mag (fl/ dt (fl* distance distance distance)))&lt;br /&gt;
                             (dxmag (fl* dx mag))&lt;br /&gt;
                             (dymag (fl* dy mag))&lt;br /&gt;
                             (dzmag (fl* dz mag))&lt;br /&gt;
                             (om (body-mass o1))&lt;br /&gt;
                             (im (body-mass i1)))&lt;br /&gt;
                        (body-vx-set! o1 (fl- (body-vx o1) (fl* dxmag im)))&lt;br /&gt;
                        (body-vy-set! o1 (fl- (body-vy o1) (fl* dymag im)))&lt;br /&gt;
                        (body-vz-set! o1 (fl- (body-vz o1) (fl* dzmag im)))&lt;br /&gt;
                        (body-vx-set! i1 (fl+ (body-vx i1) (fl* dxmag om)))&lt;br /&gt;
                        (body-vy-set! i1 (fl+ (body-vy i1) (fl* dymag om)))&lt;br /&gt;
                        (body-vz-set! i1 (fl+ (body-vz i1) (fl* dzmag om)))&lt;br /&gt;
                        (loop-i (cdr i)))))&lt;br /&gt;
            (loop-o (cdr o))))&lt;br /&gt;
  (let loop-o ((o system))&lt;br /&gt;
    (unless (null? o)&lt;br /&gt;
            (let ([o1 (car o)])&lt;br /&gt;
              (body-x-set! o1 (fl+ (body-x o1) (fl* dt (body-vx o1))))&lt;br /&gt;
              (body-y-set! o1 (fl+ (body-y o1) (fl* dt (body-vy o1))))&lt;br /&gt;
              (body-z-set! o1 (fl+ (body-z o1) (fl* dt (body-vz o1))))&lt;br /&gt;
              (loop-o (cdr o))))))&lt;br /&gt;
&lt;br /&gt;
;; -------------------------------&lt;br /&gt;
(define (main . args)&lt;br /&gt;
  (let ((n (if (&amp;lt; (length args) 1)&lt;br /&gt;
               1&lt;br /&gt;
               (string-&amp;gt;number (car args))))&lt;br /&gt;
        (system (list *sun* *jupiter* *saturn* *uranus* *neptune*)))&lt;br /&gt;
    (offset-momentum system)&lt;br /&gt;
    (display (roundto 9 (energy system))) (newline)&lt;br /&gt;
    (do ((i 1 (fx+ i 1)))&lt;br /&gt;
        ((&amp;lt; n i))&lt;br /&gt;
      (advance system 0.01))&lt;br /&gt;
    (display (roundto 9 (energy system))) (newline)))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==Compiling==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gsc n-body&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==Running==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gsi n-body 20000000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bjlucier</name></author>	</entry>

	</feed>