home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Education
/
collectionofeducationcarat1997.iso
/
SCIENCE
/
ODE25.ZIP
/
BINARY.ODE
< prev
next >
Wrap
Text File
|
1990-01-03
|
534b
|
28 lines
# BINARY.ODE
# Planetary orbit in binary star system
# Plot x against y
# Use 5th order Runge-Kutta, auto step-size, 500 steps
$m 6
$n 500
#Solve to 20
$t 20
# (x,y) is position of the planet; (vx,vy) its velocity.
x = 1
y = 0
vx = 0
vy = 1.155, 1.160, 1.165 # notice sensitivity to initial values!
# Binary star centres are at (0,0) and (-5,0)
r13 = cub(sqrt(sqr(x)+ sqr(y)))
r23 = cub(sqrt(sqr(x+5)+sqr(y)))
x' = vx
y' = vy
# Newton's Law
vx' = -x/r13 - (x+5)/r23
vy' = -y/r13 - y/r23