## Stata 15 help for mf_sin

```
[M-5] sin() -- Trigonometric and hyperbolic functions

Syntax

numeric matrix sin(numeric matrix Z)

numeric matrix cos(numeric matrix Z)

numeric matrix tan(numeric matrix Z)

numeric matrix asin(numeric matrix Z)

numeric matrix acos(numeric matrix Z)

numeric matrix atan(numeric matrix Z)

real matrix    atan2(real matrix X, real matrix Y)

real matrix    arg(complex matrix Z)

numeric matrix sinh(numeric matrix Z)

numeric matrix cosh(numeric matrix Z)

numeric matrix tanh(numeric matrix Z)

numeric matrix asinh(numeric matrix Z)

numeric matrix acosh(numeric matrix Z)

numeric matrix atanh(numeric matrix Z)

real scalar    pi()

Description

sin(Z), cos(Z), and tan(Z) return the appropriate trigonometric
functions.  Angles are measured in radians.  All return real if the
argument is real and complex if the argument is complex.

sin(x), x real, returns the sine of x.  sin() returns a value between
-1 and 1.

sin(z), z complex, returns the complex sine of z, mathematically
defined as {exp(i*z)-exp(-i*z)}/2i.

cos(x), x real, returns the cosine of x.  cos() returns a value
between -1 and 1.

cos(z), z complex, returns the complex cosine of z, mathematically
defined as {exp(i*z)+exp(-i*z)}/2.

tan(x), x real, returns the tangent of x.

tan(z), z complex, returns the complex tangent of z, mathematically
defined as sin(z)/cos(z).

asin(Z), acos(Z), and atan(Z) return the appropriate inverse
trigonometric functions.  Returned results are in radians.  All return
real if the argument is real and complex if the argument is complex.

asin(x), x real, returns arcsine in the range [-pi/2,pi/2].  If x <
-1 or x > 1, missing (.) is returned.

asin(z), z complex, returns the complex arcsine, mathematically
defined as -i*ln{i*z + sqrt(1-z*z)}.  Re(asin()) is chosen to be in
the interval [-pi/2,pi/2].

acos(x), x real, returns arccosine in the range [0,pi].  If x < -1 or
x > 1, missing (.) is returned.

acos(z), z complex, returns the complex arccosine, mathematically
defined as -i*ln{z + sqrt(z*z-1)}.  Re(acos()) is chosen to be in the
interval [0,pi].

atan(x), x real, returns arctangent in the range (-pi/2,pi/2).

atan(z), z complex, returns the complex arctangent, mathematically
defined as ln{(1+iz)/(1-iz)}/(2i).  Re(atan()) is chosen to be in the
interval [0,pi].

atan2(X, Y) returns the radian value in the range (-pi,pi] of the angle
of the vector determined by (X,Y), the result being in the range [0,pi]
for quadrants 1 and 2 and [0,-pi) for quadrants 4 and 3.  X and Y must be
real.  atan2(X, Y) is equivalent to arg(C(X, Y)).

arg(Z) returns the arctangent of Im(Z)/Re(Z) in the correct quadrant, the
result being in the range (-pi,pi]; [0,pi] in quadrants 1 and 2 and
[0,-pi) in quadrants 4 and 3.  arg(Z) is equivalent to atan2(Re(Z),
Im(Z)).

sinh(Z), cosh(Z), and tanh(Z) return the hyperbolic sine, cosine, and
tangent, respectively.  The returned value is real if the argument is
real and complex if the argument is complex.

sinh(x), x real, returns the inverse hyperbolic sine of x,
mathematically defined as {exp(x)-exp(-x)}/2.

sinh(z), z complex, returns the complex hyperbolic sine of z,
mathematically defined as {exp(z)-exp(-z)}/2.

cosh(x), x real, returns the inverse hyperbolic cosine of x,
mathematically defined as {exp(x)+exp(-x)}/2.

cosh(z), z complex, returns the complex hyperbolic cosine of z,
mathematically defined as {exp(z)+exp(-z)}/2.

tanh(x), x real, returns the inverse hyperbolic tangent of x,
mathematically defined as sinh(x)/cosh(x).

tanh(z), z complex, returns the complex hyperbolic tangent of z,
mathematically defined as sinh(z)/cosh(z).

asinh(Z), acosh(Z), and atanh(Z) return the inverse hyperbolic sine,
cosine, and tangent, respectively.  The returned value is real if the
argument is real and complex if the argument is complex.

asinh(x), x real, returns the inverse hyperbolic sine.

asinh(z), z complex, returns the complex inverse hyperbolic sine,
mathematically defined as ln{z+sqrt(z*z+1)}.  Im(asinh()) is chosen
to be in the interval [-pi/2,pi/2].

acosh(x), x real, returns the inverse hyperbolic cosine.  If x < 1,
missing (.) is returned.

acosh(z), z complex, returns the complex inverse hyperbolic cosine,
mathematically defined as ln{z + sqrt(z*z-1)}.  Im(acosh()) is chosen
to be in the interval [-pi,pi]; Re(acosh()) is chosen to be
nonnegative.

atanh(x), x real, returns the inverse hyperbolic tangent.  If |x|>1,
missing (.) is returned.

atanh(z), z complex, returns the complex inverse hyperbolic tangent,
mathematically defined as ln{(1+z)/(1-z)}/2.  Im(atanh()) is chosen
to be in the interval [-pi/2,pi/2].

pi() returns the value of pi.

Conformability

atan2(X, Y):
X:  r1 x c1
Y:  r2 x c2, X and Y r-conformable
result:  max(r1,r2) x max(c1,c2)

pi() returns a 1 x 1 scalar.

All other functions return a matrix of the same dimension as input
containing element-by-element calculated results.

Diagnostics

All functions return missing for real arguments when the result would be
complex.  For instance, acos(2) = ., whereas acos(2+0i) = -1.317i.

Source code

asin.mata, acos.mata, atan.mata, tanh.mata, asinh.mata, acosh.mata,
atanh.mata, pi.mata; other functions are built in.

```