A quaternionic matrix is a matrix whose elements are quaternions.
The quaternions form a noncommutative ring, and therefore addition and multiplication can be defined for quaternionic matrices as for matrices over any ring.
Addition. The sum of two quaternionic matrices A and B is defined in the usual way by element-wise addition:
(A+B)ij=Aij+Bij.
Multiplication. The product of two quaternionic matrices A and B also follows the usual definition for matrix multiplication. For it to be defined, the number of columns of A must equal the number of rows of B. Then the entry in the ith row and jth column of the product is the dot product of the ith row of the first matrix with the jth column of the second matrix. Specifically:
(AB)ij=\sumsAisBsj.
U= \begin{pmatrix} u11&u12\\ u21&u22\\ \end{pmatrix}, V= \begin{pmatrix}v11&v12\\ v21&v22\\ \end{pmatrix},
UV= \begin{pmatrix} u11v11+u12v21&u11v12+u12v22\\ u21v11+u22v21&u21v12+u22v22\\ \end{pmatrix}.
The identity for this multiplication is, as expected, the diagonal matrix I = diag(1, 1, ..., 1). Multiplication follows the usual laws of associativity and distributivity. The trace of a matrix is defined as the sum of the diagonal elements, but in general
\operatorname{trace}(AB)\ne\operatorname{trace}(BA).
Left scalar multiplication, and right scalar multiplication are defined by
(cA)ij=cAij, (Ac)ij=Aijc.
There is no natural way to define a determinant for (square) quaternionic matrices so that the values of the determinant are quaternions.[2] Complex valued determinants can be defined however.[3] The quaternion a + bi + cj + dk can be represented as the 2×2 complex matrix
\begin{bmatrix}~~a+bi&c+di\ -c+di&a-bi\end{bmatrix}.
Quaternionic matrices are used in quantum mechanics[4] and in the treatment of multibody problems.[5]