Function Repository Resource:

MercerMatrix

Source Notebook

Generate a Mercer matrix

Contributed by: Jan Mangaldan

ResourceFunction["MercerMatrix"][n]

returns the n×n Mercer matrix.

Details and Options

The Mercer matrix is an index-n nilpotent matrix with non-zero integer entries; that is, the nth matrix power of the Mercer matrix is equal to the zero matrix.
ResourceFunction["MercerMatrix"][,WorkingPrecisionp] gives a matrix with entries of precision p.

Examples

Basic Examples (2) 

A 4×4 Mercer matrix:

In[1]:=
ResourceFunction["MercerMatrix"][4]
Out[1]=

Its 4th power is the zero matrix:

In[2]:=
MatrixPower[ResourceFunction["MercerMatrix"][4], 4]
Out[2]=

Visualize the entries of a Mercer matrix:

In[3]:=
MatrixPlot[ResourceFunction["MercerMatrix"][20]]
Out[3]=

Options (3) 

WorkingPrecision (3) 

By default, an exact matrix is computed:

In[4]:=
ResourceFunction["MercerMatrix"][5] // MatrixForm
Out[4]=

Use machine precision:

In[5]:=
ResourceFunction["MercerMatrix"][5, WorkingPrecision -> MachinePrecision] // MatrixForm
Out[5]=

Use arbitrary precision:

In[6]:=
ResourceFunction["MercerMatrix"][5, WorkingPrecision -> 20] // MatrixForm
Out[6]=

Properties and Relations (3) 

The nth matrix power of an n×n Mercer matrix is the zero matrix; that is, the Mercer matrix is nilpotent (and thus, singular as well):

In[7]:=
Table[MatrixPower[ResourceFunction["MercerMatrix"][n], n] === ConstantArray[0, {n, n}], {n, 2, 9}]
Out[7]=

The Drazin inverse of an n×n Mercer matrix is the zero matrix:

In[8]:=
Table[DrazinInverse[ResourceFunction["MercerMatrix"][n]] === ConstantArray[0, {n, n}], {n, 2, 9}]
Out[8]=

The only null vector (which is also the only eigenvector) of the Mercer matrix has a simple form:

In[9]:=
Table[NullSpace[
   ResourceFunction["MercerMatrix"][n]] === {Append[
    ConstantArray[1, n - 1], 2]}, {n, 2, 9}]
Out[9]=

Neat Examples (1) 

Show that all entries are non-zero for each power of the Mercer matrix until the nth:

In[10]:=
Table[MatrixPlot[
  MatrixPower[ResourceFunction["MercerMatrix"][8], i]], {i, 8}]
Out[10]=

Requirements

Wolfram Language 12.3 (May 2021) or above

Version History

  • 1.0.0 – 09 August 2023

Source Metadata

Related Resources

License Information