The Special Functions library currently provides five templated special functions, in namespace boost. Two of these (sinc_pi
and sinhc_pi
) are needed by our implementation of quaternions and octonions.
The functions acosh
, asinh
and atanh
are entirely classical, the function sinc_pi
sees heavy use in signal processing tasks, and the function sinhc_pi
is an ad'hoc function whose naming is modelled on sinc_pi
and hyperbolic functions.
The exponential funtion is defined, for all object for which this makes sense, as the power series , with
(and
by definition) being the factorial of
. In particular, the exponential function is well defined for real numbers, complex number, quaternions, octonions, and matrices of complex numbers, among others.
Graph of exp on R
Real and Imaginary parts of exp on C
The hyperbolic functions are defined as power series which can be computed (for reals, complex, quaternions and octonions) as:
Hyperbolic cosine:
Hyperbolic sine:
Hyperbolic tangent:
Trigonometric functions on R (cos: purple; sin: red; tan: blue)
Hyperbolic functions on r (cosh: purple; sinh: red; tanh: blue)
The hyperbolic sine is one to one on the set of real numbers, with range the full set of reals, while the hyperbolic tangent is also one to one on the set of real numbers but with range , and therefore both have inverses. The hyperbolic cosine is one to one from
onto
(and from
onto
); the inverse function we use here is defined on
with range
.
The inverse of the hyperbolic tangent is called the Argument hyperbolic tangent, and can be computed as .
The inverse of the hyperbolic sine is called the Argument hyperbolic sine, and can be computed (for ) as
.
The inverse of the hyperbolic cosine is called the Argument hyperbolic cosine, and can be computed as .
The sine Cardinal family of functions is defined by the family of indices by
.
We define, by analogy, the Hyperbolic sine Cardinal family of functions is defined by the family of indices by
. It, too, is an entire function.
Sinus Cardinal of index pi (purple) and Hyperbolic Sinus Cardinal of index pi (red) on R
The mathematical text has been typeset with Nisus Writer, and the illustrations have been made with Graphing Calculator. Jens Maurer was the Review Manager for this library. More acknowledgements in the History section. Thank you to all who contributed to the discution about this library.
The interface and implementation for each function (or forms of a function) are both supplied by one header file:
The special_functions_test.cpp test program tests the functions for float, double and long double arguments (sample output).
It has been compiled and runs without error with the following C++ compilers:
- MetroWerk's CodeWarrior Pro 6 on a Mac on a PowerPC G3
namespace boost
{
namespace math
{
template<typename T> inline T acosh(const T x);
template<typename T> inline T asinh(const T x);
template<typename T> inline T atanh(const T x);
template<typename T> inline T sinc_pi(const T x);
template<typename T, template<typename> class U> inline U<T> sinc_pi(const U<T> x);
template<typename T> inline T sinhc_pi(const T x);
template<typename T, template<typename> class U> inline U<T> sinhc_pi(const U<T> x);
}
}
The functions implemented here can throw standard exceptions, but no exception specification has been made.
template<typename T> inline T acosh(const T x);
Computes the reciprocal of (the restriction to the range
of) the hyperbolic cosine function, at
x
. Values returned are positive. Generalised Taylor series are used near 1 and Laurent series are used near the infinity to ensure accuracy.If
x
is in the rangea quiet NaN is returned (if the system allows, otherwise a
domain_error
exception is generated).
template<typename T> inline T asinh(const T x);
Computes the reciprocal of the hyperbolic sine function. Taylor series are used at the origin and Laurent series are used near the infinity to ensure accuracy.
template<typename T> inline T atanh(const T x);
Computes the reciprocal of the hyperbolic tangent function, at
x
. Taylor series are used at the origin to ensure accuracy.If
x
is in the rangeor in the range
a quiet NaN is returned (if the system allows, otherwise a
domain_error
exception is generated).If
x
is in the range, minus infinity is returned (if the system allows, otherwise an
out_of_range
exception is generated), withdenoting
numeric_limits<T>::epsilon()
.If
x
is in the range, plus infinity is returned (if the system allows, otherwise an
out_of_range
exception is generated), withdenoting
numeric_limits<T>::epsilon()
.
template<typename T> inline T sinc_pi(const T x);
template<typename T, template<typename> class U> inline U<T> sinc_pi(const U<T> x);
Computes the Sinus Cardinal of
x
. The second form is for complexes, quaternions, octonions... Taylor series are used at the origin to ensure accuracy.
template<typename T> inline T sinhc_pi(const T x);
template<typename T, template<typename> class U> inline U<T> sinhc_pi(const U<T> x);
Computes the Hyperbolic Sinus Cardinal of
x
. The second form is for complexes, quaternions, octonions... Taylor series are used at the origin to ensure accuracy.
acosh
and asinh
, which were submited by Eric Ford; applied changes for Gcc 2.9.x suggested by John Maddock; improved accuracy; sanity check for test file, related to accuracy.
namespace math
.
special_functions.hpp
into atanh.hpp
, sinc.hpp
and sinhc.hpp
; improved efficiency of atanh
with compile-time technique (Daryle Walker); improved accuracy of all functions near zero (Peter Schmitteckert).
Revised 27 September 2001
© Copyright Hubert Holin 2001. Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This software is provided "as is" without express or implied warranty, and with no claim as to its suitability for any purpose.