Go to the first, previous, next, last section, table of contents.
This chapter describes basic mathematical functions. Some of these
functions are present in system libraries, but the alternative versions
in the library can be used as a substitute when the system functions are
not available.
The functions and macros are defined in the header file `gsl_math.h'.
The library ensures that the standard BSD mathematical constants
are defined. For reference here is a list of the constants.
M_E
-
The base of exponentials, e
M_LOG2E
-
The base-2 logarithm of e, \log_2 (e)
M_LOG10E
-
The base-10 logarithm of e,
\log_10 (e)
M_SQRT2
-
The square root of two, \sqrt 2
M_SQRT1_2
-
The square root of one-half,
\sqrt{1/2}
M_SQRT3
-
The square root of three, \sqrt 3
M_PI
-
The constant pi, \pi
M_PI_2
-
pi divided by two, \pi/2
M_PI_4
-
pi divided by four, \pi/4
M_SQRTPI
-
The square root of pi, \sqrt\pi
M_2_SQRTPI
-
Two divided by the square root of pi, 2/\sqrt\pi
M_1_PI
-
The reciprocal of pi, 1/\pi
M_2_PI
-
Twice the reciprocal of pi, 2/\pi
M_LN10
-
The natural logarithm of ten, \ln(10)
M_LN2
-
The natural logarith of two, \ln(2)
M_LNPI
-
The natural logarithm of pi, \ln(\pi)
M_EULER
-
Euler's constant, \gamma
- Macro: GSL_POSINF
-
This macro contains the IEEE representation of positive infinity,
+\infty. It is computed from the expression
+1.0/0.0
- Macro: GSL_NEGINF
-
This macro contains the IEEE representation of negative infinity,
-\infty. It is computed from the expression
-1.0/0.0
- Macro: GSL_NAN
-
This macro contains the IEEE representation of the Not-a-Number symbol,
NaN
. It is computed from the ratio 0.0/0.0
.
The following routines provide portable implementations of functions
found in the BSD math library. When native versions are not available
the functions described here can be used instead. The substitution can
be made automatically if you use autoconf
to compile your
application see section Portability functions.
- Function: double gsl_log1p (const double x)
-
This function computes the value of \log(1+x) in a way that is
accurate for small x. It provides an alternative to the BSD math
function
log1p(x)
.
- Function: double gsl_expm1 (const double x)
-
This function computes the value of \exp(x)-1 in a way that is
accurate for small x. It provides an alternative to the BSD math
function
expm1(x)
.
- Function: double gsl_hypot (const double x, const double y)
-
This function computes the value of
\sqrt{x^2 + y^2} in a way that avoids overflow. It provides an
alternative to the BSD math function
hypot(x,y)
.
- Function: double gsl_acosh (const double x)
-
This function computes the value of \arccosh(x). It provides an
alternative to the standard math function
acosh(x)
.
- Function: double gsl_asinh (const double x)
-
This function computes the value of \arcsinh(x). It provides an
alternative to the standard math function
asinh(x)
.
- Function: double gsl_atanh (const double x)
-
This function computes the value of \arctanh(x). It provides an
alternative to the standard math function
atanh(x)
.
- Macro: GSL_SIGN (x)
-
This macro returns the sign of x. It is defined as
((x) >= 0
? 1 : -1)
. Note that with this definition the sign of zero is positive
(regardless of its IEEE sign bit).
- Macro: GSL_IS_ODD (n)
-
This macro evaluates to 1 if n is odd and 0 if n is
even. The argument n must be of integer type.
- Macro: GSL_IS_EVEN (n)
-
This macro is the opposite of
GSL_IS_ODD(n)
. It evaluates to 1 if
n is even and 0 if n is odd. The argument n must be of
integer type.
- Macro: GSL_MAX (a, b)
-
This macro returns the maximum of a and b. It is defined as
((a) > (b) ? (a):(b))
.
- Macro: GSL_MIN (a, b)
-
This macro returns the minimum of a and b. It is defined as
((a) < (b) ? (a):(b))
.
- Function: extern inline double GSL_MAX_DBL (double a, double b)
-
This function returns the maximum of the double precision numbers
a and b using an inline function. The use of a function
allows for type checking of the arguments as an extra safety feature. On
platforms where inline functions are not available the macro
GSL_MAX
will be automatically substituted.
- Function: extern inline double GSL_MIN_DBL (double a, double b)
-
This function returns the minimum of the double precision numbers
a and b using an inline function. The use of a function
allows for type checking of the arguments as an extra safety feature. On
platforms where inline functions are not available the macro
GSL_MIN
will be automatically substituted.
- Function: extern inline int GSL_MAX_INT (int a, int b)
-
- Function: extern inline int GSL_MIN_INT (int a, int b)
-
These functions return the maximum or minimum of the integers a
and b using an inline function. On platforms where inline
functions are not available the macros
GSL_MAX
or GSL_MIN
will be automatically substituted.
- Function: extern inline long double GSL_MAX_LDBL (long double a, long double b)
-
- Function: extern inline long double GSL_MIN_LDBL (long double a, long double b)
-
These functions return the maximum or minimum of the long doubles a
and b using an inline function. On platforms where inline
functions are not available the macros
GSL_MAX
or GSL_MIN
will be automatically substituted.
Go to the first, previous, next, last section, table of contents.