Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Derivatives of the Bessel Functions

Synopsis

#include <boost/math/special_functions/bessel_prime.hpp>

template <class T1, class T2>
calculated-result-type cyl_bessel_j_prime(T1 v, T2 x);

template <class T1, class T2, class Policy>
calculated-result-type cyl_bessel_j_prime(T1 v, T2 x, const Policy&);

template <class T1, class T2>
calculated-result-type cyl_neumann_prime(T1 v, T2 x);

template <class T1, class T2, class Policy>
calculated-result-type cyl_neumann_prime(T1 v, T2 x, const Policy&);

template <class T1, class T2>
calculated-result-type cyl_bessel_i_prime(T1 v, T2 x);

template <class T1, class T2, class Policy>
calculated-result-type cyl_bessel_i_prime(T1 v, T2 x, const Policy&);

template <class T1, class T2>
calculated-result-type cyl_bessel_k_prime(T1 v, T2 x);

template <class T1, class T2, class Policy>
calculated-result-type cyl_bessel_k_prime(T1 v, T2 x, const Policy&);

template <class T1, class T2>
calculated-result-type sph_bessel_prime(T1 v, T2 x);

template <class T1, class T2, class Policy>
calculated-result-type sph_bessel_prime(T1 v, T2 x, const Policy&);

template <class T1, class T2>
calculated-result-type sph_neumann_prime(T1 v, T2 x);

template <class T1, class T2, class Policy>
calculated-result-type sph_neumann_prime(T1 v, T2 x, const Policy&);
Description

These functions return the first derivative with respect to x of the corresponding Bessel function.

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.

The functions return the result of domain_error whenever the result is undefined or complex.

Testing

There are two sets of test values: spot values calculated using wolframalpha.com, and a much larger set of tests computed using a relation to the underlying Bessel functions that the implementation does not use.

Accuracy

The accuracy of these functions is broadly similar to the underlying Bessel functions.

Table 6.50. Error rates for cyl_bessel_i_prime (integer orders)

GNU C++ version 7.1.0
linux
double

GNU C++ version 7.1.0
linux
long double

Sun compiler version 0x5150
Sun Solaris
long double

Microsoft Visual C++ version 14.1
Win32
double

Bessel I'0: Mathworld Data (Integer Version)

Max = 0ε (Mean = 0ε)

Max = 0.82ε (Mean = 0.259ε)

Max = 0.82ε (Mean = 0.259ε)

Max = 0.82ε (Mean = 0.354ε)

Bessel I'1: Mathworld Data (Integer Version)

Max = 0ε (Mean = 0ε)

Max = 1.97ε (Mean = 0.757ε)

Max = 1.97ε (Mean = 0.757ε)

Max = 1.36ε (Mean = 0.782ε)

Bessel I'n: Mathworld Data (Integer Version)

Max = 0ε (Mean = 0ε)

Max = 2.31ε (Mean = 1.41ε)

Max = 701ε (Mean = 212ε)

Max = 3.61ε (Mean = 1.22ε)


Table 6.51. Error rates for cyl_bessel_i_prime

GNU C++ version 7.1.0
linux
double

GNU C++ version 7.1.0
linux
long double

Sun compiler version 0x5150
Sun Solaris
long double

Microsoft Visual C++ version 14.1
Win32
double

Bessel I'0: Mathworld Data

Max = 0ε (Mean = 0ε)

Max = 0.82ε (Mean = 0.259ε)

Max = 0.82ε (Mean = 0.259ε)

Max = 0.82ε (Mean = 0.354ε)

Bessel I'1: Mathworld Data

Max = 0ε (Mean = 0ε)

Max = 1.97ε (Mean = 0.757ε)

Max = 1.97ε (Mean = 0.757ε)

Max = 1.36ε (Mean = 0.782ε)

Bessel I'n: Mathworld Data

Max = 0ε (Mean = 0ε)

Max = 2.31ε (Mean = 1.41ε)

Max = 701ε (Mean = 212ε)

Max = 3.61ε (Mean = 1.22ε)

Bessel I'v: Mathworld Data

Max = 1.62ε (Mean = 0.512ε)

Max = 2.89e+03ε (Mean = 914ε)

Max = 2.89e+03ε (Mean = 914ε)

Max = 3.76e+03ε (Mean = 1.19e+03ε)

Bessel I'n: Random Data

Max = 0ε (Mean = 0ε)

Max = 3.95ε (Mean = 1.06ε)

Max = 195ε (Mean = 37.1ε)

Max = 9.85ε (Mean = 1.82ε)

Bessel I'v: Random Data

Max = 0ε (Mean = 0ε)

Max = 14.1ε (Mean = 2.93ε)

Max = 336ε (Mean = 68.5ε)

Max = 14ε (Mean = 2.5ε)

Bessel I'v: Mathworld Data (large values)

Max = 0ε (Mean = 0ε)

Max = 42.6ε (Mean = 20.2ε)

Max = 42.6ε (Mean = 20.2ε)

Max = 59.5ε (Mean = 26.6ε)


Table 6.52. Error rates for cyl_bessel_j_prime (integer orders)

GNU C++ version 7.1.0
linux
double

GNU C++ version 7.1.0
linux
long double

Sun compiler version 0x5150
Sun Solaris
long double

Microsoft Visual C++ version 14.1
Win32
double

Bessel J0': Mathworld Data (Integer Version)

Max = 0ε (Mean = 0ε)

Max = 18.9ε (Mean = 6.82ε)

Max = 18.9ε (Mean = 6.72ε)

Max = 6.62ε (Mean = 2.55ε)

Bessel J0': Mathworld Data (Tricky cases) (Integer Version)

Max = 0ε (Mean = 0ε)

Max = 7.44ε (Mean = 3.34ε)

Max = 7.44ε (Mean = 3.31ε)

Max = 3.67ε (Mean = 1.74ε)

Bessel J1': Mathworld Data (Integer Version)

Max = 0ε (Mean = 0ε)

Max = 7.9ε (Mean = 3.37ε)

Max = 7.9ε (Mean = 3.37ε)

Max = 0.999ε (Mean = 0.627ε)

Bessel J1': Mathworld Data (tricky cases) (Integer Version)

Max = 287ε (Mean = 129ε)

Max = 5.88e+05ε (Mean = 2.63e+05ε)

Max = 5.88e+05ε (Mean = 2.63e+05ε)

Max = 288ε (Mean = 129ε)

Bessel JN': Mathworld Data (Integer Version)

Max = 0.527ε (Mean = 0.128ε)

Max = 1.29e+03ε (Mean = 312ε)

Max = 1.29e+03ε (Mean = 355ε)

Max = 14ε (Mean = 6.13ε)


Table 6.53. Error rates for cyl_bessel_j_prime

GNU C++ version 7.1.0
linux
double

GNU C++ version 7.1.0
linux
long double

Sun compiler version 0x5150
Sun Solaris
long double

Microsoft Visual C++ version 14.1
Win32
double

Bessel J0': Mathworld Data

Max = 0ε (Mean = 0ε)

Max = 18.9ε (Mean = 6.82ε)

Max = 18.9ε (Mean = 6.72ε)

Max = 6.62ε (Mean = 2.55ε)

Bessel J0': Mathworld Data (Tricky cases)

Max = 0ε (Mean = 0ε)

Max = 7.44ε (Mean = 3.34ε)

Max = 7.44ε (Mean = 3.31ε)

Max = 3.67ε (Mean = 1.74ε)

Bessel J1': Mathworld Data

Max = 0ε (Mean = 0ε)

Max = 7.9ε (Mean = 3.37ε)

Max = 7.9ε (Mean = 3.37ε)

Max = 0.999ε (Mean = 0.627ε)

Bessel J1': Mathworld Data (tricky cases)

Max = 287ε (Mean = 129ε)

Max = 5.88e+05ε (Mean = 2.63e+05ε)

Max = 5.88e+05ε (Mean = 2.63e+05ε)

Max = 288ε (Mean = 129ε)

Bessel JN': Mathworld Data

Max = 0.527ε (Mean = 0.128ε)

Max = 1.29e+03ε (Mean = 312ε)

Max = 1.29e+03ε (Mean = 355ε)

Max = 14ε (Mean = 6.13ε)

Bessel J': Mathworld Data

Max = 21.5ε (Mean = 4.7ε)

Max = 42.5ε (Mean = 9.31ε)

Max = 42.5ε (Mean = 9.32ε)

Max = 23.7ε (Mean = 8ε)

Bessel J': Mathworld Data (large values)

Max = 0ε (Mean = 0ε)

Max = 989ε (Mean = 495ε)

Max = 989ε (Mean = 495ε)

Max = 2.9ε (Mean = 1.61ε)

Bessel JN': Random Data

Max = 0.593ε (Mean = 0.0396ε)

Max = 11.3ε (Mean = 1.85ε)

Max = 79.4ε (Mean = 16.2ε)

Max = 6.34ε (Mean = 0.999ε)

Bessel J': Random Data

Max = 0.885ε (Mean = 0.033ε)

Max = 139ε (Mean = 6.47ε)

Max = 279ε (Mean = 27.2ε)

Max = 176ε (Mean = 9.75ε)

Bessel J': Random Data (Tricky large values)

Max = 0ε (Mean = 0ε)

Max = 474ε (Mean = 62.2ε)

Max = 474ε (Mean = 64.5ε)

Max = 379ε (Mean = 45.4ε)


Table 6.54. Error rates for cyl_bessel_k_prime (integer orders)

GNU C++ version 7.1.0
linux
double

GNU C++ version 7.1.0
linux
long double

Sun compiler version 0x5150
Sun Solaris
long double

Microsoft Visual C++ version 14.1
Win32
double

Bessel K'0: Mathworld Data (Integer Version)

Max = 0ε (Mean = 0ε)

Max = 0.786ε (Mean = 0.329ε)

Max = 0.786ε (Mean = 0.329ε)

Max = 0.786ε (Mean = 0.39ε)

Bessel K'1: Mathworld Data (Integer Version)

Max = 0ε (Mean = 0ε)

Max = 0.736ε (Mean = 0.389ε)

Max = 0.736ε (Mean = 0.389ε)

Max = 0.761ε (Mean = 0.444ε)

Bessel K'n: Mathworld Data (Integer Version)

Max = 0ε (Mean = 0ε)

Max = 2.16ε (Mean = 1.08ε)

Max = 2.16ε (Mean = 1.08ε)

Max = 4.17ε (Mean = 1.75ε)


Table 6.55. Error rates for cyl_bessel_k_prime

GNU C++ version 7.1.0
linux
double

GNU C++ version 7.1.0
linux
long double

Sun compiler version 0x5150
Sun Solaris
long double

Microsoft Visual C++ version 14.1
Win32
double

Bessel K'0: Mathworld Data

Max = 0ε (Mean = 0ε)

Max = 0.786ε (Mean = 0.329ε)

Max = 0.786ε (Mean = 0.329ε)

Max = 0.786ε (Mean = 0.39ε)

Bessel K'1: Mathworld Data

Max = 0ε (Mean = 0ε)

Max = 0.736ε (Mean = 0.389ε)

Max = 0.736ε (Mean = 0.389ε)

Max = 0.761ε (Mean = 0.444ε)

Bessel K'n: Mathworld Data

Max = 0ε (Mean = 0ε)

Max = 2.16ε (Mean = 1.08ε)

Max = 2.16ε (Mean = 1.08ε)

Max = 4.17ε (Mean = 1.75ε)

Bessel K'v: Mathworld Data

Max = 0ε (Mean = 0ε)

Max = 3.94ε (Mean = 2.44ε)

Max = 3.94ε (Mean = 2.34ε)

Max = 3.94ε (Mean = 1.47ε)

Bessel K'v: Mathworld Data (large values)

Max = 0ε (Mean = 0ε)

Max = 59.2ε (Mean = 42.9ε)

Max = 58.7ε (Mean = 42.6ε)

Max = 18.6ε (Mean = 11.8ε)

Bessel K'n: Random Data

Max = 0ε (Mean = 0ε)

Max = 4.45ε (Mean = 1.19ε)

Max = 4.45ε (Mean = 1.19ε)

Max = 9.67ε (Mean = 1.73ε)

Bessel K'v: Random Data

Max = 0ε (Mean = 0ε)

Max = 7.95ε (Mean = 1.53ε)

Max = 7.95ε (Mean = 1.52ε)

Max = 8.32ε (Mean = 1.65ε)


Table 6.56. Error rates for sph_bessel_prime

GNU C++ version 7.1.0
linux
double

GNU C++ version 7.1.0
linux
long double

Sun compiler version 0x5150
Sun Solaris
long double

Microsoft Visual C++ version 14.1
Win32
double

Bessel j': Random Data

Max = 0.753ε (Mean = 0.0343ε)

Max = 167ε (Mean = 12ε)

Max = 167ε (Mean = 33.2ε)

Max = 307ε (Mean = 25.2ε)


Table 6.57. Error rates for sph_neumann_prime

GNU C++ version 7.1.0
linux
double

GNU C++ version 7.1.0
linux
long double

Sun compiler version 0x5150
Sun Solaris
long double

Microsoft Visual C++ version 14.1
Win32
double

y': Random Data

Max = 0.988ε (Mean = 0.0869ε)

Max = 158ε (Mean = 18.8ε)

Max = 158ε (Mean = 20.2ε)

Max = 296ε (Mean = 25.6ε)


Implementation

In the general case, the derivatives are calculated using the relations:

There are also a number of special cases, for large x we have:

And for small x:


PrevUpHomeNext