]> www.ginac.de Git - cln.git/blob - src/polynomial/misc/cl_UP_I_laguerre.cc
* All Files have been modified for inclusion of namespace cln;
[cln.git] / src / polynomial / misc / cl_UP_I_laguerre.cc
1 // laguerre().
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 // Specification.
7 #include "cln/univpoly_integer.h"
8
9
10 // Implementation.
11
12 #include "cln/integer.h"
13
14 namespace cln {
15
16 const cl_UP_I laguerre (sintL n)
17 {
18 // The Laguerre polynomials L_n(x) are defined as
19 //
20 //                    ( d  ) n
21 //    L_n(x) = exp(x) (----)   (x^n exp(-x))
22 //                    ( dx )
23 //
24 // They satisfy the recurrence relation
25 //
26 //    L_0(x) = 1
27 //    L_{n+1}(x) = (2n+1-x) L_n(x) - n^2 L_{n-1}(x) for n >= 0.
28 //
29 // Theorem:
30 //    L_n(x) satisfies the differential equation
31 //    x*L_n''(x) + (1-x)*L_n'(x) + n*L_n(x) = 0.
32 //
33 // Proof: See elsewhere.
34 //
35 // Corollary:
36 //    The coefficients c_{n,k} of L_n(x) = sum(k=0..n, c_{n,k} x^k)
37 //    satisfy:
38 //       c_{n,n} = (-1)^n,
39 //       c_{n,k} = (k+1)^2/(k-n)*c_{n,k+1}
40 //
41 // It follows that for n>=0
42 //
43 //       L_n(x) = sum(j=0..n, (-1)^(n-j) n!^2/j!(n-j)!^2 x^(n-j))
44 //
45         var cl_univpoly_integer_ring R = find_univpoly_ring(cl_I_ring);
46         var cl_UP_I l = R->create(n);
47         var sintL k = n;
48         var cl_I c_k = (evenp(n) ? 1 : -1);
49         for (;;) {
50                 l.set_coeff(k,c_k);
51                 k = k-1;
52                 if (k < 0)
53                         break;
54                 c_k = exquo((cl_I)(k+1) * (cl_I)(k+1) * c_k,
55                             (cl_I)(k-n));
56         }
57         l.finalize();
58         return l;
59 }
60
61 }  // namespace cln