Tutorials › Linear Algebra › Vector Spaces Over Finite Fields

Linear Algebra Beyond the Reals · Tutorial 967 of 1000

Vector Spaces Over Finite Fields

Use arithmetic modulo a prime to compute in vector spaces of tuples, matrices, and polynomials, and to understand what a span contains.

Intermediate 10 min read

What You'll Learn

  • Explain why the modulus must be prime for the scalars to form a field.
  • Compute scalar multiples and linear combinations in \(\mathbb{F}_p^n\).
  • Verify the vector-space operations for tuples, matrices, and polynomials over \(\mathbb{F}_p\).
  • Express a span using finite-field coefficients and check membership by substitution.
  • Recognize common errors caused by using ordinary integer arithmetic or a non-prime modulus.

Vectors When the Scalars Are Residues

Vector-space calculations do not require real numbers as scalars. For a prime \(p\), the field \(\mathbb{F}_p\) consists of the residue classes modulo \(p\), represented by \(0,1,\dots,p-1\). Addition, subtraction, and multiplication are performed modulo \(p\). For example, in \(\mathbb{F}_5\), \(4+3=2\) and \(2\cdot 3=1\), because \(7\) has remainder \(2\) and \(6\) has remainder \(1\) on division by \(5\). The primality condition matters: every nonzero element of \(\mathbb{F}_p\) has a multiplicative inverse, so the scalars form a field.

A vector in \(\mathbb{F}_p^n\) is a column of \(n\) elements of \(\mathbb{F}_p\). Vector addition and scalar multiplication are performed coordinate by coordinate, always reducing each result modulo \(p\). Thus vectors that look like ordinary integer columns are not being calculated over \(\mathbb{R}\): their entries and coefficients belong to \(\mathbb{F}_p\).

Definition: A vector space over a field \(\mathbb{F}\) is a set \(V\) with vector addition and scalar multiplication satisfying the following rules for all \(\mathbf{u},\mathbf{v},\mathbf{w}\in V\) and \(a,b\in\mathbb{F}\): addition is closed, associative, and commutative; there is a zero vector and each vector has an additive inverse; scalar multiplication is closed; \(a(\mathbf{u}+\mathbf{v})=a\mathbf{u}+a\mathbf{v}\), \((a+b)\mathbf{u}=a\mathbf{u}+b\mathbf{u}\), \(a(b\mathbf{u})=(ab)\mathbf{u}\), and \(1\mathbf{u}=\mathbf{u}\).

These rules have the same form over \(\mathbb{F}_p\) as over \(\mathbb{R}\), but the calculations that verify them take place in the finite field. The zero vector in \(\mathbb{F}_p^n\) has every coordinate equal to \(0\). The additive inverse of a vector is found by taking the additive inverse of each coordinate; for instance, \(-2=3\) in \(\mathbb{F}_5\).

Why Tuples, Matrices, and Polynomials Are Vector Spaces

Theorem: For a prime \(p\), \(\mathbb{F}_p^n\) is a vector space over \(\mathbb{F}_p\) with coordinatewise operations. Matrices of a fixed size over \(\mathbb{F}_p\) also form a vector space over \(\mathbb{F}_p\). The set \(\mathbb{F}_p[x]\) of polynomials with coefficients in \(\mathbb{F}_p\) is a vector space over \(\mathbb{F}_p\) under polynomial addition and coefficientwise scalar multiplication.

Proof. The field operations in \(\mathbb{F}_p\) are closed and obey the field laws. For tuples, adding two \(n\)-coordinate columns or multiplying one by a scalar produces another \(n\)-coordinate column over \(\mathbb{F}_p\). The zero column is an additive identity, and negating each entry gives an additive inverse. Each vector-space identity holds in every coordinate: for example, the \(i\)th coordinate of \(a(\mathbf{u}+\mathbf{v})\) is \(a(u_i+v_i)=au_i+av_i\), which is the \(i\)th coordinate of \(a\mathbf{u}+a\mathbf{v}\). Associativity, commutativity, the scalar addition rule, compatibility of scalar multiplication, and the identity-scalar rule follow coordinate by coordinate from the corresponding field laws. For fixed-size matrices, the same argument applies to each matrix entry, so the zero matrix and entrywise additive inverses supply the required zero and inverses. For polynomials, addition and scalar multiplication act on each coefficient. Sums and scalar multiples of polynomials still have only finitely many nonzero coefficients, and the zero polynomial and coefficientwise negatives supply the additive identity and inverses. Each axiom then holds coefficient by coefficient by the field laws. Therefore all three sets satisfy the vector-space axioms. \(\square\)

For a polynomial, “coefficientwise” means that like powers of \(x\) are combined. It does not mean that the exponent is reduced modulo \(p\). For example, over \(\mathbb{F}_2\), the coefficients \(1+1\) cancel to \(0\), but the term \(x^3\) remains a term of degree \(3\).

Computing Linear Combinations

A linear combination of \(\mathbf{v}_1,\dots,\mathbf{v}_k\) over \(\mathbb{F}_p\) is \(c_1\mathbf{v}_1+\cdots+c_k\mathbf{v}_k\), where each coefficient \(c_i\) is in \(\mathbb{F}_p\). The vector addition and scalar multiplication are those of the space in question. In particular, each coordinate or matrix entry is reduced modulo \(p\) as the calculation proceeds.

Worked Example: A Linear Combination in \(\mathbb{F}_5^2\)

Let \(\mathbf{u}=\begin{bmatrix}1\\2\end{bmatrix}\) and \(\mathbf{v}=\begin{bmatrix}3\\1\end{bmatrix}\) in \(\mathbb{F}_5^2\). Compute \(2\mathbf{u}+4\mathbf{v}\).

First multiply each coordinate by its scalar, reducing modulo \(5\):

$$ 2\mathbf{u} = \begin{bmatrix}2\cdot1\\2\cdot2\end{bmatrix} = \begin{bmatrix}2\\4\end{bmatrix}, \qquad 4\mathbf{v} = \begin{bmatrix}4\cdot3\\4\cdot1\end{bmatrix} = \begin{bmatrix}12\\4\end{bmatrix} = \begin{bmatrix}2\\4\end{bmatrix}. $$

Now add the columns coordinatewise:

$$ 2\mathbf{u}+4\mathbf{v} = \begin{bmatrix}2\\4\end{bmatrix} + \begin{bmatrix}2\\4\end{bmatrix} = \begin{bmatrix}4\\8\end{bmatrix} = \begin{bmatrix}4\\3\end{bmatrix} \quad\text{in }\mathbb{F}_5^2. $$

Check: the first coordinate is \(2+12=14\), whose remainder modulo \(5\) is \(4\); the second is \(4+4=8\), whose remainder is \(3\). Thus the result is \(\begin{bmatrix}4\\3\end{bmatrix}\), with both coordinates reduced.

To form a span, allow all possible coefficients from the field, not just the coefficients \(0\) and \(1\). The resulting collection is a set of vectors in the same vector space.

Definition: For a list \(\mathbf{v}_1,\dots,\mathbf{v}_k\) in a vector space over \(\mathbb{F}_p\), its span is the set of all finite-field linear combinations: \(\operatorname{span}\{\mathbf{v}_1,\dots,\mathbf{v}_k\}=\{c_1\mathbf{v}_1+\cdots+c_k\mathbf{v}_k:c_1,\dots,c_k\in\mathbb{F}_p\}\).

Worked Example: Checking Membership in a Span

Use the vectors \(\mathbf{u}\) and \(\mathbf{v}\) from the previous example. Show that \(\begin{bmatrix}4\\3\end{bmatrix}\) belongs to \(\operatorname{span}\{\mathbf{u},\mathbf{v}\}\) over \(\mathbb{F}_5\).

Membership means that some coefficients in \(\mathbb{F}_5\) produce the target. Try \(c_1=2\) and \(c_2=4\). The computation is

$$ 2\mathbf{u}+4\mathbf{v} = \begin{bmatrix}2\\4\end{bmatrix} + \begin{bmatrix}2\\4\end{bmatrix} = \begin{bmatrix}4\\8\end{bmatrix} = \begin{bmatrix}4\\3\end{bmatrix}. $$

Both coefficients \(2\) and \(4\) are allowed scalars, and the computed combination equals the target. Therefore \(\begin{bmatrix}4\\3\end{bmatrix}\in\operatorname{span}\{\mathbf{u},\mathbf{v}\}\).

Check: the first coordinate of the combination is \(2\cdot1+4\cdot3=14=4\) in \(\mathbb{F}_5\); the second is \(2\cdot2+4\cdot1=8=3\). Substitution reproduces the target in both coordinates.

Spans Are Closed Under the Vector-Space Operations

Theorem: In a vector space over \(\mathbb{F}_p\), the span of any finite list of vectors is a subspace. Here a subspace means a subset containing the zero vector and closed under addition and scalar multiplication.

Proof. Let \(S=\operatorname{span}\{\mathbf{v}_1,\dots,\mathbf{v}_k\}\). The zero vector belongs to \(S\), since choosing every coefficient to be \(0\) gives \(0\mathbf{v}_1+\cdots+0\mathbf{v}_k=\mathbf{0}\). Take any \(\mathbf{x},\mathbf{y}\in S\). By the definition of span, there are coefficients \(a_1,\dots,a_k,b_1,\dots,b_k\in\mathbb{F}_p\) such that \(\mathbf{x}=\sum_{i=1}^k a_i\mathbf{v}_i\) and \(\mathbf{y}=\sum_{i=1}^k b_i\mathbf{v}_i\). Using the vector-space distributive laws, \(\mathbf{x}+\mathbf{y}=\sum_{i=1}^k(a_i+b_i)\mathbf{v}_i\). Each \(a_i+b_i\) is in \(\mathbb{F}_p\), so this sum belongs to \(S\). Now take any \(c\in\mathbb{F}_p\). Then \(c\mathbf{x}=\sum_{i=1}^k(ca_i)\mathbf{v}_i\), and each \(ca_i\) is in \(\mathbb{F}_p\), so \(c\mathbf{x}\in S\). Thus \(S\) contains zero and is closed under addition and scalar multiplication; it is a subspace. \(\square\)

This result explains why the word “span” is useful: it describes a collection that stays within the same vector space when its elements are added or multiplied by scalars. To establish that one vector belongs to a span, it is enough to exhibit coefficients and verify the resulting combination. To establish that a whole set is the span requires accounting for all possible coefficients, a different task from checking one membership claim.

Finite-Field Operations in Matrices and Polynomials

Worked Example: Combining Matrices over \(\mathbb{F}_3\)

Let \(\mathbf{A}=\begin{bmatrix}1&2\\0&1\end{bmatrix}\) and \(\mathbf{B}=\begin{bmatrix}2&1\\1&0\end{bmatrix}\), with entries in \(\mathbb{F}_3\). Compute \(2\mathbf{A}+\mathbf{B}\).

Multiply each entry of \(\mathbf{A}\) by \(2\), reducing modulo \(3\):

$$ 2\mathbf{A} = \begin{bmatrix}2\cdot1&2\cdot2\\2\cdot0&2\cdot1\end{bmatrix} = \begin{bmatrix}2&4\\0&2\end{bmatrix} = \begin{bmatrix}2&1\\0&2\end{bmatrix}. $$

Add \(\mathbf{B}\) entrywise and reduce each entry:

$$ 2\mathbf{A}+\mathbf{B} = \begin{bmatrix}2&1\\0&2\end{bmatrix} + \begin{bmatrix}2&1\\1&0\end{bmatrix} = \begin{bmatrix}4&2\\1&2\end{bmatrix} = \begin{bmatrix}1&2\\1&2\end{bmatrix}. $$

Check: the entries of \(2\mathbf{A}+\mathbf{B}\), calculated directly, are \(2+2=4=1\), \(4+1=5=2\), \(0+1=1\), and \(2+0=2\), all modulo \(3\). This verifies the displayed matrix entry by entry.

Worked Example: Adding Polynomials over \(\mathbb{F}_2\)

Let \(f(x)=1+x+x^2\) and \(g(x)=1+x^3\), with coefficients in \(\mathbb{F}_2\). Compute \(f(x)+g(x)\).

Match terms with the same power of \(x\), adding their coefficients modulo \(2\):

$$ f(x)+g(x) =(1+1)+x+x^2+x^3 =0+x+x^2+x^3 =x+x^2+x^3. $$

Check: the constant coefficient is \(1+1=0\) in \(\mathbb{F}_2\); the coefficients of \(x\), \(x^2\), and \(x^3\) are respectively \(1+0=1\), \(1+0=1\), and \(0+1=1\). Hence the result has exactly the displayed terms. Also, \(1\cdot f(x)=f(x)\), whereas \(0\cdot f(x)=0\), illustrating that the available scalars are just \(0\) and \(1\).

Common Pitfall: Reducing Only at the End

A frequent error is to leave an answer as though the entries were ordinary integers. For example, over \(\mathbb{F}_5\), a mistaken calculation might write \(3\begin{bmatrix}1\\2\end{bmatrix}=\begin{bmatrix}3\\6\end{bmatrix}\) and conclude that this is the final vector. The correction is to reduce each entry modulo \(5\): \(6=1\), so the scalar multiple is \(\begin{bmatrix}3\\1\end{bmatrix}\). The unreduced column does not use entries in the chosen representative set \(0,1,2,3,4\).

The modulus itself is another essential condition. Modulo \(6\), the nonzero residue \(2\) has no multiplicative inverse: the possible products \(2\cdot0,2\cdot1,\dots,2\cdot5\) have remainders \(0,2,4,0,2,4\), never \(1\). Thus the residues modulo \(6\) do not form a field, and they cannot serve as the scalar field in the vector-space definition used here. For \(\mathbb{F}_p\), keep \(p\) prime, and reduce every coordinate, entry, and coefficient using that same modulus.

Check Your Understanding

Use the indicated finite field in each question, and reduce all results to field elements.

  1. In \(\mathbb{F}_7^2\), compute \(3\begin{bmatrix}2\\5\end{bmatrix}+4\begin{bmatrix}1\\3\end{bmatrix}\).
  2. In \(\mathbb{F}_3\), verify directly that \(2\begin{bmatrix}1&2\\0&1\end{bmatrix}+\begin{bmatrix}2&1\\1&0\end{bmatrix}\) is a matrix over \(\mathbb{F}_3\).
  3. Over \(\mathbb{F}_2\), compute \((1+x^2)+(1+x+x^2)\).
  4. Give coefficients in \(\mathbb{F}_5\) showing that \(\begin{bmatrix}2\\4\end{bmatrix}\) belongs to \(\operatorname{span}\left\{\begin{bmatrix}1\\2\end{bmatrix},\begin{bmatrix}3\\1\end{bmatrix}\right\}\), or explain why none exist.
  5. In one or two sentences, explain why reduction modulo \(6\) does not give a field of scalars.

Test yourself: Linear Algebra final exam practice

Ready to check what you know? Work a full-length practice final, then open the complete worked solutions.

Want all 1,114 practice problems?

This tutorial covers one topic. Calc Pass covers the full Calculus AB & BC curriculum (the core of Calculus I and II): full review, every practice question, and step-by-step solutions to each one.

QR code to download the Calc Pass app

Get the Calc Pass App

Scan to download and practice on the go, with instant scoring.

Calc Pass Volume 1: 1,114 Practice Questions book cover

Vol. 1: 1,114 Questions

The complete practice question bank, organized by AB & BC topic.

View on Amazon
Calc Pass Volume 2: Solutions Manual book cover

Vol. 2: Solutions Manual

Fully worked solutions to every question in Volume 1.

View on Amazon