Polynomial GCD over GF(2)
Use binary polynomial division to uncover a common factor and distinguish it from an integer gcd.
By Riano · Published · Updated · Report a correction
Polynomial GCD over GF(2)
Binary Polynomial Arithmetic
Polynomials can be represented as binary strings where each bit corresponds to a coefficient in GF(2). The leftmost bit is the most significant, representing the highest degree term. In GF(2), coefficient arithmetic is modulo 2, which means addition and subtraction are identical and equivalent to the bitwise XOR operation. There are no "borrows" or "carries".
Finding the GCD of 11100 and 10101
Let A = 11100 (x4 + x3 + x2) and B = 10101 (x4 + x2 + 1). We use polynomial long division over GF(2) repeatedly, replacing A with B and B with the remainder R, until B becomes 0.
| A | B | Q | R |
|---|---|---|---|
| 11100 | 10101 | 1 | 1001 |
| 10101 | 1001 | 10 | 111 |
| 1001 | 111 | 11 | 0 |
The final non-zero remainder is 111 (x2 + x + 1), which is the greatest common divisor. Its degree is 2. Notice how quotient terms are found by matching the highest degree of the dividend with the divisor.
Explore Polynomial Division
Open the Polynomial GCD over GF(2) explorer. Follow these steps to see the Euclidean algorithm in action:
- Ensure Polynomial A is set to 10101 and Polynomial B is 1001.
- Press Step to perform the first division. The trace will show A divided by B, resulting in quotient Q and remainder R.
- Press Step again to continue the algorithm. The previous divisor becomes the new dividend, and the previous remainder becomes the new divisor.
- Press Finish to complete all remaining steps instantly. The GCD bits will show 111 and the GCD degree will show 2.
- Change Polynomial A to 10011 and Polynomial B to 111. Press Finish. The GCD is 1, a constant polynomial with degree 0, indicating they are coprime.
- Test the boundary case by setting Polynomial A to 0 and Polynomial B to 101. Press Finish. By convention, gcd(0, B) = B, so the GCD is 101.
- Set both to 0 and press Finish. The GCD bits is 0 and the degree is explicitly "Undefined for zero polynomial".
- Type an invalid character like "x" in Polynomial A. The trace will immediately clear and show an "Invalid polynomial bits" error.
- Press Reset to rewind the division trace to step 0 while preserving the entered A and B.
Assumptions and Limitations
This explorer models polynomial arithmetic specifically over the finite field GF(2).
- The module only accepts binary strings consisting of 1s and 0s. The strings represent polynomials up to a certain degree, with leading zeros normalized away.
- The maximum input length is restricted to 9 bits (degree 8). This bounds the maximum number of division steps to 9, keeping the visual trace manageable.
- Empty inputs or strings containing non-binary characters produce an explicit error rather than silently defaulting to zero or producing NaN.
- By mathematical convention, the degree of the zero polynomial is undefined (often denoted as -∞). This module explicitly displays "Undefined for zero polynomial" rather than a numeric 0, which would incorrectly imply a non-zero constant.
- Unlike integer division, GF(2) polynomial long division uses XOR for both addition and subtraction. This tool is not a general integer GCD calculator nor a CRC calculator (which divides a message by a single fixed generator).
Primary Source
The mathematical properties of polynomial rings over finite fields, including GF(2), are a standard topic in abstract algebra.
- SageMath Documentation: Polynomials over GF(2) - Details the computational representation and operations, such as gcd and quotient/remainder division, for binary polynomials. It confirms the bitwise arithmetic model and degree conventions used here.
Experience it interactively
Adjust parameters, observe in real time, and build deep intuition with Riano’s interactive Polynomial GCD over GF(2) module.
Try Polynomial GCD over GF(2) on Riano →