
Krawtchouk polynomials, K_{n}(x; p, N), N a positive integer, 0 < p < 1, n = 0, … , N, are orthogonal on the support interval [0,N] with weight function w(x) = Σ_{n=0}^{N} C_{x}^{N} p ^{x} (1  p) ^{N  x} &delta(x  n) 

and normalized by the requirement that the leading coefficient K_{n}(x; p, N) is 1 / n!.
K_{n}(x; p, N) satisfies the threeterm recurrence relation (n + 1) K_{n+1}(x) = [ x  n + p ( N  2n) ] K_{n}(x)  n (N  n + 1) p (1  p) K_{n1}(x)  for n ≥ 1 

with starting values K_{0}(x; p, N) = 1,  K_{1}(x; p, N) = x  p N. 

 double Krawtchouk_Kn( double x, double p, int N, int n )
This function returns K_{n}(x; p, N) where K_{n}(x; p, N) is described above.
 long double xKrawtchouk_Kn( long double x, long double p, int N, int n )
This function returns K_{n}(x; p, N) where K_{n}(x; p, N) is described above.
 void Krawtchouk_Kn_Sequence( double K[ ], double x, double p, int N, int max_n )
This function returns K_{n}(x; p, N), for n = 0, 1, …, max_n in the array K[ ] where K_{n}(x; p, N) is described above. Note that K[ ] should be declared as double K[L] where L ≥ max_n + 1._{ }
 void xKrawtchouk_Kn_Sequence( long double K[ ], long double x, long double p, int N, int max_n )
This function returns K_{n}(x; p, N), for n = 0, 1, …, max_n in the array K[ ] where K_{n}(x; p, N) is described above. Note that K[ ] should be declared as long double K[L] where L ≥ max_n + 1._{ }
 double Krawtchouk_Kn_Series( double x, double p, int N, double a[ ], int degree )
This function returns Σ_{k=0}^{n}a[k] K_{k}(x; p, N) where n = degree and K_{k}(x; p, N) for k = 0, …, n is described above._{ }
 long double xKrawtchouk_Kn_Series( long double x, long double p, int N, long double a[ ], int degree )
This function returns Σ_{k=0}^{n}a[k] K_{k}(x; p, N) where n = degree and K_{k}(x; p, N) for k = 0, …, n is described above._{ }
C source code is available for these routines:
