]> www.ginac.de Git - cln.git/blob - src/polynomial/misc/cl_UP_I_hermite.cc
b2807bf43549a995f55801bde3b600f1b05d930c
[cln.git] / src / polynomial / misc / cl_UP_I_hermite.cc
1 // cl_hermite().
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_hermite (sintL n)
15 {
16 // The Hermite polynomials H_n(x) are defined as
17 //
18 //                             ( d  ) n
19 //    H_n(x) = (-1)^n exp(x^2) (----)   exp(- x^2)
20 //                             ( dx )
21 //
22 // They satisfy the recurrence relation
23 //
24 //    H_0(x) = 1
25 //    H_{n+1}(x) = 2x H_n(x) - 2n H_{n-1}(x) for n >= 0.
26 //
27 // Theorem:
28 //    H_n(x) satisfies the differential equation
29 //    H_n''(x) - 2x*H_n'(x) + 2n*H_n(x) = 0.
30 //
31 // Proof: See elsewhere.
32 //
33 // Corollary:
34 //    The coefficients c_{n,k} of H_n(x) = sum(k=0..n, c_{n,k} x^k)
35 //    satisfy:
36 //       c_{n,n} = 2^n,
37 //       c_{n,n-1} = 0,
38 //       c_{n,k} = (k+1)(k+2)/2(k-n)*c_{n,k+2}
39 //
40 // It follows that for n>=0
41 //
42 //    H_n(x) = sum(j=0..floor(n/2), (-1)^j n!/j!(n-2j)! 2^(n-2j) x^(n-2j))
43 //
44         var cl_univpoly_integer_ring R = cl_find_univpoly_ring(cl_I_ring);
45         var cl_UP_I h = R->create(n);
46         var sintL k = n;
47         var cl_I c_k = ash(1,n);
48         for (;;) {
49                 h.set_coeff(k,c_k);
50                 k = k-2;
51                 if (k < 0)
52                         break;
53                 c_k = exquo((cl_I)(k+1) * (cl_I)(k+2) * c_k,
54                             2*(cl_I)(k-n));
55         }
56         h.finalize();
57         return h;
58 }