Skip to main content
. 2021 Sep 3;23(9):1162. doi: 10.3390/e23091162
Algorithm 1 Computation of Krawtchouk polynomials using the proposed algorithm.
     Input: N,p
                   N represents the size of the Krawtchouk polynomial,
                   p represents the parameter of the Krawtchouk polynomials.
     Output: Knpx
1: Flag=False
2: if  p>0.5  then
3:     Flag=True;       pp1
4: end if
5: x0Np,       x1x0+1
6: Compute K0px0 using (10)
7: Compute K0px1 using (12)
8: Compute K1px0 and K1px1 using (16) and (17)
9: ▹ Compute initial set
10: for x=x0:x1 do
11:     for n=2:x do
12:         Compute Knpx using (18)
13:     end for
14: end for
15: ▹ Compute coefficient values in Part 1
16: for n=0:x0 do
17:     for x=x0:1:ndo▹ inner loop
18:         Compute Knpx using (19)
19:         if |Kn(x)|<105and|Kn(x+1)|<107 then
20:            Exit inner loop
21:         end if
22:     end for
23: end for
24: ▹ Compute coefficient values in Part 2-1
25: for n=0:x0 do
26:     for x=x0:Nn1do ▹ inner loop
27:         Compute Knpx using (21)
28:         if |Kn(x+1)|<107and|Kn(x)|<105 then
29:            Exit inner loop
30:         end if
31:     end for
32: end for
33: ▹ Compute coefficient values in Part 2-2
34: for x=x0:N/21 do
35:     nx
36:     Compute Knpx using (23)
37: end for
38: for x=x1:N/21 do
39:     nx
40:     Compute Knpx using (26)
41: end for
42: ▹ Compute coefficient values in Part 2-3
43: for n=x1:N/22 do
44:     for x=n+2:Nn1do ▹ inner loop
45:         Compute Knpx using (21)
46:         if |Kn(x)|<105and|Kn(x+1)|<107 then
47:            Exit inner loop
48:         end if
49:     end for
50: end for
51: Compute the rest of the coefficients using the similarity relations (28) and (29)
52: if Flag=True then
53:     Apply (30)
54: end if