home *** CD-ROM | disk | FTP | other *** search
- # ORBIT.ODE
- # A planetary orbit around a fixed star. It should be an ellipse.
- # Use 4th order Runge-Kutta, fixed step size, 200 steps, solve to t=50.
- $m -4
- $n 200
- $t 50
-
- # Planet is at (x,y)
- x = 1
- y = 0
-
- # Initial velocity
- vx = 0
- vy = 1
-
- # Dynamics given by Newton's second law:
- r3 = cub(sqrt(sqr(x)+sqr(y)))
- x' = vx
- y' = vy
- vx' = -x/r3
- vy' = -y/r3