The Extended Euclidean Algorithm in Finite Fields
This article has been adapted from an earlier PDF I wrote.
Motivation
Given that several operations in discrete mathematics require one to find the inverse of integers or polynomials in finite fields, it is important to learn an efficient algorithm to do so quickly. The Extended Euclidean Algorithm is the most primitive of these algorithms and essential for students.
In this article, I will explain use this algorithm on a few example problems, hopefully giving some intuition to future students.
Standard Euclidean Algorithm
Let us find the gcd of
At first, we just use the standard Euclidean algorithm, making sure to write down every step as follows:
Take
Extended Euclidean Algorithm to find the gcd
Now what the extended Euclidean algorithm allows us to do is to find the gcd of the two numbers as a sum of the two times certain factors. In other words, we want to find coefficients
For this we go backwards through the steps of the Euclidean Algorithm (we ignore the step where we get
And therefore we have found the needed factors.
Extended Euclidean Algorithm for finding multiplicative inverses
Given the following modulo-equation:
We know this is equivalent to:
Notice how this problem simplifies to the same as the one in the previous chapter: we are also looking for factors
Therefore, we can use the Extended Euclidean algorithm:
Now solving for
Therefore,
A note on coefficients
Most often it is obvious by what factor you have to multiply the smaller amount to subtract it from the larger amount, as in the previous example:
But with larger and larger numbers (and also with polynomials), it might not become as obvious. This when for each step one can execute a division algorithm of choice with rest to find the given coefficient and rest:
Example:
Therefore, our first step will be
And then we continue the algorithm as normal
Polynomials
This exact same algorithm can be used for polynomials, it just gets computationally more heavy due to the added complexity of polynomials.
Let us find the inverse of
Therefore, we want to solve the equation
Now notice the following:
If we ever get an equation of this form:
We can get
The big “top-level” idea therefore is to run the algorithm as many steps as needed until the rest is a polynomial of zeroth order
Then we solve for
Let us start the Euclidean algorithm:
Now we use polynomial division to find
Therefore:
And now we solve for
Therefore, the inverse of
Some shorter examples with edge cases
Notice that both of these examples get us a rest of zeroth order after only a single iteration of the euclidean algorithm, which then means that the “solving” part is trivial.
Example
Inverse of
Euclidean algorithm:
Example
Inverse of
Euclidean algorithm:
Therefore, the inverse of
Example
Inverse of
Euclidean algorithm:
We multiply both sides with