Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Generate a Mercer matrix
| ResourceFunction["MercerMatrix"][n] returns the n×n Mercer matrix. | 
A 4×4 Mercer matrix:
| In[1]:= | ![ResourceFunction["MercerMatrix"][4]](https://www.wolframcloud.com/obj/resourcesystem/images/ff1/ff1bea76-89d9-4636-90e9-b4ad8e2d362f/6595370e89b6c0b9.png) | 
| Out[1]= |  | 
Its 4th power is the zero matrix:
| In[2]:= | ![MatrixPower[ResourceFunction["MercerMatrix"][4], 4]](https://www.wolframcloud.com/obj/resourcesystem/images/ff1/ff1bea76-89d9-4636-90e9-b4ad8e2d362f/4486a404dc5aeb6b.png) | 
| Out[2]= |  | 
Visualize the entries of a Mercer matrix:
| In[3]:= | ![MatrixPlot[ResourceFunction["MercerMatrix"][20]]](https://www.wolframcloud.com/obj/resourcesystem/images/ff1/ff1bea76-89d9-4636-90e9-b4ad8e2d362f/7fffaffb42d54db1.png) | 
| Out[3]= |  | 
By default, an exact matrix is computed:
| In[4]:= | ![ResourceFunction["MercerMatrix"][5] // MatrixForm](https://www.wolframcloud.com/obj/resourcesystem/images/ff1/ff1bea76-89d9-4636-90e9-b4ad8e2d362f/40790f58578cd0ac.png) | 
| Out[4]= |  | 
Use machine precision:
| In[5]:= | ![ResourceFunction["MercerMatrix"][5, WorkingPrecision -> MachinePrecision] // MatrixForm](https://www.wolframcloud.com/obj/resourcesystem/images/ff1/ff1bea76-89d9-4636-90e9-b4ad8e2d362f/58040babe34aee37.png) | 
| Out[5]= |  | 
Use arbitrary precision:
| In[6]:= | ![ResourceFunction["MercerMatrix"][5, WorkingPrecision -> 20] // MatrixForm](https://www.wolframcloud.com/obj/resourcesystem/images/ff1/ff1bea76-89d9-4636-90e9-b4ad8e2d362f/2e57a830108b99f6.png) | 
| Out[6]= |  | 
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}]](https://www.wolframcloud.com/obj/resourcesystem/images/ff1/ff1bea76-89d9-4636-90e9-b4ad8e2d362f/79043cc31007f27a.png) | 
| 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}]](https://www.wolframcloud.com/obj/resourcesystem/images/ff1/ff1bea76-89d9-4636-90e9-b4ad8e2d362f/14429e47ac3e6bad.png) | 
| 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}]](https://www.wolframcloud.com/obj/resourcesystem/images/ff1/ff1bea76-89d9-4636-90e9-b4ad8e2d362f/4481defe84f4aaac.png) | 
| Out[9]= |  | 
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}]](https://www.wolframcloud.com/obj/resourcesystem/images/ff1/ff1bea76-89d9-4636-90e9-b4ad8e2d362f/690c67f838f3b8de.png) | 
| Out[10]= |  | 
Wolfram Language 12.3 (May 2021) or above
This work is licensed under a Creative Commons Attribution 4.0 International License