...one of the most highly
regarded and expertly designed C++ library projects in the
world.

— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards

template <class T1, class T2> std::complex<calculated-result-type> cyl_hankel_1(T1 v, T2 x); template <class T1, class T2, class Policy> std::complex<calculated-result-type> cyl_hankel_1(T1 v, T2 x, const Policy&); template <class T1, class T2> std::complex<calculated-result-type> cyl_hankel_2(T1 v, T2 x); template <class T1, class T2, class Policy> std::complex<calculated-result-type> cyl_hankel_2(T1 v, T2 x, const Policy&);

The functions cyl_hankel_1 and cyl_hankel_2 return the result of the Hankel functions of the first and second kind respectively:

cyl_hankel_1(v, x) = H_{v}^{(1)}(x) = J_{v}(x) + i Y_{v}(x)

cyl_hankel_2(v, x) = H_{v}^{(2)}(x) = J_{v}(x) - i Y_{v}(x)

where:

*J _{v}(x)* is the Bessel function of the first kind, and

The return type of these functions is computed using the *result
type calculation rules* when T1 and T2 are different types.
The functions are also optimised for the relatively common case that T1 is
an integer.

The final Policy argument is optional and can be used to control the behaviour of the function: how it handles errors, what level of precision to use etc. Refer to the policy documentation for more details.

Note that while the arguments to these functions are real values, the results
are complex. That means that the functions can only be instantiated on types
`float`

, `double`

and `long double`

.
The functions have also been extended to operate over the whole range of
*v* and *x* (unlike cyl_bessel_j
and cyl_neumann).

These functions are generally more efficient than two separate calls to the underlying Bessel functions as internally Bessel J and Y can be computed simultaneously.

There are just a few spot tests to exercise all the special case handling - the bulk of the testing is done on the Bessel functions upon which these are based.

Refer to cyl_bessel_j and cyl_neumann.

For *x < 0* the following reflection formulae are used:

Otherwise the implementation is trivially in terms of the Bessel J and Y functions.

Note however, that the Hankel functions compute the Bessel J and Y functions
simultaneously, and therefore a single Hankel function call is more efficient
than two Bessel function calls. The one exception is when *v*
is a small positive integer, in which case the usual Bessel function routines
for integer order are used.