
fprintf ( '\n' );
fprintf ( 'patriot\n' );
fprintf ( '  The Patriot missile system "ticked" every tenth of a second.\n' );
fprintf ( '  It computed time in seconds as S = T * ONE_TENTH\n' );
fprintf ( '  The system used 24 bit floating arithmetic.\n' );
fprintf ( '  ONE_TENTH was stored as 0.099999905\n' );
fprintf ( '  This meant that the computed time S differed from the\n' );
fprintf ( '  real time R, and this error increased unless the system\n' );
fprintf ( '  was rebooted.\n' );
fprintf ( '\n' );
fprintf ( '  The Scud missile traveled at V=1,676 meters per second.\n' );
fprintf ( '  A position error of more than 137 meters means the\n' );
fprintf ( '  Patriot cannot intercept the Scud.\n' );

one_tenth = 0.099999905;
v = 1676.0;

fprintf ( '\n' );
fprintf ( '  Here is what gradually happens as the system stays on alert.\n' );
fprintf ( '\n' );
fprintf ( '      h        t            r            s      r-s     v*(r-s)\n' );
fprintf ( '  hours    ticks          sec          sec      sec      meters\n' );
fprintf ( '                         true     computed    error  scud error\n' );
fprintf ( '\n' );

for h = [ 0, 1, 8, 24, 48, 72, 96 ]
  t = h * 60 * 60 * 10;  % T is the number of ticks counted in H hours;
  r = t / 10.0;          % R is real time (just divide T by 10)
  s = t * one_tenth;     % S is computed time (Multiply T by "1/10")
  ds = r - s;            % DS is the error in time!
  dx = v * ds;           % DX is the error in the estimated missile position
  fprintf ( '    %3d  %7d  %11.4f  %11.4f  %7.4f  %10.1f\n', h, t, r, s, ds, dx );
end

