---
title: Matrix and Quaternion Groups
module: Groups and Symmetry
moduleNumber: 2
lessonNumber: 3
order: 203
summary: >
  Invertible matrices over a field form the general linear group GL_n(F), with
  the determinant-one matrices as the subgroup SL_n(F). Over a finite field the
  order of GL_n(F) has a clean product formula. The quaternion group Q_8 is a
  second small nonabelian group, distinct from the dihedral group of the same
  order; its multiplication and subgroup structure sharpen the contrast between
  the two.
topics: [Groups and Symmetry]
sources:
  - book: Dummit & Foote
    ref: "Ch. 1 — Introduction to Groups; §1.4 Matrix Groups, §1.5 The Quaternion Group"
  - book: Judson
    ref: "Ch. 12 — Matrix Groups and Symmetry; §12.1 Matrix Groups"
draft: false
---

The [dihedral and symmetric groups](/abstract-algebra/groups-and-symmetry/dihedral-and-symmetric-groups)
come from geometry and combinatorics. A third source is linear algebra: the
invertible matrices over a field form a group under multiplication, and their
subgroups supply many of the standard examples of infinite and finite
noncommutative groups. Alongside them sits a small exceptional group, the
quaternion group $Q_8$, which has order $8$ like the dihedral group $D_8$ but is
structurally different — a difference that a subgroup diagram makes visible.

## Fields, in brief

Matrix entries are drawn from a field. A full treatment waits for
[field theory](/abstract-algebra/field-theory/field-extensions-and-algebraic-elements);
here only the definition is needed.

> **Definition (Field).** A **field** is a set $F$ with two operations $+$ and
> $\cdot$ such that $(F, +)$ is an abelian group with identity $0$,
> $(F \setminus \{0\}, \cdot)$ is an abelian group with identity $1$, and
> multiplication distributes over addition:
> $a \cdot (b + c) = a \cdot b + a \cdot c$ for all $a, b, c \in F$.

A field is the smallest setting in which $+$, $-$, $\times$, and division by
nonzero elements all make sense. The examples for now are $\mathbb{Q}$,
$\mathbb{R}$, and $\mathbb{F}_p = \mathbb{Z}/p\mathbb{Z}$ for a prime $p$ — the
last a finite field, whose additive and multiplicative structure was assembled in
[modular arithmetic](/abstract-algebra/foundations/integers-and-modular-arithmetic).
Write $F^\times = F \setminus \{0\}$ for the multiplicative group of a field.

## The general linear group

> **Definition (General linear group).** For a field $F$ and $n \ge 1$, the
> **general linear group** $\mathrm{GL}_n(F)$ is the set of $n \times n$ matrices
> with entries in $F$ and nonzero determinant, under matrix multiplication.

Three facts from linear algebra, valid over any field with the same formulas as
over $\mathbb{R}$, make this a group.[^df-mat]

- **Closure.** The determinant is multiplicative, $\det(AB) = \det(A)\det(B)$, so
  if $\det A \ne 0$ and $\det B \ne 0$ then $\det(AB) \ne 0$.
- **Associativity.** Matrix multiplication is associative.
- **Inverses.** A square matrix is invertible if and only if its determinant is
  nonzero, and the inverse (by the adjugate formula) again has entries in $F$ and
  nonzero determinant, so $A^{-1} \in \mathrm{GL}_n(F)$.

The identity is the identity matrix $I$. The group is nonabelian for every
$n \ge 2$, since matrix products generally depend on order.

### Determinant one: the special linear group

The determinant is itself a multiplicative map $\mathrm{GL}_n(F) \to F^\times$, and
the matrices it sends to $1$ form a distinguished subgroup.

> **Definition (Special linear group).** The **special linear group**
> $\mathrm{SL}_n(F)$ is the set of matrices in $\mathrm{GL}_n(F)$ with determinant
> $1$. It is closed under products and inverses because $\det(AB) = \det A \det B$
> and $\det(A^{-1}) = (\det A)^{-1}$.

The description "matrices the determinant sends to $1$" says that
$\mathrm{SL}_n(F)$ is the kernel of the determinant, viewed as a
[homomorphism](/abstract-algebra/groups-and-symmetry/homomorphisms-and-group-actions)
$\det : \mathrm{GL}_n(F) \to F^\times$. Kernels of homomorphisms are subgroups
automatically, which is a cleaner reason for the closure than checking products
by hand; the general theory is developed in the
[isomorphism theorems](/abstract-algebra/subgroups-and-quotients/isomorphism-theorems).

Geometrically, over $\mathbb{R}$ the group $\mathrm{SL}_n(\mathbb{R})$ consists of
the linear maps that preserve signed volume: $\mathrm{SL}_2(\mathbb{R})$ preserves
the area of every parallelogram, and $\mathrm{SL}_3(\mathbb{R})$ the volume of
every parallelepiped.[^judson-mat] A general element of $\mathrm{GL}_n(\mathbb{R})$
distorts the grid and rescales area by the factor $\det A$; the special linear
subgroup consists of the shears and rotations that leave the scale alone.

### Orthogonal groups

A second subgroup of $\mathrm{GL}_n(\mathbb{R})$ collects the length-preserving
maps.

> **Definition (Orthogonal group).** The **orthogonal group** $O(n)$ is the set of
> real $n \times n$ matrices $A$ with $A^{-1} = A^{\mathsf{T}}$. Equivalently, the
> columns of $A$ form an orthonormal basis, so $A$ preserves lengths and angles.

From $A^{\mathsf{T}}A = I$ and multiplicativity, $\det(A)^2 = 1$, so every
orthogonal matrix has determinant $\pm 1$.[^judson-mat] The determinant-one
elements $SO(n) = O(n) \cap \mathrm{SL}_n(\mathbb{R})$ are the **rotations**; in
the plane, $SO(2)$ is the circle of rotation matrices, and the full $O(2)$ adds
the reflections. The dihedral group appears here concretely: $D_{2n}$ is the
finite subgroup of $O(2)$ generated by rotation through $2\pi/n$ and one
reflection, matching the geometric definition from
[the dihedral group](/abstract-algebra/groups-and-symmetry/dihedral-and-symmetric-groups).

$$
% caption: A matrix in the general linear group carries the unit grid to a
% skewed grid; the determinant is the area of the image of one unit cell, so a
% special-linear matrix shears the grid without changing that area.
\begin{tikzpicture}[font=\small, >=stealth]
  \definecolor{acc}{HTML}{2A6F97}
  % original unit grid (left)
  \begin{scope}[shift={(-4.4,-1.4)}]
    \draw[black, step=0.9] (0,0) grid (2.7,2.7);
    \fill[acc!12] (0,0) rectangle (0.9,0.9);
    \draw[acc, thick] (0,0) rectangle (0.9,0.9);
    \node[font=\footnotesize, anchor=north] at (1.35,-0.15) {unit grid};
  \end{scope}
  \draw[->, acc, very thick] (-1.1,0) -- (0.3,0) node[midway, above, font=\footnotesize] {$A$};
  % sheared grid (right): shear (x,y) -> (x + 0.5y, y)
  \begin{scope}[shift={(1.0,-1.4)}]
    \foreach \k in {0,1,2,3} {
      \draw[black] (0.9*\k,0) -- ($(0.9*\k,0)+(1.35,2.7)$);
      \draw[black] (0.45*\k,0.9*\k) -- ($(0.45*\k,0.9*\k)+(2.7,0)$);
    }
    \fill[acc!12] (0,0) -- (0.9,0) -- (1.35,0.9) -- (0.45,0.9) -- cycle;
    \draw[acc, thick] (0,0) -- (0.9,0) -- (1.35,0.9) -- (0.45,0.9) -- cycle;
    \node[font=\footnotesize, anchor=north] at (1.35,-0.15) {sheared, same area};
  \end{scope}
\end{tikzpicture}
$$

### Order over a finite field

When $F$ is finite the general linear group is finite, and its order counts the
ordered bases of $F^n$.

> **Theorem (Order of $\mathrm{GL}_n$ over a finite field).** If $|F| = q$, then
> $$|\mathrm{GL}_n(F)| = (q^n - 1)(q^n - q)(q^n - q^2)\cdots(q^n - q^{n-1}).$$

**Idea.** An invertible matrix is a choice of $n$ linearly independent columns.
The first column is any nonzero vector: $q^n - 1$ choices. The second is any
vector outside the line spanned by the first: $q^n - q$ choices. The $k$-th is any
vector outside the $(k{-}1)$-dimensional span already chosen: $q^n - q^{k-1}$
choices. Multiplying gives the formula.[^df-mat] Two small cases:

- **$q = 2, n = 2$.** $|\mathrm{GL}_2(\mathbb{F}_2)| = (2^2 - 1)(2^2 - 2) = 3 \cdot 2 = 6$,
  and indeed $\mathrm{GL}_2(\mathbb{F}_2) \cong S_3$, the smallest nonabelian group —
  the six invertible $2 \times 2$ matrices over $\mathbb{F}_2$ permute the three
  nonzero vectors of $\mathbb{F}_2^2$.
- **$q = 3, n = 2$.** $|\mathrm{GL}_2(\mathbb{F}_3)| = (9 - 1)(9 - 3) = 8 \cdot 6 = 48$,
  of which the determinant-one matrices number $|\mathrm{SL}_2(\mathbb{F}_3)| = 48 / |{\mathbb{F}_3^\times}| = 48/2 = 24$,
  since $\det$ maps onto $\mathbb{F}_3^\times = \{1, 2\}$ with each fiber the same size.

> **Worked example.** Over $\mathbb{F}_3$, take
>
> $$
> A = \begin{pmatrix} 1 & 1 \\ 0 & 1 \end{pmatrix}, \qquad
> B = \begin{pmatrix} 2 & 0 \\ 1 & 2 \end{pmatrix}.
> $$
>
> Then $\det A = 1$ and $\det B = 4 \equiv 1$, so both lie in
> $\mathrm{SL}_2(\mathbb{F}_3)$. Their product, reduced mod $3$, is
>
> $$
> AB = \begin{pmatrix} 3 & 2 \\ 1 & 2 \end{pmatrix} = \begin{pmatrix} 0 & 2 \\ 1 & 2 \end{pmatrix},
> \qquad \det(AB) = 0 \cdot 2 - 2 \cdot 1 = -2 \equiv 1,
> $$
>
> matching $\det A \, \det B = 1$. The inverse of $A$ is
>
> $$
> A^{-1} = \begin{pmatrix} 1 & -1 \\ 0 & 1 \end{pmatrix} = \begin{pmatrix} 1 & 2 \\ 0 & 1 \end{pmatrix} \pmod 3,
> $$
>
> and the whole group has $|\mathrm{GL}_2(\mathbb{F}_3)| = (9-1)(9-3) = 48$ with
> $|\mathrm{SL}_2(\mathbb{F}_3)| = 48/2 = 24$.

## The quaternion group

The second small nonabelian group is not a matrix group by definition, though it
embeds in one. It is given by an explicit table.

> **Definition (Quaternion group).** The **quaternion group** is the set
> $$Q_8 = \{1,\ -1,\ i,\ -i,\ j,\ -j,\ k,\ -k\}$$
> of order $8$, with multiplication determined by
> $$i^2 = j^2 = k^2 = -1, \qquad ij = k,\ jk = i,\ ki = j,$$
> together with $(-1)^2 = 1$ and $(-1)$ central. It is nonabelian, since
> $ji = -k \ne k = ij$.

The three imaginary units cycle $i \to j \to k \to i$ under multiplication when
taken in order, and reverse to a sign change when taken backward:
$ji = -k$, $kj = -i$, $ik = -j$. The element $-1$ commutes with everything and is
the unique element of order $2$; the six elements $\pm i, \pm j, \pm k$ all have
order $4$.

Like the dihedral group, $Q_8$ is generated by two elements with a short list of
relations. Taking $i$ and $j$ as generators,

$$
Q_8 = \langle\, i, j \mid i^4 = 1,\ i^2 = j^2,\ j i j^{-1} = i^{-1} \,\rangle,
$$

with $k = ij$ and $-1 = i^2$ recovered from the generators.[^df-mat] The relation
$jij^{-1} = i^{-1}$ mirrors the dihedral $sr s^{-1} = r^{-1}$, so the two groups
of order $8$ are built from similar-looking presentations; the difference is the
single extra relation $i^2 = j^2$, which forces $j^2 \ne 1$ and thereby removes
all the order-$2$ reflections that $D_8$ has.

$$
% caption: The multiplication of the three imaginary units, magnitudes shown in
% each cell; a shaded cell marks a product carrying a sign flip, so reading a row
% forward gives a plus and reading it backward gives a minus.
\begin{tikzpicture}[font=\small, x=13mm, y=13mm]
  \definecolor{acc}{HTML}{2A6F97}
  \foreach \v [count=\c from 1] in {i,j,k} {
    \node[acc] at (\c+0.5,-0.5) {$\v$};
    \node[acc] at (0.5,-\c-0.5) {$\v$};
  }
  % row/col = i,j,k ; entry is the magnitude, shaded when the product is negative
  \foreach \r/\c/\mag/\neg in {
    1/1/1/1, 1/2/k/0, 1/3/j/1,
    2/1/k/1, 2/2/1/1, 2/3/i/0,
    3/1/j/0, 3/2/i/1, 3/3/1/1} {
    \ifnum\neg=1 \fill[acc!16] (\c,-\r) rectangle (\c+1,-\r-1); \fi
    \node at (\c+0.5,-\r-0.5) {$\mag$};
  }
  \draw (0,0) grid (4,-4);
  \draw[acc, thick] (0,0) rectangle (4,-1);
  \draw[acc, thick] (0,0) rectangle (1,-4);
  \node[font=\footnotesize, anchor=west] at (4.5,-1.3) {shaded cell:};
  \node[font=\footnotesize, anchor=west] at (4.5,-2.1) {product is negative};
\end{tikzpicture}
$$

### Cyclic subgroups and orders

Each imaginary unit generates a copy of the cyclic group of order $4$. Following
the powers of $i$, for instance, gives a four-step loop that visits $1$, $i$, the
central element $i^2$, and $i^3$, returning to $1$.

$$
% caption: The powers of i close into a four-cycle; the halfway element i-squared
% is the central sign flip, the unique element of order two, and every imaginary
% unit generates such a cycle sharing that midpoint.
\begin{tikzpicture}[font=\small, >=stealth,
  v/.style={circle, draw, minimum size=10mm, inner sep=0pt}]
  \definecolor{acc}{HTML}{2A6F97}
  \node[v, draw=acc, text=acc] (p0) at (90:1.9)  {$i^{0}$};
  \node[v] (p1) at (0:1.9)   {$i^{1}$};
  \node[v] (p2) at (-90:1.9) {$i^{2}$};
  \node[v] (p3) at (180:1.9) {$i^{3}$};
  \foreach \a/\b in {p0/p1, p1/p2, p2/p3, p3/p0}
    \draw[->, acc, thick] (\a) to[bend left=16] (\b);
  \node[align=center, font=\footnotesize] at (0,0) {multiply\\ by $i$};
  \node[font=\footnotesize, anchor=west] at (2.6,-1.9) {$i^{0} = 1$, and $i^{2}$ is central};
\end{tikzpicture}
$$

> **Worked example.** In $Q_8$, the product $ij = k$ satisfies
> $(ij)^2 = k^2 = -1$, so $|ij| = 4$; every imaginary unit has order $4$, while
> $-1$ is the only element of order $2$. The conjugation relation matching the
> dihedral $srs^{-1} = r^{-1}$ comes out by direct multiplication, using
> $j^{-1} = -j$ (from $j^2 = -1$):
>
> $$
> j\, i\, j^{-1} = j\, i\, (-j) = -(ji)\,j = -(-k)\,j = k j = -i = i^{-1}.
> $$

Both $Q_8$ and $D_8$ have order $8$ and are nonabelian, yet they are not
[isomorphic](/abstract-algebra/groups-and-symmetry/homomorphisms-and-group-actions).
The cleanest distinction is in their elements of order $2$: the dihedral group
$D_8$ has five (the central rotation by a half-turn and four reflections), while
$Q_8$ has exactly one (the central element $-1$). Every subgroup of $Q_8$ except
the trivial one therefore contains $-1$, so the subgroup diagram of $Q_8$ funnels
down to a single point above the bottom, whereas $D_8$ fans out into several
minimal subgroups.

$$
% caption: Subgroup diagrams of the two nonabelian groups of order eight; each
% order-four node is the cyclic subgroup generated by that element, and the
% quaternion group narrows to one minimal subgroup while the dihedral group fans
% into several.
\begin{tikzpicture}[font=\small, >=stealth,
  n/.style={draw, minimum size=6mm, inner sep=1.5pt}]
  \definecolor{acc}{HTML}{2A6F97}
  % --- Q_8 (left) ---
  \node[n, draw=acc] (qt) at (-4,3)   {$Q_8$};
  \node[n] (qi) at (-5.4,1.6) {$i$};
  \node[n] (qj) at (-4,1.6)   {$j$};
  \node[n] (qk) at (-2.6,1.6) {$k$};
  \node[n, draw=acc] (qz) at (-4,0.2) {$Z$};
  \node[n] (qb) at (-4,-1.2)  {$1$};
  \foreach \m in {qi,qj,qk} { \draw[black] (qt) -- (\m); \draw[black] (\m) -- (qz); }
  \draw[black] (qz) -- (qb);
  \node[font=\footnotesize, text=black] at (-4,-1.9) {1 minimal subgroup};
  % --- D_8 (right) ---
  \node[n, draw=acc] (dt) at (3,3)    {$D_8$};
  \node[n] (dr) at (1.4,1.7)  {$R$};
  \node[n] (dv) at (3,1.7)    {$V$};
  \node[n] (dw) at (4.6,1.7)  {$W$};
  \node[n] (m1) at (0.8,0.3)  {$a$};
  \node[n] (m2) at (2.0,0.3)  {$b$};
  \node[n] (m3) at (3.0,0.3)  {$z$};
  \node[n] (m4) at (4.0,0.3)  {$c$};
  \node[n] (m5) at (5.2,0.3)  {$d$};
  \node[n] (db) at (3,-1.2)   {$1$};
  \foreach \m in {dr,dv,dw} \draw[black] (dt) -- (\m);
  \draw[black] (dr) -- (m3);
  \draw[black] (dv) -- (m1); \draw[black] (dv) -- (m3);
  \draw[black] (dw) -- (m5); \draw[black] (dw) -- (m3);
  \draw[black] (dv) -- (m2); \draw[black] (dw) -- (m4);
  \foreach \m in {m1,m2,m3,m4,m5} \draw[black] (\m) -- (db);
  \node[font=\footnotesize, text=black] at (3,-1.9) {5 minimal subgroups};
\end{tikzpicture}
$$

Both groups embed in matrix groups, which is where the "matrix" and "quaternion"
threads rejoin. The dihedral group $D_{2n}$ sits inside
$\mathrm{GL}_2(\mathbb{R})$ as the rotation and reflection matrices of the
$n$-gon, and $Q_8$ sits inside $\mathrm{GL}_2(\mathbb{C})$ under the map

$$
i \mapsto \begin{pmatrix} \sqrt{-1} & 0 \\ 0 & -\sqrt{-1} \end{pmatrix}, \qquad
j \mapsto \begin{pmatrix} 0 & 1 \\ -1 & 0 \end{pmatrix}.
$$

Every group can be realized this way — as symmetries of some structure or as
matrices acting on a space — through
[homomorphisms and group actions](/abstract-algebra/groups-and-symmetry/homomorphisms-and-group-actions)
and, in the extreme, [Cayley's theorem](/abstract-algebra/group-actions-and-sylow/actions-and-cayleys-theorem).

| | $D_8$ | $Q_8$ |
| --- | --- | --- |
| Order | $8$ | $8$ |
| Elements of order $2$ | $5$ | $1$ |
| Elements of order $4$ | $2$ | $6$ |
| Center | order $2$ | order $2$ |
| Minimal subgroups | $5$ | $1$ |
| Realized in | $\mathrm{GL}_2(\mathbb{R})$ | $\mathrm{GL}_2(\mathbb{C})$ |

The two tables of order counts differ, so no relabeling can turn one group into
the other. Counting elements of each order is the first and cheapest test for
whether two finite groups are the same.

[^df-mat]: **Dummit & Foote**, _Abstract Algebra_, §1.4 — the general linear group $\mathrm{GL}_n(F)$ over a field, closure via the multiplicativity of the determinant, and the order formula $|\mathrm{GL}_n(F)| = \prod_{k=0}^{n-1}(q^n - q^k)$ when $|F| = q$; and §1.5 for the quaternion group $Q_8$ and its multiplication.
[^judson-mat]: **Judson**, _Abstract Algebra: Theory and Applications_, §12.1 — matrix groups, the special linear group $\mathrm{SL}_n(\mathbb{R})$ as the volume-preserving maps, and the orthogonal group as a further subgroup.
