]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | [section:laguerre Laguerre (and Associated) Polynomials] |
2 | ||
3 | [h4 Synopsis] | |
4 | ||
5 | `` | |
6 | #include <boost/math/special_functions/laguerre.hpp> | |
7 | `` | |
8 | ||
9 | namespace boost{ namespace math{ | |
10 | ||
11 | template <class T> | |
12 | ``__sf_result`` laguerre(unsigned n, T x); | |
13 | ||
14 | template <class T, class ``__Policy``> | |
15 | ``__sf_result`` laguerre(unsigned n, T x, const ``__Policy``&); | |
16 | ||
17 | template <class T> | |
18 | ``__sf_result`` laguerre(unsigned n, unsigned m, T x); | |
19 | ||
20 | template <class T, class ``__Policy``> | |
21 | ``__sf_result`` laguerre(unsigned n, unsigned m, T x, const ``__Policy``&); | |
22 | ||
23 | template <class T1, class T2, class T3> | |
24 | ``__sf_result`` laguerre_next(unsigned n, T1 x, T2 Ln, T3 Lnm1); | |
25 | ||
26 | template <class T1, class T2, class T3> | |
27 | ``__sf_result`` laguerre_next(unsigned n, unsigned m, T1 x, T2 Ln, T3 Lnm1); | |
28 | ||
29 | ||
30 | }} // namespaces | |
31 | ||
32 | [h4 Description] | |
33 | ||
34 | The return type of these functions is computed using the __arg_promotion_rules: | |
35 | note than when there is a single template argument the result is the same type | |
36 | as that argument or `double` if the template argument is an integer type. | |
37 | ||
38 | [optional_policy] | |
39 | ||
40 | template <class T> | |
41 | ``__sf_result`` laguerre(unsigned n, T x); | |
42 | ||
43 | template <class T, class ``__Policy``> | |
44 | ``__sf_result`` laguerre(unsigned n, T x, const ``__Policy``&); | |
45 | ||
46 | Returns the value of the Laguerre Polynomial of order /n/ at point /x/: | |
47 | ||
48 | [equation laguerre_0] | |
49 | ||
50 | The following graph illustrates the behaviour of the first few | |
51 | Laguerre Polynomials: | |
52 | ||
53 | [graph laguerre] | |
54 | ||
55 | template <class T> | |
56 | ``__sf_result`` laguerre(unsigned n, unsigned m, T x); | |
57 | ||
58 | template <class T, class ``__Policy``> | |
59 | ``__sf_result`` laguerre(unsigned n, unsigned m, T x, const ``__Policy``&); | |
60 | ||
61 | Returns the Associated Laguerre polynomial of degree /n/ | |
62 | and order /m/ at point /x/: | |
63 | ||
64 | [equation laguerre_1] | |
65 | ||
66 | template <class T1, class T2, class T3> | |
67 | ``__sf_result`` laguerre_next(unsigned n, T1 x, T2 Ln, T3 Lnm1); | |
68 | ||
69 | Implements the three term recurrence relation for the Laguerre | |
70 | polynomials, this function can be used to create a sequence of | |
71 | values evaluated at the same /x/, and for rising /n/. | |
72 | ||
73 | [equation laguerre_2] | |
74 | ||
75 | For example we could produce a vector of the first 10 polynomial | |
76 | values using: | |
77 | ||
78 | double x = 0.5; // Abscissa value | |
79 | vector<double> v; | |
80 | v.push_back(laguerre(0, x)).push_back(laguerre(1, x)); | |
81 | for(unsigned l = 1; l < 10; ++l) | |
82 | v.push_back(laguerre_next(l, x, v[l], v[l-1])); | |
83 | ||
84 | Formally the arguments are: | |
85 | ||
86 | [variablelist | |
87 | [[n][The degree /n/ of the last polynomial calculated.]] | |
88 | [[x][The abscissa value]] | |
89 | [[Ln][The value of the polynomial evaluated at degree /n/.]] | |
90 | [[Lnm1][The value of the polynomial evaluated at degree /n-1/.]] | |
91 | ] | |
92 | ||
93 | template <class T1, class T2, class T3> | |
94 | ``__sf_result`` laguerre_next(unsigned n, unsigned m, T1 x, T2 Ln, T3 Lnm1); | |
95 | ||
96 | Implements the three term recurrence relation for the Associated Laguerre | |
97 | polynomials, this function can be used to create a sequence of | |
98 | values evaluated at the same /x/, and for rising degree /n/. | |
99 | ||
100 | [equation laguerre_3] | |
101 | ||
102 | For example we could produce a vector of the first 10 polynomial | |
103 | values using: | |
104 | ||
105 | double x = 0.5; // Abscissa value | |
106 | int m = 10; // order | |
107 | vector<double> v; | |
108 | v.push_back(laguerre(0, m, x)).push_back(laguerre(1, m, x)); | |
109 | for(unsigned l = 1; l < 10; ++l) | |
110 | v.push_back(laguerre_next(l, m, x, v[l], v[l-1])); | |
111 | ||
112 | Formally the arguments are: | |
113 | ||
114 | [variablelist | |
115 | [[n][The degree of the last polynomial calculated.]] | |
116 | [[m][The order of the Associated Polynomial.]] | |
117 | [[x][The abscissa value.]] | |
118 | [[Ln][The value of the polynomial evaluated at degree /n/.]] | |
119 | [[Lnm1][The value of the polynomial evaluated at degree /n-1/.]] | |
120 | ] | |
121 | ||
122 | [h4 Accuracy] | |
123 | ||
124 | The following table shows peak errors (in units of epsilon) | |
125 | for various domains of input arguments. | |
126 | Note that only results for the widest floating point type on the system are | |
127 | given as narrower types have __zero_error. | |
128 | ||
129 | [table_laguerre_n_x_] | |
130 | ||
131 | [table_laguerre_n_m_x_] | |
132 | ||
133 | Note that the worst errors occur when the degree increases, values greater than | |
134 | ~120 are very unlikely to produce sensible results, especially in the associated | |
135 | polynomial case when the order is also large. Further the relative errors | |
136 | are likely to grow arbitrarily large when the function is very close to a root. | |
137 | ||
138 | [h4 Testing] | |
139 | ||
140 | A mixture of spot tests of values calculated using functions.wolfram.com, | |
141 | and randomly generated test data are | |
142 | used: the test data was computed using | |
143 | [@http://shoup.net/ntl/doc/RR.txt NTL::RR] at 1000-bit precision. | |
144 | ||
145 | [h4 Implementation] | |
146 | ||
147 | These functions are implemented using the stable three term | |
148 | recurrence relations. These relations guarantee low absolute error | |
149 | but cannot guarantee low relative error near one of the roots of the | |
150 | polynomials. | |
151 | ||
152 | [endsect][/section:beta_function The Beta Function] | |
153 | [/ | |
154 | Copyright 2006 John Maddock and Paul A. Bristow. | |
155 | Distributed under the Boost Software License, Version 1.0. | |
156 | (See accompanying file LICENSE_1_0.txt or copy at | |
157 | http://www.boost.org/LICENSE_1_0.txt). | |
158 | ] | |
159 |