From e0737c56c1e384e05064a0c6e1ac46979371041b Mon Sep 17 00:00:00 2001 From: Christoph Berg Date: Wed, 19 Dec 2018 22:58:32 +0100 Subject: New upstream version 2.0.0+repack --- .../doc/html/math_toolkit/sf_poly/hermite.html | 243 +++++++++ .../doc/html/math_toolkit/sf_poly/laguerre.html | 384 +++++++++++++ .../doc/html/math_toolkit/sf_poly/legendre.html | 602 +++++++++++++++++++++ .../doc/html/math_toolkit/sf_poly/sph_harm.html | 334 ++++++++++++ 4 files changed, 1563 insertions(+) create mode 100644 boost/libs/math/doc/html/math_toolkit/sf_poly/hermite.html create mode 100644 boost/libs/math/doc/html/math_toolkit/sf_poly/laguerre.html create mode 100644 boost/libs/math/doc/html/math_toolkit/sf_poly/legendre.html create mode 100644 boost/libs/math/doc/html/math_toolkit/sf_poly/sph_harm.html (limited to 'boost/libs/math/doc/html/math_toolkit/sf_poly') diff --git a/boost/libs/math/doc/html/math_toolkit/sf_poly/hermite.html b/boost/libs/math/doc/html/math_toolkit/sf_poly/hermite.html new file mode 100644 index 00000000..6711df39 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/sf_poly/hermite.html @@ -0,0 +1,243 @@ + + + +Hermite Polynomials + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Synopsis +
+
#include <boost/math/special_functions/hermite.hpp>
+
+
namespace boost{ namespace math{
+
+template <class T>
+calculated-result-type hermite(unsigned n, T x);
+
+template <class T, class Policy>
+calculated-result-type hermite(unsigned n, T x, const Policy&);
+
+template <class T1, class T2, class T3>
+calculated-result-type hermite_next(unsigned n, T1 x, T2 Hn, T3 Hnm1);
+
+}} // namespaces
+
+
+ + Description +
+

+ The return type of these functions is computed using the result + type calculation rules: note than when there is a single + template argument the result is the same type as that argument or double if the template argument is an integer + type. +

+
template <class T>
+calculated-result-type hermite(unsigned n, T x);
+
+template <class T, class Policy>
+calculated-result-type hermite(unsigned n, T x, const Policy&);
+
+

+ Returns the value of the Hermite Polynomial of order n + at point x: +

+

+ +

+

+ 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 following graph illustrates the behaviour of the first few Hermite Polynomials: +

+

+ +

+
template <class T1, class T2, class T3>
+calculated-result-type hermite_next(unsigned n, T1 x, T2 Hn, T3 Hnm1);
+
+

+ Implements the three term recurrence relation for the Hermite polynomials, + this function can be used to create a sequence of values evaluated at the + same x, and for rising n. +

+

+ +

+

+ For example we could produce a vector of the first 10 polynomial values using: +

+
double x = 0.5;  // Abscissa value
+vector<double> v;
+v.push_back(hermite(0, x)).push_back(hermite(1, x));
+for(unsigned l = 1; l < 10; ++l)
+   v.push_back(hermite_next(l, x, v[l], v[l-1]));
+
+

+ Formally the arguments are: +

+
+

+
+
n
+

+ The degree n of the last polynomial calculated. +

+
x
+

+ The abscissa value +

+
Hn
+

+ The value of the polynomial evaluated at degree n. +

+
Hnm1
+

+ The value of the polynomial evaluated at degree n-1. +

+
+
+
+ + Accuracy +
+

+ The following table shows peak errors (in units of epsilon) for various domains + of input arguments. Note that only results for the widest floating point + type on the system are given as narrower types have effectively + zero error. +

+
+

Table 6.37. Error rates for hermite

+
+++++++ + + + + + + + + + + + + + + +
+ +

+ Microsoft Visual C++ version 12.0
Win32
double +

+
+

+ GNU C++ version 5.1.0
linux
double +

+
+

+ GNU C++ version 5.1.0
linux
long double +

+
+

+ Sun compiler version 0x5130
Sun Solaris
long double +

+
+

+ Hermite Polynomials +

+
+

+ Max = 4.46ε (Mean = 1.41ε) +

+
+

+ Max = 0ε (Mean = 0ε) +

+
+

+ Max = 6.24ε (Mean = 2.07ε) +

+
+

+ Max = 6.24ε (Mean = 2.07ε) +

+
+
+

+ Note that the worst errors occur when the degree increases, values greater + than ~120 are very unlikely to produce sensible results, especially in the + associated polynomial case when the order is also large. Further the relative + errors are likely to grow arbitrarily large when the function is very close + to a root. +

+
+ + Testing +
+

+ A mixture of spot tests of values calculated using functions.wolfram.com, + and randomly generated test data are used: the test data was computed using + NTL::RR at 1000-bit + precision. +

+
+ + Implementation +
+

+ These functions are implemented using the stable three term recurrence relations. + These relations guarantee low absolute error but cannot guarantee low relative + error near one of the roots of the polynomials. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/sf_poly/laguerre.html b/boost/libs/math/doc/html/math_toolkit/sf_poly/laguerre.html new file mode 100644 index 00000000..4e7f295b --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/sf_poly/laguerre.html @@ -0,0 +1,384 @@ + + + +Laguerre (and Associated) Polynomials + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Synopsis +
+
#include <boost/math/special_functions/laguerre.hpp>
+
+
namespace boost{ namespace math{
+
+template <class T>
+calculated-result-type laguerre(unsigned n, T x);
+
+template <class T, class Policy>
+calculated-result-type laguerre(unsigned n, T x, const Policy&);
+
+template <class T>
+calculated-result-type laguerre(unsigned n, unsigned m, T x);
+
+template <class T, class Policy>
+calculated-result-type laguerre(unsigned n, unsigned m, T x, const Policy&);
+
+template <class T1, class T2, class T3>
+calculated-result-type laguerre_next(unsigned n, T1 x, T2 Ln, T3 Lnm1);
+
+template <class T1, class T2, class T3>
+calculated-result-type laguerre_next(unsigned n, unsigned m, T1 x, T2 Ln, T3 Lnm1);
+
+
+}} // namespaces
+
+
+ + Description +
+

+ The return type of these functions is computed using the result + type calculation rules: note than when there is a single + template argument the result is the same type as that argument or double if the template argument is an integer + type. +

+

+ 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. +

+
template <class T>
+calculated-result-type laguerre(unsigned n, T x);
+
+template <class T, class Policy>
+calculated-result-type laguerre(unsigned n, T x, const Policy&);
+
+

+ Returns the value of the Laguerre Polynomial of order n + at point x: +

+

+ +

+

+ The following graph illustrates the behaviour of the first few Laguerre Polynomials: +

+

+ +

+
template <class T>
+calculated-result-type laguerre(unsigned n, unsigned m, T x);
+
+template <class T, class Policy>
+calculated-result-type laguerre(unsigned n, unsigned m, T x, const Policy&);
+
+

+ Returns the Associated Laguerre polynomial of degree n + and order m at point x: +

+

+ +

+
template <class T1, class T2, class T3>
+calculated-result-type laguerre_next(unsigned n, T1 x, T2 Ln, T3 Lnm1);
+
+

+ Implements the three term recurrence relation for the Laguerre polynomials, + this function can be used to create a sequence of values evaluated at the + same x, and for rising n. +

+

+ +

+

+ For example we could produce a vector of the first 10 polynomial values using: +

+
double x = 0.5;  // Abscissa value
+vector<double> v;
+v.push_back(laguerre(0, x)).push_back(laguerre(1, x));
+for(unsigned l = 1; l < 10; ++l)
+   v.push_back(laguerre_next(l, x, v[l], v[l-1]));
+
+

+ Formally the arguments are: +

+
+

+
+
n
+

+ The degree n of the last polynomial calculated. +

+
x
+

+ The abscissa value +

+
Ln
+

+ The value of the polynomial evaluated at degree n. +

+
Lnm1
+

+ The value of the polynomial evaluated at degree n-1. +

+
+
+
template <class T1, class T2, class T3>
+calculated-result-type laguerre_next(unsigned n, unsigned m, T1 x, T2 Ln, T3 Lnm1);
+
+

+ Implements the three term recurrence relation for the Associated Laguerre + polynomials, this function can be used to create a sequence of values evaluated + at the same x, and for rising degree n. +

+

+ +

+

+ For example we could produce a vector of the first 10 polynomial values using: +

+
double x = 0.5;  // Abscissa value
+int m = 10;      // order
+vector<double> v;
+v.push_back(laguerre(0, m, x)).push_back(laguerre(1, m, x));
+for(unsigned l = 1; l < 10; ++l)
+   v.push_back(laguerre_next(l, m, x, v[l], v[l-1]));
+
+

+ Formally the arguments are: +

+
+

+
+
n
+

+ The degree of the last polynomial calculated. +

+
m
+

+ The order of the Associated Polynomial. +

+
x
+

+ The abscissa value. +

+
Ln
+

+ The value of the polynomial evaluated at degree n. +

+
Lnm1
+

+ The value of the polynomial evaluated at degree n-1. +

+
+
+
+ + Accuracy +
+

+ The following table shows peak errors (in units of epsilon) for various domains + of input arguments. Note that only results for the widest floating point + type on the system are given as narrower types have effectively + zero error. +

+
+

Table 6.35. Error rates for laguerre(n, x)

+
+++++++ + + + + + + + + + + + + + + +
+ +

+ Microsoft Visual C++ version 12.0
Win32
double +

+
+

+ GNU C++ version 5.1.0
linux
double +

+
+

+ GNU C++ version 5.1.0
linux
long double +

+
+

+ Sun compiler version 0x5130
Sun Solaris
long double +

+
+

+ Laguerre Polynomials +

+
+

+ Max = 3.1e+003ε (Mean = 185ε) +

+
+

+ Max = 6.82ε (Mean = 0.408ε)

+ (GSL 1.16: Max = 3.1e+03ε (Mean = 185ε)) +

+
+

+ Max = 1.39e+04ε (Mean = 828ε)
+
(<tr1/cmath>: Max = 4.2e+03ε (Mean + = 251ε)) +

+
+

+ Max = 1.39e+04ε (Mean = 828ε) +

+
+
+
+

Table 6.36. Error rates for laguerre(n, m, x)

+
+++++++ + + + + + + + + + + + + + + +
+ +

+ Microsoft Visual C++ version 12.0
Win32
double +

+
+

+ GNU C++ version 5.1.0
linux
double +

+
+

+ GNU C++ version 5.1.0
linux
long double +

+
+

+ Sun compiler version 0x5130
Sun Solaris
long double +

+
+

+ Associated Laguerre Polynomials +

+
+

+ Max = 434ε (Mean = 11.1ε) +

+
+

+ Max = 0.84ε (Mean = 0.0358ε)

+ (GSL 1.16: Max = 434ε (Mean = 10.7ε)) +

+
+

+ Max = 167ε (Mean = 6.38ε)

+ (<tr1/cmath>: Max = 206ε (Mean = 6.86ε)) +

+
+

+ Max = 167ε (Mean = 6.38ε) +

+
+
+

+ Note that the worst errors occur when the degree increases, values greater + than ~120 are very unlikely to produce sensible results, especially in the + associated polynomial case when the order is also large. Further the relative + errors are likely to grow arbitrarily large when the function is very close + to a root. +

+
+ + Testing +
+

+ A mixture of spot tests of values calculated using functions.wolfram.com, + and randomly generated test data are used: the test data was computed using + NTL::RR at 1000-bit + precision. +

+
+ + Implementation +
+

+ These functions are implemented using the stable three term recurrence relations. + These relations guarantee low absolute error but cannot guarantee low relative + error near one of the roots of the polynomials. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/sf_poly/legendre.html b/boost/libs/math/doc/html/math_toolkit/sf_poly/legendre.html new file mode 100644 index 00000000..30979640 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/sf_poly/legendre.html @@ -0,0 +1,602 @@ + + + +Legendre (and Associated) Polynomials + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Synopsis +
+
#include <boost/math/special_functions/legendre.hpp>
+
+
namespace boost{ namespace math{
+
+template <class T>
+calculated-result-type legendre_p(int n, T x);
+
+template <class T, class Policy>
+calculated-result-type legendre_p(int n, T x, const Policy&);
+
+template <class T>
+calculated-result-type legendre_p(int n, int m, T x);
+
+template <class T, class Policy>
+calculated-result-type legendre_p(int n, int m, T x, const Policy&);
+
+template <class T>
+calculated-result-type legendre_q(unsigned n, T x);
+
+template <class T, class Policy>
+calculated-result-type legendre_q(unsigned n, T x, const Policy&);
+
+template <class T1, class T2, class T3>
+calculated-result-type legendre_next(unsigned l, T1 x, T2 Pl, T3 Plm1);
+
+template <class T1, class T2, class T3>
+calculated-result-type legendre_next(unsigned l, unsigned m, T1 x, T2 Pl, T3 Plm1);
+
+
+}} // namespaces
+
+

+ The return type of these functions is computed using the result + type calculation rules: note than when there is a single + template argument the result is the same type as that argument or double if the template argument is an integer + type. +

+

+ 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. +

+
+ + Description +
+
template <class T>
+calculated-result-type legendre_p(int l, T x);
+
+template <class T, class Policy>
+calculated-result-type legendre_p(int l, T x, const Policy&);
+
+

+ Returns the Legendre Polynomial of the first kind: +

+

+ +

+

+ Requires -1 <= x <= 1, otherwise returns the result of domain_error. +

+

+ Negative orders are handled via the reflection formula: +

+

+ P-l-1(x) = Pl(x) +

+

+ The following graph illustrates the behaviour of the first few Legendre Polynomials: +

+

+ +

+
template <class T>
+calculated-result-type legendre_p(int l, int m, T x);
+
+template <class T, class Policy>
+calculated-result-type legendre_p(int l, int m, T x, const Policy&);
+
+

+ Returns the associated Legendre polynomial of the first kind: +

+

+ +

+

+ Requires -1 <= x <= 1, otherwise returns the result of domain_error. +

+

+ Negative values of l and m are + handled via the identity relations: +

+

+ +

+
+ + + + + +
[Caution]Caution
+

+ The definition of the associated Legendre polynomial used here includes + a leading Condon-Shortley phase term of (-1)m. This matches the definition + given by Abramowitz and Stegun (8.6.6) and that used by Mathworld + and Mathematica's + LegendreP function. However, uses in the literature do not always + include this phase term, and strangely the specification for the associated + Legendre function in the C++ TR1 (assoc_legendre) also omits it, in spite + of stating that it uses Abramowitz and Stegun as the final arbiter on these + matters. +

+

+ See: +

+

+ Weisstein, + Eric W. "Legendre Polynomial." From MathWorld--A Wolfram Web + Resource. +

+

+ Abramowitz, M. and Stegun, I. A. (Eds.). "Legendre Functions" + and "Orthogonal Polynomials." Ch. 22 in Chs. 8 and 22 in Handbook + of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, + 9th printing. New York: Dover, pp. 331-339 and 771-802, 1972. +

+
+
template <class T>
+calculated-result-type legendre_q(unsigned n, T x);
+
+template <class T, class Policy>
+calculated-result-type legendre_q(unsigned n, T x, const Policy&);
+
+

+ Returns the value of the Legendre polynomial that is the second solution + to the Legendre differential equation, for example: +

+

+ +

+

+ Requires -1 <= x <= 1, otherwise domain_error + is called. +

+

+ The following graph illustrates the first few Legendre functions of the second + kind: +

+

+ +

+
template <class T1, class T2, class T3>
+calculated-result-type legendre_next(unsigned l, T1 x, T2 Pl, T3 Plm1);
+
+

+ Implements the three term recurrence relation for the Legendre polynomials, + this function can be used to create a sequence of values evaluated at the + same x, and for rising l. This + recurrence relation holds for Legendre Polynomials of both the first and + second kinds. +

+

+ +

+

+ For example we could produce a vector of the first 10 polynomial values using: +

+
double x = 0.5;  // Abscissa value
+vector<double> v;
+v.push_back(legendre_p(0, x));
+v.push_back(legendre_p(1, x));
+for(unsigned l = 1; l < 10; ++l)
+   v.push_back(legendre_next(l, x, v[l], v[l-1]));
+// Double check values:
+for(unsigned l = 1; l < 10; ++l)
+   assert(v[l] == legendre_p(l, x));
+
+

+ Formally the arguments are: +

+
+

+
+
l
+

+ The degree of the last polynomial calculated. +

+
x
+

+ The abscissa value +

+
Pl
+

+ The value of the polynomial evaluated at degree l. +

+
Plm1
+

+ The value of the polynomial evaluated at degree l-1. +

+
+
+
template <class T1, class T2, class T3>
+calculated-result-type legendre_next(unsigned l, unsigned m, T1 x, T2 Pl, T3 Plm1);
+
+

+ Implements the three term recurrence relation for the Associated Legendre + polynomials, this function can be used to create a sequence of values evaluated + at the same x, and for rising l. +

+

+ +

+

+ For example we could produce a vector of the first m+10 polynomial values + using: +

+
double x = 0.5;  // Abscissa value
+int m = 10;      // order
+vector<double> v;
+v.push_back(legendre_p(m, m, x));
+v.push_back(legendre_p(1 + m, m, x));
+for(unsigned l = 1; l < 10; ++l)
+   v.push_back(legendre_next(l + 10, m, x, v[l], v[l-1]));
+// Double check values:
+for(unsigned l = 1; l < 10; ++l)
+   assert(v[l] == legendre_p(10 + l, m, x));
+
+

+ Formally the arguments are: +

+
+

+
+
l
+

+ The degree of the last polynomial calculated. +

+
m
+

+ The order of the Associated Polynomial. +

+
x
+

+ The abscissa value +

+
Pl
+

+ The value of the polynomial evaluated at degree l. +

+
Plm1
+

+ The value of the polynomial evaluated at degree l-1. +

+
+
+
+ + Accuracy +
+

+ The following table shows peak errors (in units of epsilon) for various domains + of input arguments. Note that only results for the widest floating point + type on the system are given as narrower types have effectively + zero error. +

+
+

Table 6.32. Error rates for legendre_p

+
+++++++ + + + + + + + + + + + + + + + + + + + + + + + +
+ +

+ Microsoft Visual C++ version 12.0
Win32
double +

+
+

+ GNU C++ version 5.1.0
linux
double +

+
+

+ GNU C++ version 5.1.0
linux
long double +

+
+

+ Sun compiler version 0x5130
Sun Solaris
long double +

+
+

+ Legendre Polynomials: Small Values +

+
+

+ Max = 211ε (Mean = 20.4ε) +

+
+

+ Max = 0.732ε (Mean = 0.0619ε)
+
(GSL 1.16: Max = 211ε (Mean = 20.4ε)) +

+
+

+ Max = 69.2ε (Mean = 9.58ε)

+ (<tr1/cmath>: Max = 124ε (Mean = 13.2ε)) +

+
+

+ Max = 69.2ε (Mean = 9.58ε) +

+
+

+ Legendre Polynomials: Large Values +

+
+

+ Max = 300ε (Mean = 33.2ε) +

+
+

+ Max = 0.632ε (Mean = 0.0693ε)
+
(GSL 1.16: Max = 300ε (Mean = 33.2ε)) +

+
+

+ Max = 699ε (Mean = 59.6ε)

+ (<tr1/cmath>: Max = 343ε (Mean = 32.1ε)) +

+
+

+ Max = 699ε (Mean = 59.6ε) +

+
+
+
+

Table 6.33. Error rates for legendre_q

+
+++++++ + + + + + + + + + + + + + + + + + + + + + + + +
+ +

+ Microsoft Visual C++ version 12.0
Win32
double +

+
+

+ GNU C++ version 5.1.0
linux
double +

+
+

+ GNU C++ version 5.1.0
linux
long double +

+
+

+ Sun compiler version 0x5130
Sun Solaris
long double +

+
+

+ Legendre Polynomials: Small Values +

+
+

+ Max = 46.4ε (Mean = 7.32ε) +

+
+

+ Max = 0.612ε (Mean = 0.0517ε)
+
(GSL 1.16: Max = 46.4ε (Mean = 7.46ε)) +

+
+

+ Max = 50.9ε (Mean = 9ε) +

+
+

+ Max = 50.9ε (Mean = 8.98ε) +

+
+

+ Legendre Polynomials: Large Values +

+
+

+ Max = 4.6e+003ε (Mean = 366ε) +

+
+

+ Max = 2.49ε (Mean = 0.202ε)

+ (GSL 1.16: Max = 4.6e+03ε (Mean = 366ε)) +

+
+

+ Max = 5.98e+03ε (Mean = 478ε) +

+
+

+ Max = 5.98e+03ε (Mean = 478ε) +

+
+
+
+

Table 6.34. Error rates for legendre_p (associated)

+
+++++++ + + + + + + + + + + + + + + +
+ +

+ Microsoft Visual C++ version 12.0
Win32
double +

+
+

+ GNU C++ version 5.1.0
linux
double +

+
+

+ GNU C++ version 5.1.0
linux
long double +

+
+

+ Sun compiler version 0x5130
Sun Solaris
long double +

+
+

+ Associated Legendre Polynomials: Small Values +

+
+

+ Max = 121ε (Mean = 7.14ε) +

+
+

+ Max = 0.999ε (Mean = 0.05ε)

+ (GSL 1.16: Max = 121ε (Mean = 6.75ε) And + other failures.) +

+
+

+ Max = 175ε (Mean = 9.88ε)

+ (<tr1/cmath>: Max = 175ε (Mean = 9.36ε) + And + other failures.) +

+
+

+ Max = 77.7ε (Mean = 5.59ε) +

+
+
+

+ Note that the worst errors occur when the order increases, values greater + than ~120 are very unlikely to produce sensible results, especially in the + associated polynomial case when the degree is also large. Further the relative + errors are likely to grow arbitrarily large when the function is very close + to a root. +

+
+ + Testing +
+

+ A mixture of spot tests of values calculated using functions.wolfram.com, + and randomly generated test data are used: the test data was computed using + NTL::RR at 1000-bit + precision. +

+
+ + Implementation +
+

+ These functions are implemented using the stable three term recurrence relations. + These relations guarantee low absolute error but cannot guarantee low relative + error near one of the roots of the polynomials. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/sf_poly/sph_harm.html b/boost/libs/math/doc/html/math_toolkit/sf_poly/sph_harm.html new file mode 100644 index 00000000..0bdb78bd --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/sf_poly/sph_harm.html @@ -0,0 +1,334 @@ + + + +Spherical Harmonics + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Synopsis +
+
#include <boost/math/special_functions/spherical_harmonic.hpp>
+
+
namespace boost{ namespace math{
+
+template <class T1, class T2>
+std::complex<calculated-result-type> spherical_harmonic(unsigned n, int m, T1 theta, T2 phi);
+
+template <class T1, class T2, class Policy>
+std::complex<calculated-result-type> spherical_harmonic(unsigned n, int m, T1 theta, T2 phi, const Policy&);
+
+template <class T1, class T2>
+calculated-result-type spherical_harmonic_r(unsigned n, int m, T1 theta, T2 phi);
+
+template <class T1, class T2, class Policy>
+calculated-result-type spherical_harmonic_r(unsigned n, int m, T1 theta, T2 phi, const Policy&);
+
+template <class T1, class T2>
+calculated-result-type spherical_harmonic_i(unsigned n, int m, T1 theta, T2 phi);
+
+template <class T1, class T2, class Policy>
+calculated-result-type spherical_harmonic_i(unsigned n, int m, T1 theta, T2 phi, const Policy&);
+
+}} // namespaces
+
+
+ + Description +
+

+ The return type of these functions is computed using the result + type calculation rules when T1 and T2 are different types. +

+

+ 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. +

+
template <class T1, class T2>
+std::complex<calculated-result-type> spherical_harmonic(unsigned n, int m, T1 theta, T2 phi);
+
+template <class T1, class T2, class Policy>
+std::complex<calculated-result-type> spherical_harmonic(unsigned n, int m, T1 theta, T2 phi, const Policy&);
+
+

+ Returns the value of the Spherical Harmonic Ynm(theta, phi): +

+

+ +

+

+ The spherical harmonics Ynm(theta, phi) are the angular portion of the solution + to Laplace's equation in spherical coordinates where azimuthal symmetry is + not present. +

+
+ + + + + +
[Caution]Caution
+

+ Care must be taken in correctly identifying the arguments to this function: + θ   is taken as the polar (colatitudinal) coordinate with θ   in [0, π], and φ   as + the azimuthal (longitudinal) coordinate with φ   in [0,2π). This is the convention + used in Physics, and matches the definition used by Mathematica + in the function SpericalHarmonicY, but is opposite to the usual + mathematical conventions. +

+

+ Some other sources include an additional Condon-Shortley phase term of + (-1)m in the definition of this function: note however that our definition + of the associated Legendre polynomial already includes this term. +

+

+ This implementation returns zero for m > n +

+

+ For θ   outside [0, π] and φ   outside [0, 2π] this implementation follows the convention + used by Mathematica: the function is periodic with period π   in θ   and 2π   in φ. + Please note that this is not the behaviour one would get from a casual + application of the function's definition. Cautious users should keep θ   and + φ   to the range [0, π] and [0, 2π] respectively. +

+

+ See: Weisstein, + Eric W. "Spherical Harmonic." From MathWorld--A Wolfram Web Resource. +

+
+
template <class T1, class T2>
+calculated-result-type spherical_harmonic_r(unsigned n, int m, T1 theta, T2 phi);
+
+template <class T1, class T2, class Policy>
+calculated-result-type spherical_harmonic_r(unsigned n, int m, T1 theta, T2 phi, const Policy&);
+
+

+ Returns the real part of Ynm(theta, phi): +

+

+ +

+
template <class T1, class T2>
+calculated-result-type spherical_harmonic_i(unsigned n, int m, T1 theta, T2 phi);
+
+template <class T1, class T2, class Policy>
+calculated-result-type spherical_harmonic_i(unsigned n, int m, T1 theta, T2 phi, const Policy&);
+
+

+ Returns the imaginary part of Ynm(theta, phi): +

+

+ +

+
+ + Accuracy +
+

+ The following table shows peak errors for various domains of input arguments. + Note that only results for the widest floating point type on the system are + given as narrower types have effectively + zero error. Peak errors are the same for both the real and imaginary + parts, as the error is dominated by calculation of the associated Legendre + polynomials: especially near the roots of the associated Legendre function. +

+

+ All values are in units of epsilon. +

+
+

Table 6.38. Error rates for spherical_harmonic_r

+
+++++++ + + + + + + + + + + + + + + +
+ +

+ Microsoft Visual C++ version 12.0
Win32
double +

+
+

+ GNU C++ version 5.1.0
linux
double +

+
+

+ GNU C++ version 5.1.0
linux
long double +

+
+

+ Sun compiler version 0x5130
Sun Solaris
long double +

+
+

+ Spherical Harmonics +

+
+

+ Max = 2.27e+004ε (Mean = 725ε) +

+
+

+ Max = 1.58ε (Mean = 0.0707ε) +

+
+

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

+
+

+ Max = 1.03e+04ε (Mean = 327ε) +

+
+
+
+

Table 6.39. Error rates for spherical_harmonic_i

+
+++++++ + + + + + + + + + + + + + + +
+ +

+ Microsoft Visual C++ version 12.0
Win32
double +

+
+

+ GNU C++ version 5.1.0
linux
double +

+
+

+ GNU C++ version 5.1.0
linux
long double +

+
+

+ Sun compiler version 0x5130
Sun Solaris
long double +

+
+

+ Spherical Harmonics +

+
+

+ Max = 2.27e+004ε (Mean = 725ε) +

+
+

+ Max = 1.36ε (Mean = 0.0765ε) +

+
+

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

+
+

+ Max = 1.03e+04ε (Mean = 327ε) +

+
+
+

+ Note that the worst errors occur when the degree increases, values greater + than ~120 are very unlikely to produce sensible results, especially when + the order is also large. Further the relative errors are likely to grow arbitrarily + large when the function is very close to a root. +

+
+ + Testing +
+

+ A mixture of spot tests of values calculated using functions.wolfram.com, + and randomly generated test data are used: the test data was computed using + NTL::RR at 1000-bit + precision. +

+
+ + Implementation +
+

+ These functions are implemented fairly naively using the formulae given above. + Some extra care is taken to prevent roundoff error when converting from polar + coordinates (so for example the 1-x2 term used by the + associated Legendre functions is calculated without roundoff error using + x = cos(theta), and 1-x2 = sin2(theta)). + The limiting factor in the error rates for these functions is the need to + calculate values near the roots of the associated Legendre functions. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + -- cgit v1.2.3