118 lines
2.8 KiB
Modula-2
118 lines
2.8 KiB
Modula-2
DEFINITION MODULE Mathlib;
|
|
(*
|
|
Module: Mathematical functions
|
|
Author: Ceriel J.H. Jacobs
|
|
Version: $Id$
|
|
*)
|
|
|
|
(* Some mathematical constants: *)
|
|
|
|
CONST
|
|
(* From: Computer Approximations
|
|
Hart, Cheney, e.a.
|
|
The SIAM Series in Applied Mathematics
|
|
John Wiley & Sons, INC. New York London Sydney, 1968
|
|
*)
|
|
|
|
pi = 3.14159265358979323846264338327950288;
|
|
twicepi = 6.28318530717958647692528676655900576;
|
|
halfpi = 1.57079632679489661923132169163975144;
|
|
quartpi = 0.78539816339744830961566084581987572;
|
|
e = 2.71828182845904523536028747135266250;
|
|
ln2 = 0.69314718055994530941723212145817657;
|
|
ln10 = 2.30258509299404568401799145468436421;
|
|
|
|
longpi = 3.14159265358979323846264338327950288D;
|
|
longtwicepi = 6.28318530717958647692528676655900576D;
|
|
longhalfpi = 1.57079632679489661923132169163975144D;
|
|
longquartpi = 0.78539816339744830961566084581987572D;
|
|
longe = 2.71828182845904523536028747135266250D;
|
|
longln2 = 0.69314718055994530941723212145817657D;
|
|
longln10 = 2.30258509299404568401799145468436421D;
|
|
|
|
(* basic functions *)
|
|
|
|
PROCEDURE pow(x: REAL; i: INTEGER): REAL;
|
|
|
|
PROCEDURE longpow(x: LONGREAL; i: INTEGER): LONGREAL;
|
|
|
|
PROCEDURE sqrt(x: REAL): REAL;
|
|
|
|
PROCEDURE longsqrt(x: LONGREAL): LONGREAL;
|
|
|
|
PROCEDURE exp(x: REAL): REAL;
|
|
|
|
PROCEDURE longexp(x: LONGREAL): LONGREAL;
|
|
|
|
PROCEDURE ln(x: REAL): REAL; (* natural log *)
|
|
|
|
PROCEDURE longln(x: LONGREAL): LONGREAL; (* natural log *)
|
|
|
|
PROCEDURE log(x: REAL): REAL; (* log with base 10 *)
|
|
|
|
PROCEDURE longlog(x: LONGREAL): LONGREAL; (* log with base 10 *)
|
|
|
|
(* trigonometric functions; arguments in radians *)
|
|
|
|
PROCEDURE sin(x: REAL): REAL;
|
|
|
|
PROCEDURE longsin(x: LONGREAL): LONGREAL;
|
|
|
|
PROCEDURE cos(x: REAL): REAL;
|
|
|
|
PROCEDURE longcos(x: LONGREAL): LONGREAL;
|
|
|
|
PROCEDURE tan(x: REAL): REAL;
|
|
|
|
PROCEDURE longtan(x: LONGREAL): LONGREAL;
|
|
|
|
PROCEDURE arcsin(x: REAL): REAL;
|
|
|
|
PROCEDURE longarcsin(x: LONGREAL): LONGREAL;
|
|
|
|
PROCEDURE arccos(x: REAL): REAL;
|
|
|
|
PROCEDURE longarccos(x: LONGREAL): LONGREAL;
|
|
|
|
PROCEDURE arctan(x: REAL): REAL;
|
|
|
|
PROCEDURE longarctan(x: LONGREAL): LONGREAL;
|
|
|
|
(* hyperbolic functions *)
|
|
|
|
PROCEDURE sinh(x: REAL): REAL;
|
|
|
|
PROCEDURE longsinh(x: LONGREAL): LONGREAL;
|
|
|
|
PROCEDURE cosh(x: REAL): REAL;
|
|
|
|
PROCEDURE longcosh(x: LONGREAL): LONGREAL;
|
|
|
|
PROCEDURE tanh(x: REAL): REAL;
|
|
|
|
PROCEDURE longtanh(x: LONGREAL): LONGREAL;
|
|
|
|
PROCEDURE arcsinh(x: REAL): REAL;
|
|
|
|
PROCEDURE longarcsinh(x: LONGREAL): LONGREAL;
|
|
|
|
PROCEDURE arccosh(x: REAL): REAL;
|
|
|
|
PROCEDURE longarccosh(x: LONGREAL): LONGREAL;
|
|
|
|
PROCEDURE arctanh(x: REAL): REAL;
|
|
|
|
PROCEDURE longarctanh(x: LONGREAL): LONGREAL;
|
|
|
|
(* conversions *)
|
|
|
|
PROCEDURE RadianToDegree(x: REAL): REAL;
|
|
|
|
PROCEDURE longRadianToDegree(x: LONGREAL): LONGREAL;
|
|
|
|
PROCEDURE DegreeToRadian(x: REAL): REAL;
|
|
|
|
PROCEDURE longDegreeToRadian(x: LONGREAL): LONGREAL;
|
|
|
|
END Mathlib.
|