home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / spezial / 02 / t7.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1986-02-05  |  366 b   |  19 lines

  1. program t7;
  2. const eps=1e-14;
  3. var x,sx,s,t:real;
  4.     i,k,n:integer;
  5. begin
  6.   writeln('compute cosinus');
  7.   write  ('n:=');read(n);
  8.   for i:=1 to n do begin
  9.     read(x);
  10.     t:=1; k:=0; s:=1; sx:=sqr(x);
  11.     while abs(t)>eps*abs(s) do begin
  12.       k:=k+2;
  13.       t:=-t*sx/(k*(k-1));
  14.       s:=s+t
  15.     end;
  16.     writeln(x,'  ',s,'  ',k div 2);
  17.   end;
  18. end.
  19.