DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Rational R1000/400

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦b0779af2e⟧ Ada Source

    Length: 3072 (0xc00)
    Types: Ada Source
    Notes: 03_class, FILE, R1k_Segment, e3_tag, function Coth, seg_0130c6, separate Generic_Elementary_Functions

Derivation

└─⟦8527c1e9b⟧ Bits:30000544 8mm tape, Rational 1000, Arrival backup of disks in PAM's R1000
    └─ ⟦5a81ac88f⟧ »Space Info Vol 1« 
        └─⟦this⟧ 

E3 Source Code



separate (Generic_Elementary_Functions)

function Coth (X : Float_Type) return Float_Type is

-- On input, X is a floating-point value in Float_Type;
-- On output, the value of coth(X) (the hyperbolic cotangent of X) is returned.

-- The definition of coth(Y) is 1/tanh(Y) = cosh(Y)/sinh(Y), which is also
-- equivalent to the following three formulas.
--      1.  ( exp(Y) + exp(-Y) ) / ( exp(Y) - exp(-Y) )
--      2.  ( 1 + ( 2 / ( exp(2*Y) - 1 ) ) )
--      3.  ( exp(2*Y) + 1 ) / ( exp(2*Y) - 1 ).
-- but computationally, some formulas are better on some ranges.

   Z, Sign_Y : Common_Float;

   Y, Abs_Y : Common_Float;

   Log2 : constant Common_Float := 16#0.B17217F7D1CF79ABC9E3B39803F2F6AF40#;

   Base_Digits : constant Common_Float :=
      Common_Float (6 * Float_Type'Base'Digits);

   Log2_Times_2 : constant Common_Float := (2.0 * Log2);

   Cond : constant Common_Float := (Base_Digits * Log2);


begin

-- Filter out exceptional cases.

   Y := Common_Float (X);

   if (Y = 0.0) then
      raise Constraint_Error;
   end if;

   Abs_Y := abs (Y);

-- Calculate the coth(X).

   if (Y >= 0.0) then
      Sign_Y := 1.0;
   else
      Sign_Y := -1.0;
   end if;


   if (Abs_Y <= (Log2_Times_2)) then
--    Formula 3 should be used in this situation to guarantee accuracy.

      Z := Kf_Em1 (2.0 * Abs_Y);
      Z := Sign_Y * ((Z + 2.0) / Z);
      return (Float_Type (Z));

   elsif (Abs_Y > Cond) then
--    Formula 2 should be used in this situation to guarantee accuracy,
--    but observe that 2/(exp(2*Y) - 1) will be so small compared to 1
--    that it is negligible.

      return (Float_Type (Sign_Y));

   else
--   When ( Log2_Times_2 < Abs_Y <= Cond ), use formula 2 for best accuracy.

      Z := Kf_Em1 (2.0 * Abs_Y);
      Z := Sign_Y * (1.0 + 2.0 / Z);
      return (Float_Type (Z));

   end if;


end Coth;


E3 Meta Data

    nblk1=2
    nid=0
    hdr6=4
        [0x00] rec0=20 rec1=00 rec2=01 rec3=040
        [0x01] rec0=2e rec1=00 rec2=02 rec3=000
    tail 0x2150db51e82b1517816ca 0x42a00066462061e03