Week 3
Fields
A field
- Add or multiply numbers.
- Find opposites, like -5 is the opposite of 5.
- Find reciprocals, like
is the reciprocal of 5. - And these operations behave in "nice" ways, like we're used to.
These fields should follow some properties:
- Closure: For any
and in the field , the result of adding or multiplying these elements should also be in . For instance, multiplying (both in ) gives (also in ). Similarly, adding (both in ) gives (also in ). - Associativity: We should be able to apply these operations in any group order. So for any
, and in field , (the group order in which add add elements doesn't matter). Similarly, (the group order in which we multiply elements doesn't matter). - Commutativity: We should be able to apply these operations to any two elements in any order. If have elements
and in field , then and . - Existence of identities: This basically means that there should be the equivalent of 0 and 1 values in the field. Let's say we assign the equivalent of 0 to
in this field , and we take any other value in , then , and this value should be denoted as (additive identity). Similarly, if we assign the equivalent of 1 to in , then , and this value should be denoted as (multiplicative identity). - Existence of inverses: This basically means that we should have a way to invert the values, whether by finding the opposite or the reciprocal. Let's say we have a value
in the field . There should exist a value in the same field such that , and this value should be denoted as (additive inverse). Similarly, there should exist a value in such that , and this value should be denoted as (multiplicative inverse). - Distributivity of
over : This basically means that for any , and in , multiplication should distribute itself over an addition operation. So if we have , then should distribute over and to give .
Some examples of fields are
Euclid's algorithm
Euclid's algorithm is used to find the greatest common denominator of any two numbers. We can think of this like finding the largest common unit of measurement between two lengths. If we have a 15-meter rope and a 9-meter rope, what's the largest measuring stick that can measure both lengths perfectly?
Here's how Euclid's algorithm works:
- We start with two numbers,
and . Let's take them to be from the example above, and . - We divide
by and get the remainder. . This basically means that . - If the remainder is 0, then
is the greatest common denominator. If not, then we replace with , and with the remainder. So in this case, now and . - We repeat 2 and 3 until we get to a remainder of 0. So
, and now and . Finally, . - Therefore, 3 is the greatest common denominator.
Let's try another example, we can try to find the g.c.d. of 48 and 18:
But that's not all, Euclid's algorithm can also find
So,
This is very useful in number theory and cryptography, but also has other uses. For example, it's handy in physics when you're dealing with resonance and need to find out when two periodic motions will sync up, or in computer graphics when you need to find the largest size of tile that will fit evenly in both width and height.
Finite fields
These are like normal Fields except that they're finite in size, and have a limited number of elements. A good example of how this would work is like doing clock arithmetic. When we add 5 hours to 22:00, we get 03:00. It "loops around" back to being within the field, so the field is limited to being from 00:00:00 to 23:59:59.
Let's ignore that clocks aren't a field, they don't have multiplicative inverses for instance, depending on how you look at it. It's an example to prove a point.
Prime fields
This is a field with a prime number of elements. Let's take a prime number
- Addition: For any
and in , addition is defined as . This is usually denoted as since the fact that it's a finite field and so addition is is implied from context, however it's also written as if written explicitly. - Multiplication: For any
and in , multiplication is defined as . This is usually denoted as since the fact that it's a finite field and so multiplication is is implied from context, however it's also written as if written explicitly.
An example of this can be a prime field with 5 elements:
Irreducible polynomials
Just like prime numbers can't be factored into smaller integers, irreducible polynomials can't be factored into smaller polynomials over a given field. First, let's look at a simple example in real space
can be reduced to and , since . Therefore it is not irreducible in the field of real numbers. cannot be reduced any further in , we need complex numbers to factorise it, which aren't available in the field of only real numbers. Therefore, it is irreducible.
Now let's look at an example in a finite field,
- Let's start with a polynomial,
. Because all of the coefficients are 0 or 1, this polynomial exists in . - The only possible factors of this polynomial are first-degree polynomials:
. - We can try all of the combinations of
and . - We will find that none of them multiply together to give us
. - Therefore,
is irreducible in .
We can prove this mathematically:
None of these give us
These are important because they are like building blocks. In physics, we build complex wavefunctions out of simpler basis functions (think
The HAROLD fact states that for any prime
Extension fields
For example, if we want to construct
Addition
Addition works by adding coefficients modulo 2:
Multiplication
Multiplication is trickier, after multiplying normally we have to reduce by the irreducible polynomial from earlier,
But
Therefore, in
Primitive element
We can also find a primitive element. Let's try
If we continue this, we will get all the non-zero elements before returning to 1, making it a primitive element.
Multiplicative inverse
There are two main ways to find the multiplicative inverses:
Extended Euclidean Algorithm Method: For element
, find polynomials and such that where is our original irreducible polynomial ( for ). For example, if we want to find the multiplicative inverse of : Divide
by : Divide
by : Since the remainder is now 1, we're done. Working backwards:
So the multiplicative inverse is
. Exponential trick (usually faster): In
, any non-zero element satisfies , and so . For example, taking : Therefore, the multiplicative inverse is
.
Linear algebraic notions that are similar/different for finite fields
Similar
The ideas of:
- Gaussian elimination
- Matrix addition/multiplication/inverses
- Determinants
- Vector spaces
- Row/columns/null-spaces of matrices/bases/rank
are all shared between infinite fields like
Gaussian elimination
This is a way to solve a system of linear equations by converting them to an easier format and "eliminating". Say we have two equations,
First, we multiply one of the equations such that one of its coefficients is the same as the other. For example, we can multiply equation 2 by 2, so that
Now, we "subtract" equation 1 from 2a, giving us
This process is the same in finite fields, except all operations are
NOTE
I discovered this on my own while trying to solve the problem Claude was giving me. Turns out you can't solve some problems in finite fields that work in
We can see that this equation doesn't work. However, the idea still stands, we can use Gaussian elimination to solve linear equations like these even in finite fields.
Differences
The main differences are that:
- Instead of Euclidean distance, we use Hamming distance.
- Instead of Euclidean norm, we use Hamming weight.
- "Angles" between vectors don't make sense. There is no natural notion of "size" or "direction" in finite field vectors, so we can't really have angles between them.
Hamming distance
In infinite fields, we use Euclidean distance,
Basically, Hamming distance is the number of locations in which two vectors differ. So if we have a vector
Hamming weight
In infinite fields, we use Euclidean norm
Basically, Hamming weight is the number of locations a vector is non-zero. So the Hamming weight of a vector
Error-correcting code
We start with some basic parameters:
: the size of the alphabet we will be using. This is usually a prime or a prime power . : The number of message symbols. This is the length of the original message. : The blocklength. This is the length of the message after encoding, it is always larger than . : The rate, or efficiency of communication, equal to . The smaller is, the more redundancy there is, hence our communication method will hopefully be more tolerant of errors, at the cost of being slower.
Then, we add some key components:
: The message. This is made up of symbols uniformly distributed in , formally written as . : The codeword. This is the encoded message, in symbols all in , formally written as . : The received, possibly corrupted, word. This is also of length , and in . It corresponds to the noisy observation of (which basically means after transmission and the data losses that happened), and may have up to erasures (missing data) or errors (incorrect symbols).
We have some additional parts here as well:
: the encoder, which maps to . We can write this as . Hence, the codeword is also sometimes denoted as . : the decoder, which maps to , the decoded message. We can write this as . : the code. This is the collection of all possible codewords that could be generated by the encoder.
Finally, we have the distance:
: minimum distance. This is the smallest Hamming distance in between any two codewords, i.e. . - Any code with minimum distance
can tolerate up to erasures, or less than errors.
Let's say we're working in
- We start with a message
. The length of this message . - We encode this message using our encoder to get
. The length of this encoded message . - Therefore, the rate
. - Let's say after transmission, we receive
. The Hamming distance between and is 1, and we can see that the element in the 5th position has changed, so one error has occurred.
In practice, this workflow looks something like:
The goal with this is to add enough redundancy to correct errors, but not so much that transmitting the message becomes too slow. So we need to find the sweet spot between reliability
Distance
The basic idea of distance in error correction is that, if two codewords are a distance
Let's say the minimum distance
Let's say
. Not every 5 character string will be a valid codeword, because the encoder uses a specific algorithm to generate these codewords. We will see this in a bit with the (7, 4, 3) Hamming code.
A visual example:
Original: 1 1 1 0 0
Received: 1 1 0 1 0
^ ^ 2 differences
Other valid: 0 0 0 1 1
^ ^ ^ 3 differencesTherefore, the received word is closer to the original message than any other codeword.
This follows the rule of less than
Original: 1 1 1 0 0
Received: 1 0 0 1 0
^ ^ ^ 3 differences
Other valid: 0 0 0 1 1
^ ^ 2 differencesHere, we're finding the incorrect valid codeword as the closest one, because of too many errors.
Erasures, on the other hand, are easier to correct, because we know which positions are corrupted, and so we can correct up to
(? means erasure)
Original: 1 1 1 0 0
Received: 1 ? 1 ? 0
Other valid: 0 0 0 1 1Only the original message matches, and so we can easily correct this. Whereas with errors, we don't always know which positions are incorrect, so we can only correct less than
Linear codes
A linear code multiplies our message
and a message
So a 2-bit message becomes a 4-bit codeword.
Linear codes have some key properties:
- The sum of two codewords is also a codeword.
- The field multiple of a codeword is also a codeword.
- The zero vector is always a codeword.
- The minimum distance
is the minimum weight of a non-zero codeword.
Repetition code
A simple way to encode messages is to just repeat them. Let's say we have
(7,4,3) Hamming code
This takes a 4-bit message,
This ensures minimum distance
Reed-Solomon codes
The generator matrix is a Vandermonde matrix, with the
The Vandermonde matrix looks like this:
where