(*     Module #3:  Motion with a Constant Velocity     *)

(*     Example of using ListPlot to graph data    *)
ListPlot[{{0,0},{1,10},{2,20},{3,30},{4,40},{5,50}}]

(*     Example of using LisPlot together with some 
       options   *)
ListPlot[{{0,0},{1,10},{2,20},{3,30},{4,40},{5,50}},
                PlotJoined->True,GridLines->Automatic,
                AxesLabel->{"t","x[t]"}]

v=(30.-20.)/(3.-2.)

(*      Interpolation of data    *)
t=2.0;
x[t]=20.;
delta=0.5;
v=10.;
x[t+delta]=x[t]+v*delta

(*      Extrapolation of data       *)
t=9.5;
x[t]=95;
delta=0.5;
v=10.;
x[t+delta]=x[t]+v*delta

(*   Example of a Do-loop           *)
Do[Print[(i^2)],{i,0,4}]

(*   Another example of a D0-loop   *)
Do[k=(i^2);Print[k],{i,0,4,2}]

(*    Program to calculate x vs. t   *)
Clear[x];delta = 1.0;v = 10.;x[0.]=0.;       
Do[ x[t+delta]=x[t]+v*delta;Print[x[t]],{t,0.,10.}]

(*   Another Program to Calculate x vs. t   *)
Clear[x];delta = 1.0;v = 10.;x[0.]=0.;
Do[ x[t+delta]=x[t]+v*delta;
    Print[{t,x[t]}],
    {t,0.,10.}]

(*   A list of data   *)
data={{0,0},{1,10},{2,20},{3,30},{4,40},{5,50},{6,60},
          {7,70},{8,80},{9,90},{10,100}};

(*   Make a graph of the data   *)
ListPlot[data,AxesLabel->{"t","x"}]

(*   A program with a smaller time step   *)
Clear[x];
delta = 0.5;         (*  Time Step delta   *)
v = 10.;             (*  Initial Velocity  *)
x[0.]=0.;            (*  Initial Position  *)
Do[ x[t+delta]=x[t]+v*delta;Print[{t,x[t]}],{t,0.,5.,0.5}]