home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
cpm
/
turbom2
/
m2trig-2.lbr
/
LONGTRIG.MZD
/
LONGTRIG.MOD
Wrap
Text File
|
1987-08-23
|
3KB
|
151 lines
IMPLEMENTATION MODULE LongTrig;
(* Jim Lill 16 Aug 87 *)
FROM LongMath IMPORT Arctan, ArgumentError, Cos, Sin, Sqrt, Exp, Ln;
CONST D0 = 0.0D0;
VAR
A, Kdr, Result : LONGREAL;
PROCEDURE Rad(x:LONGREAL): LONGREAL;
BEGIN
Result := x * Kdr;
RETURN Result;
END Rad;
PROCEDURE Deg(x:LONGREAL): LONGREAL;
BEGIN
Result := x/Kdr;
RETURN Result;
END Deg;
PROCEDURE Tan(x:LONGREAL): LONGREAL;
BEGIN
A := Cos(x);
IF A=D0 THEN
Result := MAX(LONGREAL)
ELSE
Result := Sin(x)/A
END;
RETURN Result;
END Tan;
PROCEDURE Cotan(x:LONGREAL): LONGREAL;
BEGIN
A := Sin(x);
IF A = D0 THEN
Result := MAX(LONGREAL)
ELSE
Result := Cos(x)/A
END;
RETURN Result;
END Cotan;
PROCEDURE Arcsin(x:LONGREAL): LONGREAL;
BEGIN
IF x=D0 THEN
Result:=D0
ELSIF x=1.0D0 THEN
Result:=PI / 2.0D0
ELSIF x=-1.0D0 THEN
Result:=-PI / 2.0D0
ELSIF ABS(x) > 1.0D0 THEN
RAISE ArgumentError
ELSE
Result := Arctan(x/Sqrt(-x*x+1.0D0))
END;
RETURN Result;
END Arcsin;
PROCEDURE Arccos(x:LONGREAL): LONGREAL;
BEGIN
IF x=D0 THEN
Result:=PI / 2.0D0
ELSIF x=1.0D0 THEN
Result:=D0
ELSIF x=-1.0D0 THEN
Result:=PI
ELSIF ABS(x) > 1.0D0 THEN
RAISE ArgumentError
ELSE
Result := -Arctan(x/Sqrt(-x*x+1.0D0))+PI / 2.0D0
END;
RETURN Result;
END Arccos;
PROCEDURE Arctan2(x,y:LONGREAL):LONGREAL;
BEGIN
IF x=D0 THEN
IF
y=D0 THEN
Result:=D0
ELSE
IF y>D0 THEN
Result:=PI / 2.0D0
ELSE
Result:= 3.0D0 * PI / 2.0D0
END
END
ELSIF y=D0 THEN
IF x>D0 THEN
Result:=D0
ELSE
Result:=PI
END
ELSE
A:=Arctan(y/x);
IF x>D0 THEN
Result:=A
ELSE
Result:=A + PI
END
END;
RETURN Result;
END Arctan2;
PROCEDURE Cosh(x:LONGREAL):LONGREAL;
BEGIN
Result:= (Exp(x) + Exp(-x))/2.0D0;
RETURN Result;
END Cosh;
PROCEDURE Sinh(x:LONGREAL):LONGREAL;
BEGIN
Result:= (Exp(x) - Exp(-x))/2.0D0;
RETURN Result;
END Sinh;
PROCEDURE Tanh(x:LONGREAL):LONGREAL;
BEGIN
Result:= (Exp(x) - Exp(-x))/(Exp(x) + Exp(-x));
RETURN Result;
END Tanh;
PROCEDURE Log(x:LONGREAL):LONGREAL;
BEGIN
IF x < D0 THEN RAISE ArgumentError
ELSE
Result:= Ln(x)/Ln(1.0D0);
RETURN Result;
END;
END Log;
BEGIN (* Initialization Code *)
PI:= 4.0D0 * Arctan(1.0D0);
Kdr:= PI / 18.0D1;
END LongTrig.