#   4. DEMO  -  put a satellite into an orbit round the earth


func x,y,vx,vy;  # coordinates of the place and velocity 

const f,mF,m;   # constant of the gravitation, mass of the earth,
                # mass of the satellite
aux r;          # distance of the satellite from the center of the earth
aux Fx,Fy;      # components of the force
aux ax,ay;      # components of the acceleration


r=sqrt(x*x+y*y); # distance of the satellite from the center of the earth

Fx=f*mF*m/r/r*x/r;
Fy=f*mF*m/r/r*y/r;

ax=Fx/m;
ay=Fy/m;

x'=vx;
y'=vy;
vx'=ax;
vy'=ay;

endmodel;

f=-6.67E-11;     # constant of the gravitation
mF=5.976E24;     # mass of the earth
m=1000;


x=6.378E6;         # initial parameters
y=0;
vx=0;
vy=7.905E3;

rerr(x,0.00005);   #  error bounds of the solution
rerr(y,0.00005); 
rerr(vx,0.00005);
rerr(vy,0.00005);

run(0,10000,100,x,y,vx,vy,r,ax,ay,Fx,Fy); #  interval of the modelling

print(table,0,10000,100,r,x,y);          # table

plot(graph,0,10000,100,x=x,y=y,r=r);       # graph

