summaryrefslogtreecommitdiff
path: root/man/2/math-elem
blob: fb3e2e2d87ed4a87a2b8fd0ff17498a5247512b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
.TH MATH-ELEM 2
.SH NAME
Math: cbrt, sqrt, pow, pow10, hypot, exp, expm1, log, log10, log1p, cos, cosh, sin, sinh, tan, tanh, acos, asin, acosh, asinh, atan, atanh, atan2, lgamma, erf, erfc, j0, j1, y0, y1, jn, yn \- elementary functions of applied mathematics
.SH SYNOPSIS
.EX
include "math.m";
math := load Math Math->PATH;

cbrt, sqrt: fn(x: real): real;
pow: fn(x, y: real): real;
pow10: fn(p: int): real;
hypot: fn(x, y: real): real;
exp, expm1, log, log10, log1p: fn(x: real): real;

cos, cosh, sin, sinh, tan, tanh: fn(x: real): real;
acos, asin, acosh, asinh, atan, atanh: fn(x: real): real;
atan2: fn(y, x: real) of real;

lgamma: fn(x: real): (int,real);
erf, erfc: fn(x: real): real;
j0, j1, y0, y1: fn(x: real): real;
jn, yn: fn(n: int, x: real): real;

.EE
.SH DESCRIPTION
These routines implement the basic elementary functions of applied mathematics.
.PP
.BI Sqrt( x )
computes the square root of
.IR x ,
.BI cbrt( x )
the cube root.
.BI Pow( x , y )
computes
.I x
raised to the exponent
.IR y ;
.B pow10
raises 10 to the integer power
.IR n .
.BI Hypot( x , y )
computes
\f5sqrt(\f2x\f5*\f2x\f5+\f2y\f5*\f2y\f5)\f1.
.PP
.BI Exp( x )
returns the exponential function of
.IR x ,
and
.BI expm1( x )
is
.BI exp( x )-1.
.PP
.BI Log( x )
returns the natural logarithm of
.IR x ,
while
.BI log10( x )
returns the logarithm base 10 and
.BI log1p( x )
returns the logarithm of
.BI 1+ x\f1.
.PP
The trigonometric functions use radians.
The ranges of the inverse functions are:
.BI acos
in [0,\(*p];
.B asin
in [-\(*p/2,\(*p/2];
.B atan
in [-\(*p/2,\(*p/2];
and
.BI atan2( y , x )
.B =
.BI arctan( y / x )
in [-\(*p,\(*p];
.PP
The gamma function is implemented by
.BI lgamma( x )\f1;
the tuple it returns, say
.BI ( s , lg )\f1,
encodes the gamma function by
.RI \(*G( x )
=
.IB s *exp( lg )\f1.
.PP
The hyperbolic trigonometric functions
.B sinh
etc. behave as expected.
.B Erf
is the error function and
.BI erfc( x )
is
.BI 1-erf( x )\f1.
.PP
The Bessel functions are computed by
.BI j0 ,
.BI j1 ,
.BI jn ,
.BI y0 ,
.BI y1 ,
and
.BR yn .
.SH SOURCE
.B /libinterp/math.c
.SH SEE ALSO
.IR math-intro (2)