Mathwords logoMathwords

BCH Code — Definition, Formula & Example

A BCH code is a type of error-correcting code where you first choose how many bit errors tt the code must fix. You then build its generator polynomial from roots in a finite field that guarantee that level of protection.

Let qq be a prime power, let gcd⁡(n,q)=1\gcd(n, q) = 1, and let α\alpha be a primitive nnth root of unity in GF(qm)\mathrm{GF}(q^m). For a designed distance δ≥2\delta \ge 2 and an integer bb, the BCH code is the cyclic code of length nn over GF(q)\mathrm{GF}(q) whose generator polynomial is the least common multiple of the minimal polynomials over GF(q)\mathrm{GF}(q) of αb,αb+1,…,αb+δ−2\alpha^b, \alpha^{b+1}, \ldots, \alpha^{b+\delta-2}. The BCH bound guarantees a minimum distance d≥δd \ge \delta. The code is narrow-sense when b=1b = 1 and primitive when n=qm−1n = q^m - 1.

Key Formula

g(x)=lcm⁡{m1(x),m2(x),…,m2t(x)},n−k≤mtg(x) = \operatorname{lcm}\{m_1(x), m_2(x), \ldots, m_{2t}(x)\}, \qquad n - k \le mt
Where:
  • g(x)g(x) = Generator polynomial; every codeword is a multiple of it
  • mi(x)m_i(x) = Minimal polynomial of αi\alpha^i over GF(2)\mathrm{GF}(2)
  • tt = Number of errors the code is designed to correct
  • nn = Block length, n=2m−1n = 2^m - 1 for a primitive binary BCH code
  • kk = Number of message bits, k=n−deg⁡g(x)k = n - \deg g(x)
  • mm = Degree of the field extension GF(2m)\mathrm{GF}(2^m)

Worked Example

Problem: Build the binary BCH code of length n=15n = 15 that corrects t=2t = 2 errors. Use GF(16)\mathrm{GF}(16) with a primitive element α\alpha satisfying α4=α+1\alpha^4 = \alpha + 1, so m1(x)=x4+x+1m_1(x) = x^4 + x + 1. Find the generator polynomial g(x)g(x) and the message length kk.
Step 1: Correcting 2 errors requires the 2t=42t = 4 consecutive roots α,α2,α3,α4\alpha, \alpha^2, \alpha^3, \alpha^4. Over GF(2)\mathrm{GF}(2), squaring a root gives another root of the same minimal polynomial. So you group the exponents by repeatedly doubling them mod 15.
{1,2,4,8},{3,6,12,9}\{1, 2, 4, 8\}, \qquad \{3, 6, 12, 9\}
Step 2: The roots α\alpha, α2\alpha^2, and α4\alpha^4 all share m1(x)m_1(x). Only α3\alpha^3 needs a new polynomial. It has order 15/gcd⁡(3,15)=515/\gcd(3, 15) = 5, so it is a root of x5+1=(x+1)(x4+x3+x2+x+1)x^5 + 1 = (x + 1)(x^4 + x^3 + x^2 + x + 1). It is not a root of x+1x + 1, because α3≠1\alpha^3 \ne 1.
m3(x)=x4+x3+x2+x+1m_3(x) = x^4 + x^3 + x^2 + x + 1
Step 3: Multiply the two minimal polynomials using arithmetic mod 2, where 1+1=01 + 1 = 0. The degree of g(x)g(x) is the number of check bits.
g(x)=(x4+x+1)(x4+x3+x2+x+1)=x8+x7+x6+x4+1,k=15−8=7g(x) = (x^4 + x + 1)(x^4 + x^3 + x^2 + x + 1) = x^8 + x^7 + x^6 + x^4 + 1, \qquad k = 15 - 8 = 7
Answer: The generator polynomial is g(x)=x8+x7+x6+x4+1g(x) = x^8 + x^7 + x^6 + x^4 + 1. It defines a (15,7)(15, 7) BCH code. The BCH bound gives d≥5d \ge 5. The codeword g(x)g(x) itself has weight 5, so d=5d = 5 exactly, and the code corrects any 2 errors in a 15-bit block.

Why It Matters

BCH codes protect the format information in every QR code, using a (15,5)(15, 5) binary BCH code. Satellite TV under the DVB-S2 standard pairs a BCH outer code with an LDPC inner code. Flash-memory controllers in SSDs use BCH decoders to fix bit errors in stored data. In a college course on coding theory or abstract algebra, BCH codes are usually your first look at finite fields applied to a real engineering problem.

Common Mistakes

Mistake: Multiplying all 2t2t minimal polynomials m1(x)m2(x)⋯m2t(x)m_1(x) m_2(x) \cdots m_{2t}(x), which counts repeats such as m2=m4=m1m_2 = m_4 = m_1.
Correction: Take the least common multiple, so each distinct minimal polynomial appears once. In the example, a plain product would have degree 16. That exceeds n=15n = 15 and leaves no room for message bits.

Related Terms

  • Coding Theory — The field that studies codes like BCH codes
  • Finite Field — Supplies the roots that define the generator polynomial
  • Linear Code — BCH codes are a special family of linear codes