Function Repository Resource:

# KrawtchoukMatrix

Generate a Krawtchouk matrix

Contributed by: Jan Mangaldan
 ResourceFunction["KrawtchoukMatrix"][n] returns an n×n Krawtchouk matrix.

## Details and Options

The Krawtchouk matrix is also known as the binomial matrix.
The Krawtchouk matrix is a matrix with integer entries, whose entries are constructed from discrete orthogonal polynomials known as Krawtchouk polynomials.
The Krawtchouk matrix appears in algebraic coding theory, digital filters, multivariate splines, the Ehrenfest urn model and the modelling of Bernoulli random walks.
The Krawtchouk matrix, when multiplied with itself, gives a multiple of the identity matrix of the same size, where the multiple is 2n-1.
ResourceFunction["KrawtchoukMatrix"][,"Normalized"True] generates a normalized version of the Krawtchouk matrix such that the resulting matrix is both symmetric and orthogonal.
ResourceFunction["KrawtchoukMatrix"][,WorkingPrecisionp] gives a matrix with entries of precision p.

## Examples

### Basic Examples (2)

A 4×4 Krawtchouk matrix:

 In[1]:=
 Out[1]=

Visualize the entries of a Krawtchouk matrix:

 In[2]:=
 Out[2]=

### Options (5)

#### Normalized (2)

A normalized Krawtchouk matrix:

 In[3]:=
 Out[3]=

The normalized matrix is both symmetric and orthogonal:

 In[4]:=
 Out[4]=

#### WorkingPrecision (3)

By default, an exact matrix is computed:

 In[5]:=
 Out[5]=

Use machine precision:

 In[6]:=
 Out[6]=

Use arbitrary precision:

 In[7]:=
 Out[7]=

### Applications (6)

Define a symmetrized version of the Krawtchouk matrix:

 In[8]:=

The symmetrized Krawtchouk matrix is symmetric, as its name implies:

 In[9]:=
 Out[9]=
 In[10]:=
 Out[10]=

The symmetrized Krawtchouk matrix gives the coefficients of the bivariate polynomial (1+x+y-x y)n-1:

 In[11]:=
 Out[11]=

Demonstrate a recursive method for generating the symmetrized Krawtchouk matrix:

 In[12]:=
 Out[12]=

The Kac matrix is a tridiagonal matrix whose subdiagonal and superdiagonal entries are consecutive integers:

 In[13]:=
 In[14]:=
 Out[14]=

The Kac matrix can be diagonalized by the symmetrized Krawtchouk matrix:

 In[15]:=
 Out[15]=

### Properties and Relations (4)

Columns of the Krawtchouk matrix can be determined from the coefficients of the polynomial (1+x)n-j-1(1-x)j:

 In[16]:=
 Out[16]=
 In[17]:=
 Out[17]=

The entries of the Krawtchouk matrix can be expressed in terms of the Krawtchouk polynomial, which can be expressed in terms of Hypergeometric2F1:

 In[18]:=
 Out[18]=
 In[19]:=
 Out[19]=

Generate the Krawtchouk matrix through a recursive definition:

 In[20]:=
 Out[20]=
 In[21]:=
 Out[21]=

The product of a Krawtchouk matrix with itself is a constant multiple of the identity matrix of the same size:

 In[22]:=
 Out[22]=

### Neat Examples (2)

Generate a Krawtchouk matrix from a Hadamard matrix, using condensation of the rows and columns with the same binary weights (number of 1's in the binary representation):

 In[23]:=
 Out[24]=

Verify that the result is a Krawtchouk matrix:

 In[25]:=
 Out[25]=

## Version History

• 1.0.0 – 01 March 2023