C++ knows several familiar mathematical functions by name:
sqrt exp log log10 ceil floor fabs(fabs is the absolute value for a floating-point argument.) ePiX provides trig functions and their inverses that are sensitive to angular mode:
Cos | Sin | Tan |
Sec | Csc | Cot |
Acos | Asin | Atan |
The function pow(x,y) returns when
, and
atan2(y,x) (N.B. argument order) returns
, the principle branch of arg.
C++ knows many constants to 20 decimal places, such as M_PI,
M_PI_2, and M_E for
,
, and
respectively. ePiX defines a few additional functions:
recip sgn zero sinx cb id proj1 proj2
The GNU C++ library defines other functions, including inverse
hyperbolic functions (acosh, etc.), log and exp
with base 2, 10, or arbitrary (log2, etc.), the error and
gamma functions (erf and tgamma [sic], respectively),
and Bessel functions of first and second kind: j0, j1,
y0, etc. Use, e.g., jn(5, ) to get higher indices.
The GNU C library reference manual [2] describes these and other
functions in detail.
Functions may be used in subsequent definitions, and functions of two (or more) variables are defined in direct analogy to functions of one variable:
double f(double t) { return t*t*log(t*t); } // t^2 \ln(t^2) double g(double s, double t) { return exp(2*s)*Sin(t); }