kb/data/en.wikipedia.org/wiki/Berlekamp–Welch_algorithm-0.md

1080 lines
14 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: "BerlekampWelch algorithm"
chunk: 1/2
source: "https://en.wikipedia.org/wiki/BerlekampWelch_algorithm"
category: "reference"
tags: "science, encyclopedia"
date_saved: "2026-05-05T14:40:01.393171+00:00"
instance: "kb-cron"
---
The BerlekampWelch algorithm, also known as the WelchBerlekamp algorithm, is named for Elwyn R. Berlekamp and Lloyd R. Welch. This is a decoder algorithm that efficiently corrects errors in ReedSolomon codes for an RS(n, k), code based on the Reed Solomon original view where a message
m
1
,
,
m
k
{\displaystyle m_{1},\cdots ,m_{k}}
is used as coefficients of a polynomial
F
(
a
i
)
{\displaystyle F(a_{i})}
or used with Lagrange interpolation to generate the polynomial
F
(
a
i
)
{\displaystyle F(a_{i})}
of degree < k for inputs
a
1
,
,
a
k
{\displaystyle a_{1},\cdots ,a_{k}}
and then
F
(
a
i
)
{\displaystyle F(a_{i})}
is applied to
a
k
+
1
,
,
a
n
{\displaystyle a_{k+1},\cdots ,a_{n}}
to create an encoded codeword
c
1
,
,
c
n
{\displaystyle c_{1},\cdots ,c_{n}}
.
The goal of the decoder is to recover the original encoding polynomial
F
(
a
i
)
{\displaystyle F(a_{i})}
, using the known inputs
a
1
,
,
a
n
{\displaystyle a_{1},\cdots ,a_{n}}
and received codeword
b
1
,
,
b
n
{\displaystyle b_{1},\cdots ,b_{n}}
with possible errors. It also computes an error polynomial
E
(
a
i
)
{\displaystyle E(a_{i})}
where
E
(
a
i
)
=
0
{\displaystyle E(a_{i})=0}
corresponding to errors in the received codeword.
== The key equations ==
Defining e = number of errors, the key set of n equations is
b
i
E
(
a
i
)
=
E
(
a
i
)
F
(
a
i
)
{\displaystyle b_{i}E(a_{i})=E(a_{i})F(a_{i})}
Where E(ai) = 0 for the e cases when bi F(ai), and E(ai) 0 for the n - e non error cases where bi = F(ai) . These equations can't be solved directly, but by defining Q() as the product of E() and F():
Q
(
a
i
)
=
E
(
a
i
)
F
(
a
i
)
{\displaystyle Q(a_{i})=E(a_{i})F(a_{i})}
and adding the constraint that the most significant coefficient of E(ai) = ee = 1, the result will lead to a set of equations that can be solved with linear algebra.
b
i
E
(
a
i
)
=
Q
(
a
i
)
{\displaystyle b_{i}E(a_{i})=Q(a_{i})}
b
i
E
(
a
i
)
Q
(
a
i
)
=
0
{\displaystyle b_{i}E(a_{i})-Q(a_{i})=0}
b
i
(
e
0
+
e
1
a
i
+
e
2
a
i
2
+
+
e
e
a
i
e
)
(
q
0
+
q
1
a
i
+
q
2
a
i
2
+
+
q
q
a
i
q
)
=
0
{\displaystyle b_{i}(e_{0}+e_{1}a_{i}+e_{2}a_{i}^{2}+\cdots +e_{e}a_{i}^{e})-(q_{0}+q_{1}a_{i}+q_{2}a_{i}^{2}+\cdots +q_{q}a_{i}^{q})=0}
where q = n - e - 1. Since ee is constrained to be 1, the equations become:
b
i
(
e
0
+
e
1
a
i
+
e
2
a
i
2
+
+
e
e
1
a
i
e
1
)
(
q
0
+
q
1
a
i
+
q
2
a
i
2
+
+
q
q
a
i
q
)
=
b
i
a
i
e
{\displaystyle b_{i}(e_{0}+e_{1}a_{i}+e_{2}a_{i}^{2}+\cdots +e_{e-1}a_{i}^{e-1})-(q_{0}+q_{1}a_{i}+q_{2}a_{i}^{2}+\cdots +q_{q}a_{i}^{q})=-b_{i}a_{i}^{e}}
resulting in a set of equations which can be solved using linear algebra, with time complexity
O
(
n
3
)
{\displaystyle O(n^{3})}
.
The algorithm begins assuming the maximum number of errors e = ⌊(n-k)/2⌋. If the equations can not be solved (due to redundancy), e is reduced by 1 and the process repeated, until the equations can be solved or e is reduced to 0, indicating no errors. If Q()/E() has remainder = 0, then F() = Q()/E() and the code word values F(ai) are calculated for the locations where E(ai) = 0 to recover the original code word. If the remainder 0, then an uncorrectable error has been detected.
== Simple Example ==
Consider a simple example where a redundant set of points are used to represent the line
y
=
5
x
{\displaystyle y=5-x}
, and one of the points is incorrect. The points that the algorithm gets as an input are
(
1
,
4
)
,
(
2
,
3
)
,
(
3
,
4
)
,
(
4
,
1
)
{\displaystyle (1,4),(2,3),(3,4),(4,1)}
, where
(
3
,
4
)
{\displaystyle (3,4)}
is the defective point. The algorithm must solve the following system of equations:
Q
(
1
)
=
4
E
(
1
)
Q
(
2
)
=
3
E
(
2
)
Q
(
3
)
=
4
E
(
3
)
Q
(
4
)
=
1
E
(
4
)
{\displaystyle {\begin{alignedat}{1}Q(1)&=4*E(1)\\Q(2)&=3*E(2)\\Q(3)&=4*E(3)\\Q(4)&=1*E(4)\\\end{alignedat}}}
Given a solution
Q
{\displaystyle Q}
and
E
{\displaystyle E}
to this system of equations, it is evident that at any of the points
x
=
1
,
2
,
3
,
4
{\displaystyle x=1,2,3,4}
one of the following must be true: either
Q
(
x
i
)
=
E
(
x
i
)
=
0
{\displaystyle Q(x_{i})=E(x_{i})=0}
, or
P
(
x
i
)
=
Q
(
x
i
)
E
(
x
i
)
=
y
i
{\displaystyle P(x_{i})={Q(x_{i}) \over E(x_{i})}=y_{i}}
. Since
E
{\displaystyle E}
is defined as only having a degree of one, the former can only be true in one point. Therefore,
P
(
x
i
)
{\displaystyle P(x_{i})}
must equal
y
i
{\displaystyle y_{i}}
at the three other points.
Letting
E
(
x
)
=
x
+
e
0
{\displaystyle E(x)=x+e_{0}}
and
Q
(
x
)
=
q
0
+
q
1
x
+
q
2
x
2
{\displaystyle Q(x)=q_{0}+q_{1}x+q_{2}x^{2}}
and bringing
E
(
x
)
{\displaystyle E(x)}
to the left, we can rewrite the system thus: