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