In mathematics, in linear algebra, a Weyr canonical form (or, Weyr form or Weyr matrix) is a square matrix which (in some sense) induces "nice" properties with matrices it commutes with. It also has a particularly simple structure and the conditions for possessing a Weyr form are fairly weak, making it a suitable tool for studying classes of commuting matrices. A square matrix is said to be in the Weyr canonical form if the matrix has the structure defining the Weyr canonical form. The Weyr form was discovered by the Czech mathematician Eduard Weyr in 1885.  The Weyr form did not become popular among mathematicians and it was overshadowed by the closely related, but distinct, canonical form known by the name Jordan canonical form. The Weyr form has been rediscovered several times since Weyr’s original discovery in 1885.  This form has been variously called as modified Jordan form, reordered Jordan form, second Jordan form, and H-form. The current terminology is credited to Shapiro who introduced it in a paper published in the American Mathematical Monthly in 1999.
 Recently several applications have been found for the Weyr matrix. Of particular interest is an application of the Weyr matrix in the study of phylogenetic invariants in biomathematics.
 A basic Weyr matrix with eigenvalue 
  
    
      
        λ
      
    
    {\displaystyle \lambda }
  
  is an 
  
    
      
        n
        ×
        n
      
    
    {\displaystyle n\times n}
  
 matrix 
  
    
      
        W
      
    
    {\displaystyle W}
  
 of the following form: There is a partition 
 such that, when 
  
    
      
        W
      
    
    {\displaystyle W}
  
 is viewed as an 
  
    
      
        r
        ×
        r
      
    
    {\displaystyle r\times r}
  
  block matrix 
  
    
      
        (
        
          W
          
            i
            j
          
        
        )
      
    
    {\displaystyle (W_{ij})}
  
, where the 
  
    
      
        (
        i
        ,
        j
        )
      
    
    {\displaystyle (i,j)}
  
 block 
  
    
      
        
          W
          
            i
            j
          
        
      
    
    {\displaystyle W_{ij}}
  
  is an 
  
    
      
        
          n
          
            i
          
        
        ×
        
          n
          
            j
          
        
      
    
    {\displaystyle n_{i}\times n_{j}}
  
 matrix, the following three features are present:
 In this case, we say that 
  
    
      
        W
      
    
    {\displaystyle W}
  
 has Weyr structure 
  
    
      
        (
        
          n
          
            1
          
        
        ,
        
          n
          
            2
          
        
        ,
        …
        ,
        
          n
          
            r
          
        
        )
      
    
    {\displaystyle (n_{1},n_{2},\ldots ,n_{r})}
  
.
 The following is an example of a basic Weyr matrix.
 
  
    
      
        W
        =
      
    
    {\displaystyle W=}
  



  
    
      
        =
        
          
            [
            
              
                
                  
                    W
                    
                      11
                    
                  
                
                
                  
                    W
                    
                      12
                    
                  
                
                
                
              
              
                
                
                  
                    W
                    
                      22
                    
                  
                
                
                  
                    W
                    
                      23
                    
                  
                
                
              
              
                
                
                
                  
                    W
                    
                      33
                    
                  
                
                
                  
                    W
                    
                      34
                    
                  
                
              
              
                
                
                
                
                  
                    W
                    
                      44
                    
                  
                
              
            
            ]
          
        
      
    
    {\displaystyle ={\begin{bmatrix}W_{11}&W_{12}&&\\&W_{22}&W_{23}&\\&&W_{33}&W_{34}\\&&&W_{44}\\\end{bmatrix}}}
  

 In this matrix, 
  
    
      
        n
        =
        9
      
    
    {\displaystyle n=9}
  
 and 
  
    
      
        
          n
          
            1
          
        
        =
        4
        ,
        
          n
          
            2
          
        
        =
        2
        ,
        
          n
          
            3
          
        
        =
        2
        ,
        
          n
          
            4
          
        
        =
        1
      
    
    {\displaystyle n_{1}=4,n_{2}=2,n_{3}=2,n_{4}=1}
  
. So 
  
    
      
        W
      
    
    {\displaystyle W}
  
 has the Weyr structure 
  
    
      
        (
        4
        ,
        2
        ,
        2
        ,
        1
        )
      
    
    {\displaystyle (4,2,2,1)}
  
. Also,
 
  
    
      
        
          W
          
            11
          
        
        =
        
          
            [
            
              
                
                  λ
                
                
                  0
                
                
                  0
                
                
                  0
                
              
              
                
                  0
                
                
                  λ
                
                
                  0
                
                
                  0
                
              
              
                
                  0
                
                
                  0
                
                
                  λ
                
                
                  0
                
              
              
                
                  0
                
                
                  0
                
                
                  0
                
                
                  λ
                
              
            
            ]
          
        
        =
        λ
        
          I
          
            4
          
        
        ,
        
        
          W
          
            22
          
        
        =
        
          
            [
            
              
                
                  λ
                
                
                  0
                
              
              
                
                  0
                
                
                  λ
                
                
              
            
            ]
          
        
        =
        λ
        
          I
          
            2
          
        
        ,
        
        
          W
          
            33
          
        
        =
        
          
            [
            
              
                
                  λ
                
                
                  0
                
              
              
                
                  0
                
                
                  λ
                
                
              
            
            ]
          
        
        =
        λ
        
          I
          
            2
          
        
        ,
        
        
          W
          
            44
          
        
        =
        
          
            [
            
              
                
                  λ
                
              
            
            ]
          
        
        =
        λ
        
          I
          
            1
          
        
      
    
    {\displaystyle W_{11}={\begin{bmatrix}\lambda &0&0&0\\0&\lambda &0&0\\0&0&\lambda &0\\0&0&0&\lambda \\\end{bmatrix}}=\lambda I_{4},\quad W_{22}={\begin{bmatrix}\lambda &0\\0&\lambda &\\\end{bmatrix}}=\lambda I_{2},\quad W_{33}={\begin{bmatrix}\lambda &0\\0&\lambda &\\\end{bmatrix}}=\lambda I_{2},\quad W_{44}={\begin{bmatrix}\lambda \\\end{bmatrix}}=\lambda I_{1}}
  

 and
 
  
    
      
        
          W
          
            12
          
        
        =
        
          
            [
            
              
                
                  1
                
                
                  0
                
              
              
                
                  0
                
                
                  1
                
              
              
                
                  0
                
                
                  0
                
              
              
                
                  0
                
                
                  0
                
              
            
            ]
          
        
        ,
        
        
          W
          
            23
          
        
        =
        
          
            [
            
              
                
                  1
                
                
                  0
                
              
              
                
                  0
                
                
                  1
                
              
            
            ]
          
        
        ,
        
        
          W
          
            34
          
        
        =
        
          
            [
            
              
                
                  1
                
              
              
                
                  0
                
              
            
            ]
          
        
        .
      
    
    {\displaystyle W_{12}={\begin{bmatrix}1&0\\0&1\\0&0\\0&0\\\end{bmatrix}},\quad W_{23}={\begin{bmatrix}1&0\\0&1\\\end{bmatrix}},\quad W_{34}={\begin{bmatrix}1\\0\\\end{bmatrix}}.}
  

 Let 
  
    
      
        W
      
    
    {\displaystyle W}
  
  be a square matrix and let 
  
    
      
        
          λ
          
            1
          
        
        ,
        …
        ,
        
          λ
          
            k
          
        
      
    
    {\displaystyle \lambda _{1},\ldots ,\lambda _{k}}
  
 be the distinct eigenvalues of 
  
    
      
        W
      
    
    {\displaystyle W}
  
. We say that 
  
    
      
        W
      
    
    {\displaystyle W}
  
 is in Weyr form (or is a Weyr matrix) if 
  
    
      
        W
      
    
    {\displaystyle W}
  
  has the following form:
 
  
    
      
        W
        =
        
          
            [
            
              
                
                  
                    W
                    
                      1
                    
                  
                
                
                
                
              
              
                
                
                  
                    W
                    
                      2
                    
                  
                
                
                
              
              
                
                
                
                  ⋱
                
                
              
              
                
                
                
                
                  
                    W
                    
                      k
                    
                  
                
              
            
            ]
          
        
      
    
    {\displaystyle W={\begin{bmatrix}W_{1}&&&\\&W_{2}&&\\&&\ddots &\\&&&W_{k}\\\end{bmatrix}}}
  

 where   
  
    
      
        
          W
          
            i
          
        
      
    
    {\displaystyle W_{i}}
  
  is a basic Weyr matrix with eigenvalue 
  
    
      
        
          λ
          
            i
          
        
      
    
    {\displaystyle \lambda _{i}}
  
 for 
  
    
      
        i
        =
        1
        ,
        …
        ,
        k
      
    
    {\displaystyle i=1,\ldots ,k}
  
.
 The following image shows an example of a general Weyr matrix consisting of three basic Weyr matrix blocks. The basic Weyr matrix in the top-left corner has the structure (4,2,1) with eigenvalue 4, the middle block has structure (2,2,1,1) with eigenvalue -3 and the one in the lower-right corner has the structure (3, 2) with eigenvalue 0.
 The Weyr canonical form 
  
    
      
        W
        =
        
          P
          
            −
            1
          
        
        J
        P
      
    
    {\displaystyle W=P^{-1}JP}
  
 is related to the Jordan form 
  
    
      
        J
      
    
    {\displaystyle J}
  
 by a simple permutation 
  
    
      
        P
      
    
    {\displaystyle P}
  
 for each Weyr basic block as follows: The first index of each Weyr subblock forms the largest Jordan chain.  After crossing out these rows and columns, the first index of each new subblock forms the second largest Jordan chain, and so forth.
 That the Weyr form is a canonical form of a matrix is a consequence of the following result: Each square matrix 
  
    
      
        A
      
    
    {\displaystyle A}
  
 over an algebraically closed field is similar to a Weyr matrix 
  
    
      
        W
      
    
    {\displaystyle W}
  
 which is unique up to permutation of its basic blocks. The matrix 
  
    
      
        W
      
    
    {\displaystyle W}
  
 is called the Weyr (canonical) form of 
  
    
      
        A
      
    
    {\displaystyle A}
  
.
 Let 
  
    
      
        A
      
    
    {\displaystyle A}
  
 be a square matrix of order 
  
    
      
        n
      
    
    {\displaystyle n}
  
 over an algebraically closed field and let the distinct eigenvalues of 
  
    
      
        A
      
    
    {\displaystyle A}
  
 be 
  
    
      
        
          λ
          
            1
          
        
        ,
        
          λ
          
            2
          
        
        ,
        …
        ,
        
          λ
          
            k
          
        
      
    
    {\displaystyle \lambda _{1},\lambda _{2},\ldots ,\lambda _{k}}
  
. The Jordan–Chevalley decomposition theorem states that 
  
    
      
        A
      
    
    {\displaystyle A}
  
 is similar to a block diagonal matrix of the form
 
  
    
      
        A
        =
        
          
            [
            
              
                
                  
                    λ
                    
                      1
                    
                  
                  I
                  +
                  
                    N
                    
                      1
                    
                  
                
                
                
                
              
              
                
                
                  
                    λ
                    
                      2
                    
                  
                  I
                  +
                  
                    N
                    
                      2
                    
                  
                
                
                
              
              
                
                
                
                  ⋱
                
                
              
              
                
                
                
                
                  
                    λ
                    
                      k
                    
                  
                  I
                  +
                  
                    N
                    
                      k
                    
                  
                
              
            
            ]
          
        
        =
        
          
            [
            
              
                
                  
                    λ
                    
                      1
                    
                  
                  I
                
                
                
                
              
              
                
                
                  
                    λ
                    
                      2
                    
                  
                  I
                
                
                
              
              
                
                
                
                  ⋱
                
                
              
              
                
                
                
                
                  
                    λ
                    
                      k
                    
                  
                  I
                
              
            
            ]
          
        
        +
        
          
            [
            
              
                
                  
                    N
                    
                      1
                    
                  
                
                
                
                
              
              
                
                
                  
                    N
                    
                      2
                    
                  
                
                
                
              
              
                
                
                
                  ⋱
                
                
              
              
                
                
                
                
                  
                    N
                    
                      k
                    
                  
                
              
            
            ]
          
        
        =
        D
        +
        N
      
    
    {\displaystyle A={\begin{bmatrix}\lambda _{1}I+N_{1}&&&\\&\lambda _{2}I+N_{2}&&\\&&\ddots &\\&&&\lambda _{k}I+N_{k}\\\end{bmatrix}}={\begin{bmatrix}\lambda _{1}I&&&\\&\lambda _{2}I&&\\&&\ddots &\\&&&\lambda _{k}I\\\end{bmatrix}}+{\begin{bmatrix}N_{1}&&&\\&N_{2}&&\\&&\ddots &\\&&&N_{k}\\\end{bmatrix}}=D+N}
  

 where 
  
    
      
        D
      
    
    {\displaystyle D}
  
 is a diagonal matrix, 
  
    
      
        N
      
    
    {\displaystyle N}
  
 is a nilpotent matrix, and 
  
    
      
        [
        D
        ,
        N
        ]
        =
        0
      
    
    {\displaystyle [D,N]=0}
  
, justifying the reduction of 
  
    
      
        N
      
    
    {\displaystyle N}
  
 into subblocks 
  
    
      
        
          N
          
            i
          
        
      
    
    {\displaystyle N_{i}}
  
. So the problem of reducing 
  
    
      
        A
      
    
    {\displaystyle A}
  
 to the Weyr form reduces to the problem of reducing the nilpotent matrices 
  
    
      
        
          N
          
            i
          
        
      
    
    {\displaystyle N_{i}}
  
 to the Weyr form.  This is leads to the generalized eigenspace decomposition theorem.
 Given a nilpotent square matrix 
  
    
      
        A
      
    
    {\displaystyle A}
  
 of order 
  
    
      
        n
      
    
    {\displaystyle n}
  
 over an algebraically closed field 
  
    
      
        F
      
    
    {\displaystyle F}
  
, the following algorithm produces an invertible matrix 
  
    
      
        C
      
    
    {\displaystyle C}
  
 and a  Weyr matrix 
  
    
      
        W
      
    
    {\displaystyle W}
  
 such that 
  
    
      
        W
        =
        
          C
          
            −
            1
          
        
        A
        C
      
    
    {\displaystyle W=C^{-1}AC}
  
.
 Step 1
 Let 
  
    
      
        
          A
          
            1
          
        
        =
        A
      
    
    {\displaystyle A_{1}=A}
  

 Step 2
 Step 3
 If 
  
    
      
        
          A
          
            2
          
        
      
    
    {\displaystyle A_{2}}
  
 is nonzero, repeat Step 2 on 
  
    
      
        
          A
          
            2
          
        
      
    
    {\displaystyle A_{2}}
  
.
 Step 4
 Continue the processes of Steps 1 and 2 to obtain increasingly smaller square matrices 
  
    
      
        
          A
          
            1
          
        
        ,
        
          A
          
            2
          
        
        ,
        
          A
          
            3
          
        
        ,
        …
      
    
    {\displaystyle A_{1},A_{2},A_{3},\ldots }
  
  and associated invertible matrices 
  
    
      
        
          P
          
            1
          
        
        ,
        
          P
          
            2
          
        
        ,
        
          P
          
            3
          
        
        ,
        …
      
    
    {\displaystyle P_{1},P_{2},P_{3},\ldots }
  
 until the first zero matrix 
  
    
      
        
          A
          
            r
          
        
      
    
    {\displaystyle A_{r}}
  
 is obtained.
 Step 5
 The Weyr structure of 
  
    
      
        A
      
    
    {\displaystyle A}
  
 is 
  
    
      
        (
        
          n
          
            1
          
        
        ,
        
          n
          
            2
          
        
        ,
        …
        ,
        
          n
          
            r
          
        
        )
      
    
    {\displaystyle (n_{1},n_{2},\ldots ,n_{r})}
  
 where 
  
    
      
        
          n
          
            i
          
        
      
    
    {\displaystyle n_{i}}
  
 = nullity
  
    
      
        (
        
          A
          
            i
          
        
        )
      
    
    {\displaystyle (A_{i})}
  
.
 Step 6
 Step 7
 Use elementary row operations to find an invertible matrix 
  
    
      
        
          Y
          
            r
            −
            1
          
        
      
    
    {\displaystyle Y_{r-1}}
  
 of appropriate size such that the product 
  
    
      
        
          Y
          
            r
            −
            1
          
        
        
          X
          
            r
            ,
            r
            −
            1
          
        
      
    
    {\displaystyle Y_{r-1}X_{r,r-1}}
  
 is a matrix of the form 
  
    
      
        
          I
          
            r
            ,
            r
            −
            1
          
        
        =
        
          
            [
            
              
                
                  I
                
              
              
                
                  O
                
              
            
            ]
          
        
      
    
    {\displaystyle I_{r,r-1}={\begin{bmatrix}I\\O\end{bmatrix}}}
  
.
 Step 8
 Set 
  
    
      
        
          Q
          
            1
          
        
        =
      
    
    {\displaystyle Q_{1}=}
  
 diag 
  
    
      
        (
        I
        ,
        I
        ,
        …
        ,
        
          Y
          
            r
            −
            1
          
          
            −
            1
          
        
        ,
        I
        )
      
    
    {\displaystyle (I,I,\ldots ,Y_{r-1}^{-1},I)}
  
 and compute 
  
    
      
        
          Q
          
            1
          
          
            −
            1
          
        
        X
        
          Q
          
            1
          
        
      
    
    {\displaystyle Q_{1}^{-1}XQ_{1}}
  
. In this matrix, the 
  
    
      
        (
        r
        ,
        r
        −
        1
        )
      
    
    {\displaystyle (r,r-1)}
  
-block is 
  
    
      
        
          I
          
            r
            ,
            r
            −
            1
          
        
      
    
    {\displaystyle I_{r,r-1}}
  
.
 Step 9
 Find a matrix 
  
    
      
        
          R
          
            1
          
        
      
    
    {\displaystyle R_{1}}
  
 formed as a product of elementary matrices such that 
  
    
      
        
          R
          
            1
          
          
            −
            1
          
        
        
          Q
          
            1
          
          
            −
            1
          
        
        X
        
          Q
          
            1
          
        
        
          R
          
            1
          
        
      
    
    {\displaystyle R_{1}^{-1}Q_{1}^{-1}XQ_{1}R_{1}}
  
 is  a matrix in which all the blocks above the block 
  
    
      
        
          I
          
            r
            ,
            r
            −
            1
          
        
      
    
    {\displaystyle I_{r,r-1}}
  
 contain only 
  
    
      
        0
      
    
    {\displaystyle 0}
  
's.
 Step 10
 Repeat Steps 8 and 9 on column 
  
    
      
        r
        −
        1
      
    
    {\displaystyle r-1}
  
 converting 
  
    
      
        (
        r
        −
        1
        ,
        r
        −
        2
        )
      
    
    {\displaystyle (r-1,r-2)}
  
-block to 
  
    
      
        
          I
          
            r
            −
            1
            ,
            r
            −
            2
          
        
      
    
    {\displaystyle I_{r-1,r-2}}
  
 via conjugation by some invertible matrix 
  
    
      
        
          Q
          
            2
          
        
      
    
    {\displaystyle Q_{2}}
  
. Use this  block to clear out the blocks above, via conjugation by a product 
  
    
      
        
          R
          
            2
          
        
      
    
    {\displaystyle R_{2}}
  
  of elementary matrices.
 Step 11
 Repeat these processes on 
  
    
      
        r
        −
        2
        ,
        r
        −
        3
        ,
        …
        ,
        3
        ,
        2
      
    
    {\displaystyle r-2,r-3,\ldots ,3,2}
  
 columns, using conjugations by 
  
    
      
        
          Q
          
            3
          
        
        ,
        
          R
          
            3
          
        
        ,
        …
        ,
        
          Q
          
            r
            −
            2
          
        
        ,
        
          R
          
            r
            −
            2
          
        
        ,
        
          Q
          
            r
            −
            1
          
        
      
    
    {\displaystyle Q_{3},R_{3},\ldots ,Q_{r-2},R_{r-2},Q_{r-1}}
  
. The resulting matrix 
  
    
      
        W
      
    
    {\displaystyle W}
  
 is now in Weyr form.
 Step 12
 Let    
  
    
      
        C
        =
        
          P
          
            1
          
        
        
          diag
        
        (
        I
        ,
        
          P
          
            2
          
        
        )
        ⋯
        
          diag
        
        (
        I
        ,
        
          P
          
            r
            −
            1
          
        
        )
        
          Q
          
            1
          
        
        
          R
          
            1
          
        
        
          Q
          
            2
          
        
        ⋯
        
          R
          
            r
            −
            2
          
        
        
          Q
          
            r
            −
            1
          
        
      
    
    {\displaystyle C=P_{1}{\text{diag}}(I,P_{2})\cdots {\text{diag}}(I,P_{r-1})Q_{1}R_{1}Q_{2}\cdots R_{r-2}Q_{r-1}}
  
.     Then 
  
    
      
        W
        =
        
          C
          
            −
            1
          
        
        A
        C
      
    
    {\displaystyle W=C^{-1}AC}
  
.
 Some well-known applications of the Weyr form are listed below: