home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / CNC11TP.ZIP / DELHANG.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1988-11-04  |  1.3 KB  |  42 lines

  1. { Copyright (C) 1988 Adam Fritz, 133 Main St., Afton, N.Y. 13730 }
  2.  
  3. program DeltaHyperbolicAngle (output) ;
  4.  
  5.      { DelHAng - Compute exact and approximate number of   }
  6.      {    iterations required to drive hyperbolic cosine   }
  7.      {    coordinate to display limit.                     }
  8.  
  9.    function cosh ( x : single ) : single ;
  10.    begin
  11.       cosh := (exp(x) + exp(-x))/2.0
  12.    end ;
  13.  
  14. var
  15.      isr,r          : integer ; { shift parameter and radius }
  16.      dx,coshdx,sinhdx : single ;  { step angle and functions }
  17.      coshx,sinhx    : single ;  { coordinate angle functions }
  18.      ndx,ndxe       : integer ; { number of coordinate rotations }
  19.  
  20. begin
  21.    for isr := 0 to 10 do begin
  22.       r := 1 shl isr ;
  23.       dx := 2.0*sqrt(1.0/r) ;
  24.       coshdx := cosh(dx) ;
  25.       sinhdx := sqrt(sqr(coshdx) - 1.0) ;
  26.       coshx := 1.0 ;
  27.       sinhx := 0.0 ;
  28.       ndx := 0 ;
  29.                                 { compute ndx }
  30.       while r * coshx <= 16384 do begin
  31.          coshx := coshx * coshdx + sinhx * sinhdx ;
  32.          sinhx := sqrt(sqr(coshx) - 1.0) ;
  33.          Inc(ndx)
  34.       end ;
  35.                                 { estimate ndx }
  36.       ndxe := Trunc(ln(32768/r)/ln(coshdx+dx)) ;
  37.       writeln (output,' ',r:5,' ',dx:10:5,' ',ndx:4,' ',ndxe:4)
  38.    end
  39. end.
  40.  
  41. { Copyright (C) 1988 Adam Fritz, 133 Main St., Afton, N.Y. 13730 }
  42.