FiniteField
✖
FiniteField

Details




- Finite fields are also known as Galois fields.
- Finite fields are used in algebraic computation, error-correcting codes, cryptography, combinatorics, algebraic geometry, number theory and finite geometry.
- A field
is an algebraic system with all four arithmetic operations +, -, * and ÷. A finite field
can have
elements
for some prime
and positive integer
.
- The
element
is the additive identity where
for all
and the
element
gives the multiplicative identity where
for all
.
- FiniteFieldElement[,k] or [k] can be used to get the
element
and is formatted as
.
- FiniteFieldElement objects in the same field are automatically combined by arithmetic operations.
- Polynomial operations such as PolynomialGCD, Factor, Expand, PolynomialQuotientRemainder and Resultant can be used for polynomials with coefficients from a finite field. Together and Cancel can be used for rational functions with coefficients from a finite field.
- Linear algebra operations such as Det, Inverse, RowReduce, NullSpace, MatrixRank and LinearSolve can be used for matrices with entries from a finite field.
- Solve and Reduce can be used to solve systems of equations over finite fields.
- There are two different representations rep supported for FiniteField: "Polynomial" and "Exponential".
- The "Polynomial" representation is the analog of a Cartesian representation of complex numbers
, easy to add and subtract but slightly harder to multiply and divide.
- Representation: It uses an irreducible polynomial
of degree d to identify the field with the quotient:
.
- Each element
is represented as a polynomial
. Or you can think of it as a vector
in the basis
.
- Enumeration: The elements are enumerated in reverse lexicographic order:
,
,…,
,…,
- Operations: Let
and
; then you have:
and
- and
is reduced modulo
(PolynomialRemainder) to degree
.
with
.
, and the multiplicative inverse
is computed using the extended polynomial GCD. Since
is irreducible, you have
and hence from the extended polynomial GCD, you have
for some polynomials
and
. By reducing modulo
, you get
and hence you have
.
- The "Exponential" representation is the analog of a polar representation of complex number
, easy to multiply and divide but slightly harder to add and subtract.
- Representation: As in the "Polynomial" representation, it uses an irreducible polynomial
of degree d, but in this case
also needs to be primitive. Since
is primitive, the powers of
represent every element in
except
:
-
- This representation is also known as the cyclic group representation, since
is a cyclic group under multiplication.
- Enumeration: The elements are enumerated using the power order:
,
,
, …,
, …,
- Operations: Let
and
, then you have:
and
- with the inversion
. For addition and subtraction, there is no simple rule that gives
such that
, and so that is stored in a lookup table that is linear in the field size
. This makes the operation fast at the cost of storing data. It also means that the "Exponential" representation is not suitable for large fields.
- The practical difference between representations is:
- "Polynomial" takes no time to create, uses no extra memory, works for large fields but has slightly slower operations.
- "Exponential" takes some time to create, uses extra memory proportional to the size of the field, works for small fields but has slightly faster operations.
- Information[FiniteField[…], prop] gives the property prop of the finite field. The following properties can be specified:
-
"Characteristic" the characteristic p of the finite field "ExtensionDegree" the extension degree d of the finite field over "FieldSize" the number of elements q=pd of the field "FieldIrreducible" the polynomial function f used to construct the field "ElementRepresentation" "Polynomial" or "Exponential"

Examples
open allclose allBasic Examples (2)Summary of the most common use cases

https://wolfram.com/xid/0rsxzoq5a-cej05r


https://wolfram.com/xid/0rsxzoq5a-1sprh


https://wolfram.com/xid/0rsxzoq5a-ixr0ip

Represent a finite field with characteristic and extension degree
:

https://wolfram.com/xid/0rsxzoq5a-o809yt

Specify elements of the field using polynomial coefficients or an index:

https://wolfram.com/xid/0rsxzoq5a-qqwza


https://wolfram.com/xid/0rsxzoq5a-e3kwp9


https://wolfram.com/xid/0rsxzoq5a-t5e2r


https://wolfram.com/xid/0rsxzoq5a-n1gbyc

Scope (13)Survey of the scope of standard use cases
Representation and Properties (4)
Represent a finite field with characteristic and extension degree
:

https://wolfram.com/xid/0rsxzoq5a-o1knw

Find the irreducible polynomial used to construct the field:

https://wolfram.com/xid/0rsxzoq5a-h0kn7v

By default, the polynomial representation of field elements is used:

https://wolfram.com/xid/0rsxzoq5a-bi6qhb

Find other properties of the field:

https://wolfram.com/xid/0rsxzoq5a-klr9jz

Field additive and multiplicative identity elements have indices and
:

https://wolfram.com/xid/0rsxzoq5a-blw0tj


https://wolfram.com/xid/0rsxzoq5a-8j20z

Construct a finite field using a custom irreducible polynomial:

https://wolfram.com/xid/0rsxzoq5a-glm81
Verify that the polynomial is irreducible:

https://wolfram.com/xid/0rsxzoq5a-evpaab


https://wolfram.com/xid/0rsxzoq5a-6f9lb

The field irreducible is equal to the specified polynomial modulo the field characteristic:

https://wolfram.com/xid/0rsxzoq5a-cmfmky

Construct a finite field that uses exponential representation of elements:

https://wolfram.com/xid/0rsxzoq5a-c0fulv

The polynomial used to represent the field is primitive:

https://wolfram.com/xid/0rsxzoq5a-bdzkrk

Field additive and multiplicative identity elements have indices and
:

https://wolfram.com/xid/0rsxzoq5a-bfoaf4


https://wolfram.com/xid/0rsxzoq5a-bo8hr1

All nonzero elements of the field are powers of the element with index :

https://wolfram.com/xid/0rsxzoq5a-e4fh3q


https://wolfram.com/xid/0rsxzoq5a-l8jg5x


https://wolfram.com/xid/0rsxzoq5a-bt01qf


https://wolfram.com/xid/0rsxzoq5a-f9fel7


https://wolfram.com/xid/0rsxzoq5a-fjnizm

Represent a finite field with 49 elements:

https://wolfram.com/xid/0rsxzoq5a-om22g


https://wolfram.com/xid/0rsxzoq5a-frc2g8

Arithmetic (3)
Perform arithmetic operations in a finite field:

https://wolfram.com/xid/0rsxzoq5a-cex154


https://wolfram.com/xid/0rsxzoq5a-hnvetd

Rational powers work only with exponent denominators and
:

https://wolfram.com/xid/0rsxzoq5a-cm48va

For some field elements, the square root may not exist:

https://wolfram.com/xid/0rsxzoq5a-fyosoo

Arithmetic operations treat integers as elements of the field:

https://wolfram.com/xid/0rsxzoq5a-dw7top


https://wolfram.com/xid/0rsxzoq5a-ha5613

Rational numbers need to be valid modulo the field characteristic:

https://wolfram.com/xid/0rsxzoq5a-frjfx0


https://wolfram.com/xid/0rsxzoq5a-bsel1a


Use Element to decide which rational numbers can be identified with field elements:

https://wolfram.com/xid/0rsxzoq5a-cddr7u

For the purpose of comparison, rational numbers are identified with field elements:

https://wolfram.com/xid/0rsxzoq5a-kxt8he


https://wolfram.com/xid/0rsxzoq5a-gp75p

Elements of different finite fields cannot be combined:

https://wolfram.com/xid/0rsxzoq5a-hw3ky8

https://wolfram.com/xid/0rsxzoq5a-cd55qy


Fields with same characteristic and field irreducible but different element representations are allowed:

https://wolfram.com/xid/0rsxzoq5a-mfwtyz

https://wolfram.com/xid/0rsxzoq5a-mqgq

Automorphisms and Embeddings (2)
Compute all conjugates of a finite field element:

https://wolfram.com/xid/0rsxzoq5a-fvhsqh


https://wolfram.com/xid/0rsxzoq5a-eb0jhn

The conjugates are roots of the minimal polynomial of a:

https://wolfram.com/xid/0rsxzoq5a-hgxuae


https://wolfram.com/xid/0rsxzoq5a-b870l6

The Frobenius automorphism maps to
:

https://wolfram.com/xid/0rsxzoq5a-bhhn00

Compute an embedding of one finite field in another:

https://wolfram.com/xid/0rsxzoq5a-go0a9b

Map finite field elements through the embedding:

https://wolfram.com/xid/0rsxzoq5a-p2fdnb

Embeddings preserve arithmetic operations:

https://wolfram.com/xid/0rsxzoq5a-e5bfm

https://wolfram.com/xid/0rsxzoq5a-f25m7h


https://wolfram.com/xid/0rsxzoq5a-oniqqm

Polynomials over Finite Fields (2)
Compute with polynomials over a finite field:

https://wolfram.com/xid/0rsxzoq5a-d7e3ez

https://wolfram.com/xid/0rsxzoq5a-1x4p1


https://wolfram.com/xid/0rsxzoq5a-e6v6pp


https://wolfram.com/xid/0rsxzoq5a-eyz58w


https://wolfram.com/xid/0rsxzoq5a-b5icsl

Compute quotient and remainder:

https://wolfram.com/xid/0rsxzoq5a-cnv7e0


https://wolfram.com/xid/0rsxzoq5a-j54s8u


https://wolfram.com/xid/0rsxzoq5a-cby308


https://wolfram.com/xid/0rsxzoq5a-bpbnqn

Compute with multivariate polynomials:

https://wolfram.com/xid/0rsxzoq5a-oaid0t


https://wolfram.com/xid/0rsxzoq5a-e605y9


https://wolfram.com/xid/0rsxzoq5a-c55i35

Factor a polynomial over an extension of a finite field:

https://wolfram.com/xid/0rsxzoq5a-lfuqta
The polynomial is irreducible over
:

https://wolfram.com/xid/0rsxzoq5a-d6ohpw

Factor after embedding
in a larger field
:

https://wolfram.com/xid/0rsxzoq5a-c3n4ii

https://wolfram.com/xid/0rsxzoq5a-7w11l

Linear Algebra over Finite Fields (1)
Compute with matrices over a finite field:

https://wolfram.com/xid/0rsxzoq5a-nw2qll

https://wolfram.com/xid/0rsxzoq5a-klnmgf


https://wolfram.com/xid/0rsxzoq5a-m5yk5


https://wolfram.com/xid/0rsxzoq5a-d5bpi9


https://wolfram.com/xid/0rsxzoq5a-ivaq2d


https://wolfram.com/xid/0rsxzoq5a-cdmwj3


https://wolfram.com/xid/0rsxzoq5a-fhem5u


https://wolfram.com/xid/0rsxzoq5a-fyl9yp

Compute the rank and the null space of a matrix:

https://wolfram.com/xid/0rsxzoq5a-bppfv8


https://wolfram.com/xid/0rsxzoq5a-cipz81


https://wolfram.com/xid/0rsxzoq5a-bjbad3

Compute the LU decomposition of a matrix:

https://wolfram.com/xid/0rsxzoq5a-bfwvef

https://wolfram.com/xid/0rsxzoq5a-9affn


https://wolfram.com/xid/0rsxzoq5a-e6zkbj


https://wolfram.com/xid/0rsxzoq5a-5hn77


https://wolfram.com/xid/0rsxzoq5a-iewnv1

Find the characteristic polynomial of a matrix:

https://wolfram.com/xid/0rsxzoq5a-c2dxqj


https://wolfram.com/xid/0rsxzoq5a-blhmgu

Equations over Finite Fields (1)
Solve equations over a finite field:

https://wolfram.com/xid/0rsxzoq5a-goax2p

https://wolfram.com/xid/0rsxzoq5a-cfndqf


https://wolfram.com/xid/0rsxzoq5a-f6gotk


https://wolfram.com/xid/0rsxzoq5a-hef9nj


https://wolfram.com/xid/0rsxzoq5a-dyppb

Systems of polynomial equations:

https://wolfram.com/xid/0rsxzoq5a-fi2b3p


https://wolfram.com/xid/0rsxzoq5a-fna1o8


https://wolfram.com/xid/0rsxzoq5a-h9dx7s


https://wolfram.com/xid/0rsxzoq5a-bdjjwi


https://wolfram.com/xid/0rsxzoq5a-xqu6d


https://wolfram.com/xid/0rsxzoq5a-by6uxb

https://wolfram.com/xid/0rsxzoq5a-bfs72u

Applications (8)Sample problems that can be solved with this function
Implement an error-correcting code. The Hamming code encodes a
-bit message in an
-bit sequence and is able to correct up to one error:

https://wolfram.com/xid/0rsxzoq5a-hfwa6v
Let be a finite field with
elements using the exponential element representation, let
be the irreducible polynomial used to construct
, and let
be the generator of
:

https://wolfram.com/xid/0rsxzoq5a-ne7iga

The encoded message is the coefficient list of , where the coefficient list of
is the original message:

https://wolfram.com/xid/0rsxzoq5a-dtplxs

https://wolfram.com/xid/0rsxzoq5a-g4mttu


https://wolfram.com/xid/0rsxzoq5a-dffiub

Let be the polynomial whose coefficient list is the received message:

https://wolfram.com/xid/0rsxzoq5a-b6zbx3
If the received message contains no errors, then , and hence
:

https://wolfram.com/xid/0rsxzoq5a-igyfr

If the received message contains one error in position , then
, and hence
:

https://wolfram.com/xid/0rsxzoq5a-ic6gpv


https://wolfram.com/xid/0rsxzoq5a-j6p97i

Check and correct the received message:

https://wolfram.com/xid/0rsxzoq5a-icxx8g

https://wolfram.com/xid/0rsxzoq5a-dw4j8e

To decode the message, compute the coefficient list of :

https://wolfram.com/xid/0rsxzoq5a-xlzjn
The decoded message is correct when the received message has no errors or one error:

https://wolfram.com/xid/0rsxzoq5a-kgdi74


https://wolfram.com/xid/0rsxzoq5a-f0bu8d

Construct orthogonal Latin squares of order
for any prime power
. A Latin square of order
is a
array such that each row and each column contains every element of a set of
elements exactly once. A pair of Latin squares is said to be orthogonal if the
pairs formed by juxtaposing the two arrays are all distinct:

https://wolfram.com/xid/0rsxzoq5a-0upuy

Verify that all arrays are Latin squares:

https://wolfram.com/xid/0rsxzoq5a-d4948x

https://wolfram.com/xid/0rsxzoq5a-c7oljo

Verify that all pairs of arrays are orthogonal:

https://wolfram.com/xid/0rsxzoq5a-9bqbe

https://wolfram.com/xid/0rsxzoq5a-lz4ntk

A finite set of integers is a Sidon set if the sums
for
are all distinct. Construct a Sidon set of
integers in
, for a prime power
:

https://wolfram.com/xid/0rsxzoq5a-e7t51s

https://wolfram.com/xid/0rsxzoq5a-cp1p36

Verify that is a Sidon set of length
:

https://wolfram.com/xid/0rsxzoq5a-gdhwln


https://wolfram.com/xid/0rsxzoq5a-bxfcdl

https://wolfram.com/xid/0rsxzoq5a-b0r0sa

A de Bruijn sequence of order for an alphabet with
letters is a cyclic sequence
of
letters of the alphabet, such that every sequence of
letters appears exactly once as a subsequence of
. Construct a de Bruijn sequence of order
for an alphabet with
letters, for a prime power
:

https://wolfram.com/xid/0rsxzoq5a-zb6aj

https://wolfram.com/xid/0rsxzoq5a-hiqtm

Verify that is a de Bruijn sequence of order
for an alphabet with
letters:

https://wolfram.com/xid/0rsxzoq5a-qooprn

An matrix
is a Hadamard matrix if all entries of
are
or
and
. Construct a Hadamard matrix of order
for any prime power
with
:

https://wolfram.com/xid/0rsxzoq5a-cw3aua

https://wolfram.com/xid/0rsxzoq5a-ct5aou


https://wolfram.com/xid/0rsxzoq5a-fo3vve


https://wolfram.com/xid/0rsxzoq5a-mgj5n5

Implement the Rijndael S-box step used in the Advanced Encryption Standard (AES) algorithm. The first part, called the Nyberg S-box, uses multiplicative inverse in :

https://wolfram.com/xid/0rsxzoq5a-c9zsui


https://wolfram.com/xid/0rsxzoq5a-cl91l1
The second part involves an affine transformation over :

https://wolfram.com/xid/0rsxzoq5a-dl0lma
The forward S-box is the composition of the two parts:

https://wolfram.com/xid/0rsxzoq5a-hmm3m3
Compute the forward S-box table in the hexadecimal notation:

https://wolfram.com/xid/0rsxzoq5a-r6ogd

https://wolfram.com/xid/0rsxzoq5a-dlqq3u

Define the inverse S-box transformation:

https://wolfram.com/xid/0rsxzoq5a-k6b24b

https://wolfram.com/xid/0rsxzoq5a-k3084o
Compute the inverse S-box table in the hexadecimal notation:

https://wolfram.com/xid/0rsxzoq5a-b33tnl

Verify that the inverse S-box is the inverse of the forward S-box:

https://wolfram.com/xid/0rsxzoq5a-s77ga

Implement a Diffie–Hellman public key cryptosystem with a 2049-bit prime:

https://wolfram.com/xid/0rsxzoq5a-cde7id
Find a primitive element of the field :

https://wolfram.com/xid/0rsxzoq5a-hdiw8k

The first user chooses a private key :

https://wolfram.com/xid/0rsxzoq5a-glt0jo

The public key consists of ,
and
:

https://wolfram.com/xid/0rsxzoq5a-i84jyh


https://wolfram.com/xid/0rsxzoq5a-ca58iq

To send a 2048-bit message , the second user sends
and
:

https://wolfram.com/xid/0rsxzoq5a-hvou7x


https://wolfram.com/xid/0rsxzoq5a-qav58


https://wolfram.com/xid/0rsxzoq5a-ekuwt5

The first user can recover by computing
:

https://wolfram.com/xid/0rsxzoq5a-eo3xa0


https://wolfram.com/xid/0rsxzoq5a-e9tu9d

Implement a digital signature scheme. Fix a prime and find a primitive element
of
:

https://wolfram.com/xid/0rsxzoq5a-d8d4y4

Pick a secret integer and publish
,
and
:

https://wolfram.com/xid/0rsxzoq5a-gehwx

The signature for a message is a pair
of positive integers less than
such that
. Computing the signature requires the knowledge of the secret integer
:

https://wolfram.com/xid/0rsxzoq5a-wbsr4
The signature can be verified using the publicly known information:

https://wolfram.com/xid/0rsxzoq5a-gr25z
Compute the signature for a randomly generated message:

https://wolfram.com/xid/0rsxzoq5a-lgt8kg


https://wolfram.com/xid/0rsxzoq5a-d4l8q9

Properties & Relations (7)Properties of the function, and connections to other functions
A finite field with characteristic and extension degree
has
elements:

https://wolfram.com/xid/0rsxzoq5a-h3xzn


https://wolfram.com/xid/0rsxzoq5a-keigzy

Elements of a finite field with characteristic satisfy
:

https://wolfram.com/xid/0rsxzoq5a-gvqrbk


https://wolfram.com/xid/0rsxzoq5a-bvu64w

Hence the mapping is a field automorphism, known as FrobeniusAutomorphism:

https://wolfram.com/xid/0rsxzoq5a-d9pgty

The field generator is a root of the field irreducible:

https://wolfram.com/xid/0rsxzoq5a-cadezm


https://wolfram.com/xid/0rsxzoq5a-ilvoro


https://wolfram.com/xid/0rsxzoq5a-i22xa9

Use FrobeniusAutomorphism to find the remaining roots of :

https://wolfram.com/xid/0rsxzoq5a-b21m0e


https://wolfram.com/xid/0rsxzoq5a-ba2jn4

All elements of a finite field with elements are roots of
:

https://wolfram.com/xid/0rsxzoq5a-blnl8i


https://wolfram.com/xid/0rsxzoq5a-b1zyw5


https://wolfram.com/xid/0rsxzoq5a-g4wanw


https://wolfram.com/xid/0rsxzoq5a-gt047o

Any irreducible polynomial of degree over
has
roots in a field with
elements:

https://wolfram.com/xid/0rsxzoq5a-dgqx2o

Use IrreduciblePolynomialQ with Modulusp to verify irreducibility over :

https://wolfram.com/xid/0rsxzoq5a-iytr86

Use Factor with Extensionℱ to verify that f is a product of linear factors over ℱ:

https://wolfram.com/xid/0rsxzoq5a-jy6t4v

Use FiniteField[p,1] to compute over the prime field :

https://wolfram.com/xid/0rsxzoq5a-ewkevl

https://wolfram.com/xid/0rsxzoq5a-ugjvr

Compare with a result obtained using Mod:

https://wolfram.com/xid/0rsxzoq5a-c2p64n


https://wolfram.com/xid/0rsxzoq5a-bi4o6q

Compare with a result obtained using the Modulus option:

https://wolfram.com/xid/0rsxzoq5a-bacprr

Use ToFiniteField to convert integer coefficients to elements in the prime subfield of a finite field:

https://wolfram.com/xid/0rsxzoq5a-d8iv40

FromFiniteField converts the coefficients back to integers:

https://wolfram.com/xid/0rsxzoq5a-6v8x2

Convert the coefficients to finite field elements, with t used to represent the field generator:

https://wolfram.com/xid/0rsxzoq5a-b63lb

Convert the finite field coefficients to polynomials in t, where t represents the field generator:

https://wolfram.com/xid/0rsxzoq5a-0pllq

Wolfram Research (2023), FiniteField, Wolfram Language function, https://reference.wolfram.com/language/ref/FiniteField.html (updated 2024).
Text
Wolfram Research (2023), FiniteField, Wolfram Language function, https://reference.wolfram.com/language/ref/FiniteField.html (updated 2024).
Wolfram Research (2023), FiniteField, Wolfram Language function, https://reference.wolfram.com/language/ref/FiniteField.html (updated 2024).
CMS
Wolfram Language. 2023. "FiniteField." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/FiniteField.html.
Wolfram Language. 2023. "FiniteField." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/FiniteField.html.
APA
Wolfram Language. (2023). FiniteField. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/FiniteField.html
Wolfram Language. (2023). FiniteField. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/FiniteField.html
BibTeX
@misc{reference.wolfram_2025_finitefield, author="Wolfram Research", title="{FiniteField}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/FiniteField.html}", note=[Accessed: 29-March-2025
]}
BibLaTeX
@online{reference.wolfram_2025_finitefield, organization={Wolfram Research}, title={FiniteField}, year={2024}, url={https://reference.wolfram.com/language/ref/FiniteField.html}, note=[Accessed: 29-March-2025
]}