Skip to content

Commit

Permalink
Rewording more math - Forney stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
geky committed Oct 23, 2024
1 parent 431a0cc commit 5faab16
Showing 1 changed file with 54 additions and 41 deletions.
95 changes: 54 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -831,8 +831,10 @@ using Horner's method and GF(256) log tables.

#### Evaluating the errors

Once we've found our error locations $X_j$, solving for the error
magnitudes $Y_j$ is relatively straightforward. Kind of.
Once we've found the error-locations, $X_j$, the next step is to find the
error-magnitudes, $Y_j$.

This step is relatively straightforward... kind of...

Recall the definition of our syndromes $S_i$:

Expand All @@ -843,9 +845,8 @@ Recall the definition of our syndromes $S_i$:
>
</p>
With $e$ syndromes, this can be rewritten as a system of equations with
$e$ equations and $e$ unknowns, our error magnitudes $Y_j$, which we can
solve for:
With $e$ syndromes, this can be rewritten as a system with $e$ equations
and $e$ unknowns, which we can, in theory, solve for:

<p align="center">
<img
Expand All @@ -861,8 +862,8 @@ But again, solving this system of equations is easier said than done.
It turns out there's a really clever formula that can be used to solve
for $Y_j$ directly, called [Forney's algorithm][forneys-algorithm].

Assuming we know an error-locator $X_j$, plug it into the following
formula to find an error-magnitude $Y_j$:
Assuming we know an error-locator $X_j$, the following formula will spit
out an error-magnitude $Y_j$:

<p align="center">
<img
Expand All @@ -871,8 +872,8 @@ formula to find an error-magnitude $Y_j$:
>
</p>
Where $\Omega(x)$, called the error-evaluator polynomial, is defined like
so:
Where $\Omega(x)$, called the "error-evaluator polynomial", is defined
like so:

<p align="center">
<img
Expand All @@ -881,17 +882,27 @@ so:
>
</p>
$S(x)$, called the "syndrome polynomial", is defined like so (we just
pretend our syndromes are a polynomial now):

<p align="center">
<img
alt="S(x) = S_0 + S_1 x + \cdots + S_{n-1} x^{n-1} = \sum_{i=0}^{n-1} S_i x^i"
src="https://latex.codecogs.com/svg.image?S%28x%29%20%3d%20S_%30%20%2b%20S_%31%20x%20%2b%20%5ccdots%20%2b%20S_%7bn%2d%31%7d%20x%5e%7bn%2d%31%7d%20%3d%20%5csum_%7bi%3d%30%7d%5e%7bn%2d%31%7d%20S_i%20x%5ei"
>
</p>
And $\Lambda'(x)$, the [formal derivative][formal-derivative] of the
error-locator, can be calculated by terms like so:
error-locator, can be calculated like so:

<p align="center">
<img
alt="\Lambda'(x) = \sum_{i=1}^2 i \cdot \Lambda_i x^{i-1}"
src="https://latex.codecogs.com/svg.image?%5cLambda%27%28x%29%20%3d%20%5csum_%7bi%3d%31%7d%5e%32%20i%20%5ccdot%20%5cLambda_i%20x%5e%7bi%2d%31%7d"
alt="\Lambda'(x) = \Lambda_1 + 2 \cdot \Lambda_2 x + \cdots + e \cdot \Lambda_e x^{e-1} = \sum_{k=1}^e k \cdot \Lambda_k x^{k-1}"
src="https://latex.codecogs.com/svg.image?%5cLambda%27%28x%29%20%3d%20%5cLambda_%31%20%2b%20%32%20%5ccdot%20%5cLambda_%32%20x%20%2b%20%5ccdots%20%2b%20e%20%5ccdot%20%5cLambda_e%20x%5e%7be%2d%31%7d%20%3d%20%5csum_%7bk%3d%31%7d%5ee%20k%20%5ccdot%20%5cLambda_k%20x%5e%7bk%2d%31%7d"
>
</p>
Though note $i$ is not a field element, so multiplication by $i$
Though note $k$ is not a field element, so multiplication by $k$
represents normal repeated addition. And since addition is xor in our
field, this just cancels out every other term.

Expand All @@ -902,60 +913,62 @@ The end result is a simple formula for our error-magnitudes $Y_j$.
Haha, I know right? Where did this equation come from? How does it work?
How did Forney even come up with this?

To be honest I don't know the answer to most of these questions, there's
very little documentation online about where this formula comes from.
I don't know the answer to most of these questions, there's very little
documentation online about where/how/what this formula comes from.

But at the very least we can prove that it works.
But at the very least we can prove that it does work!

#### The error-evaluator polynomial

Let us start with the syndrome polynomial $S(x)$:
Let's start with the syndrome polynomial $S(x)$:

<p align="center">
<img
alt="S(x) = \sum_{i=0}^n S_i x^i"
src="https://latex.codecogs.com/svg.image?S%28x%29%20%3d%20%5csum_%7bi%3d%30%7d%5en%20S_i%20x%5ei"
alt="S(x) = S_0 + S_1 x + \cdots + S_{n-1} x^{n-1} = \sum_{i=0}^{n-1} S_i x^i"
src="https://latex.codecogs.com/svg.image?S%28x%29%20%3d%20S_%30%20%2b%20S_%31%20x%20%2b%20%5ccdots%20%2b%20S_%7bn%2d%31%7d%20x%5e%7bn%2d%31%7d%20%3d%20%5csum_%7bi%3d%30%7d%5e%7bn%2d%31%7d%20S_i%20x%5ei"
>
</p>
Substituting the definition of $S_i$:
Substituting in the definition of our syndromes,
$S_i = \sum_{j \in E} Y_j X_j^i x^i$:

<p align="center">
<img
alt="\begin{aligned} S(x) &= \sum_{i=0}^n \sum_{j \in e} Y_j X_j^i x^i \\ &= \sum_{j \in e} \left(Y_j \sum_{i=0}^n X_j^i x^i\right) \end{aligned}"
src="https://latex.codecogs.com/svg.image?%5cbegin%7baligned%7d%20S%28x%29%20%26%3d%20%5csum_%7bi%3d%30%7d%5en%20%5csum_%7bj%20%5cin%20e%7d%20Y_j%20X_j%5ei%20x%5ei%20%5c%5c%20%26%3d%20%5csum_%7bj%20%5cin%20e%7d%20%5cleft%28Y_j%20%5csum_%7bi%3d%30%7d%5en%20X_j%5ei%20x%5ei%5cright%29%20%5cend%7baligned%7d"
alt="\begin{aligned} S(x) &= \sum_{i=0}^{n-1} \sum_{j \in E} Y_j X_j^i x^i \\ &= \sum_{j \in E} \left(Y_j \sum_{i=0}^{n-1} X_j^i x^i\right) \end{aligned}"
src="https://latex.codecogs.com/svg.image?%5cbegin%7baligned%7d%20S%28x%29%20%26%3d%20%5csum_%7bi%3d%30%7d%5e%7bn%2d%31%7d%20%5csum_%7bj%20%5cin%20E%7d%20Y_j%20X_j%5ei%20x%5ei%20%5c%5c%20%26%3d%20%5csum_%7bj%20%5cin%20E%7d%20%5cleft%28Y_j%20%5csum_%7bi%3d%30%7d%5e%7bn%2d%31%7d%20X_j%5ei%20x%5ei%5cright%29%20%5cend%7baligned%7d"
>
</p>
The sum on the right side turns out to be a [geometric series][geometric-series]:
The sum on the right turns out to be a [geometric series][geometric-series]:

<p align="center">
<img
alt="S(x) = \sum_{j \in e} Y_j \frac{1 - X_j^n x^n}{1 - X_j x}"
src="https://latex.codecogs.com/svg.image?S%28x%29%20%3d%20%5csum_%7bj%20%5cin%20e%7d%20Y_j%20%5cfrac%7b%31%20%2d%20X_j%5en%20x%5en%7d%7b%31%20%2d%20X_j%20x%7d"
alt="S(x) = \sum_{j \in E} Y_j \frac{1 - X_j^n x^n}{1 - X_j x}"
src="https://latex.codecogs.com/svg.image?S%28x%29%20%3d%20%5csum_%7bj%20%5cin%20E%7d%20Y_j%20%5cfrac%7b%31%20%2d%20X_j%5en%20x%5en%7d%7b%31%20%2d%20X_j%20x%7d"
>
</p>
If we then multiply with our error-locator polynomial $\Lambda(x)$:
If we then multiply with our error-locator polynomial, $\Lambda(x)$:

<p align="center">
<img
alt="\begin{aligned} S(x)\Lambda(x) &= \sum_{j \in e} \left(Y_j \frac{1 - X_j^n x^n}{1 - X_j x}\right) \cdot \prod_{k=0}^e \left(1 - X_k x\right) \\ &= \sum_{j \in e} \left(Y_j \left(1 - X_j^n x^n\right) \prod_{k \ne j} \left(1 - X_k x\right)\right) \end{aligned}"
src="https://latex.codecogs.com/svg.image?%5cbegin%7baligned%7d%20S%28x%29%5cLambda%28x%29%20%26%3d%20%5csum_%7bj%20%5cin%20e%7d%20%5cleft%28Y_j%20%5cfrac%7b%31%20%2d%20X_j%5en%20x%5en%7d%7b%31%20%2d%20X_j%20x%7d%5cright%29%20%5ccdot%20%5cprod_%7bk%3d%30%7d%5ee%20%5cleft%28%31%20%2d%20X_k%20x%5cright%29%20%5c%5c%20%26%3d%20%5csum_%7bj%20%5cin%20e%7d%20%5cleft%28Y_j%20%5cleft%28%31%20%2d%20X_j%5en%20x%5en%5cright%29%20%5cprod_%7bk%20%5cne%20j%7d%20%5cleft%28%31%20%2d%20X_k%20x%5cright%29%5cright%29%20%5cend%7baligned%7d"
alt="\begin{aligned} S(x)\Lambda(x) &= \sum_{j \in E} \left(Y_j \frac{1 - X_j^n x^n}{1 - X_j x}\right) \cdot \prod_{k \in E} \left(1 - X_k x\right) \\ &= \sum_{j \in E} \left(Y_j \left(1 - X_j^n x^n\right) \prod_{k \ne j} \left(1 - X_k x\right)\right) \end{aligned}"
src="https://latex.codecogs.com/svg.image?%5cbegin%7baligned%7d%20S%28x%29%5cLambda%28x%29%20%26%3d%20%5csum_%7bj%20%5cin%20E%7d%20%5cleft%28Y_j%20%5cfrac%7b%31%20%2d%20X_j%5en%20x%5en%7d%7b%31%20%2d%20X_j%20x%7d%5cright%29%20%5ccdot%20%5cprod_%7bk%20%5cin%20E%7d%20%5cleft%28%31%20%2d%20X_k%20x%5cright%29%20%5c%5c%20%26%3d%20%5csum_%7bj%20%5cin%20E%7d%20%5cleft%28Y_j%20%5cleft%28%31%20%2d%20X_j%5en%20x%5en%5cright%29%20%5cprod_%7bk%20%5cne%20j%7d%20%5cleft%28%31%20%2d%20X_k%20x%5cright%29%5cright%29%20%5cend%7baligned%7d"
>
</p>
We see exactly one term in each summand (TODO summand??) cancel out.
We see exactly one term in each summand cancel out.

At this point, if we plug in $X_j^{-1}$, this still evaluates to zero
thanks to the error-locator polynomial $\Lambda(x)$.
At this point, if we plug in $X_j^{-1}$, $S(X_j^{-1})\Lambda(X_j^{-1})$
still evaluates to zero thanks to the error-locator polynomial
$\Lambda(x)$.

But if we expand the multiplication, something interesting happens:

<p align="center">
<img
alt="S(x)\Lambda(x) = \sum_{j \in e} \left(Y_j \prod_{k \ne j} \left(1 - X_k x\right)\right) - \sum_{j \in e} \left(Y_j X_j^n x^n \prod_{k \ne j} \left(1 - X_k x\right)\right)"
src="https://latex.codecogs.com/svg.image?S%28x%29%5cLambda%28x%29%20%3d%20%5csum_%7bj%20%5cin%20e%7d%20%5cleft%28Y_j%20%5cprod_%7bk%20%5cne%20j%7d%20%5cleft%28%31%20%2d%20X_k%20x%5cright%29%5cright%29%20%2d%20%5csum_%7bj%20%5cin%20e%7d%20%5cleft%28Y_j%20X_j%5en%20x%5en%20%5cprod_%7bk%20%5cne%20j%7d%20%5cleft%28%31%20%2d%20X_k%20x%5cright%29%5cright%29"
alt="S(x)\Lambda(x) = \sum_{j \in E} \left(Y_j \prod_{k \ne j} \left(1 - X_k x\right)\right) - \sum_{j \in E} \left(Y_j X_j^n x^n \prod_{k \ne j} \left(1 - X_k x\right)\right)"
src="https://latex.codecogs.com/svg.image?S%28x%29%5cLambda%28x%29%20%3d%20%5csum_%7bj%20%5cin%20E%7d%20%5cleft%28Y_j%20%5cprod_%7bk%20%5cne%20j%7d%20%5cleft%28%31%20%2d%20X_k%20x%5cright%29%5cright%29%20%2d%20%5csum_%7bj%20%5cin%20E%7d%20%5cleft%28Y_j%20X_j%5en%20x%5en%20%5cprod_%7bk%20%5cne%20j%7d%20%5cleft%28%31%20%2d%20X_k%20x%5cright%29%5cright%29"
>
</p>
Expand All @@ -967,27 +980,27 @@ Imagine how these contribute to the expanded form of the equation:

<p align="center">
<img
alt="S(x)\Lambda(x) = \overbrace{\Omega_0 + \dots + \Omega_{e-1} x^{e-1}}^{\sum_{j \in e} \left(Y_j \prod_{k \ne j} \left(1 - X_k x\right)\right)} + \overbrace{\Omega_n x^n + \dots + \Omega_{n+e-1} x^{n+e-1}}^{\sum_{j \in e} \left(Y_j X_j^n x^n \prod_{k \ne j} \left(1 - X_k x\right)\right) }"
src="https://latex.codecogs.com/svg.image?S%28x%29%5cLambda%28x%29%20%3d%20%5coverbrace%7b%5cOmega_%30%20%2b%20%5cdots%20%2b%20%5cOmega_%7be%2d%31%7d%20x%5e%7be%2d%31%7d%7d%5e%7b%5csum_%7bj%20%5cin%20e%7d%20%5cleft%28Y_j%20%5cprod_%7bk%20%5cne%20j%7d%20%5cleft%28%31%20%2d%20X_k%20x%5cright%29%5cright%29%7d%20%2b%20%5coverbrace%7b%5cOmega_n%20x%5en%20%2b%20%5cdots%20%2b%20%5cOmega_%7bn%2be%2d%31%7d%20x%5e%7bn%2be%2d%31%7d%7d%5e%7b%5csum_%7bj%20%5cin%20e%7d%20%5cleft%28Y_j%20X_j%5en%20x%5en%20%5cprod_%7bk%20%5cne%20j%7d%20%5cleft%28%31%20%2d%20X_k%20x%5cright%29%5cright%29%20%7d"
alt="S(x)\Lambda(x) = \overbrace{\Omega_0 + \Omega_1 x + \cdots + \Omega_{e-1} x^{e-1}}^{\sum_{j \in E} \left(Y_j \prod_{k \ne j} \left(1 - X_k x\right)\right)} + \overbrace{\Omega_n x^n + \Omega_{n+1} x^{n+1} + \cdots + \Omega_{n+e-1} x^{n+e-1}}^{\sum_{j \in E} \left(Y_j X_j^n x^n \prod_{k \ne j} \left(1 - X_k x\right)\right) }"
src="https://latex.codecogs.com/svg.image?S%28x%29%5cLambda%28x%29%20%3d%20%5coverbrace%7b%5cOmega_%30%20%2b%20%5cOmega_%31%20x%20%2b%20%5ccdots%20%2b%20%5cOmega_%7be%2d%31%7d%20x%5e%7be%2d%31%7d%7d%5e%7b%5csum_%7bj%20%5cin%20E%7d%20%5cleft%28Y_j%20%5cprod_%7bk%20%5cne%20j%7d%20%5cleft%28%31%20%2d%20X_k%20x%5cright%29%5cright%29%7d%20%2b%20%5coverbrace%7b%5cOmega_n%20x%5en%20%2b%20%5cOmega_%7bn%2b%31%7d%20x%5e%7bn%2b%31%7d%20%2b%20%5ccdots%20%2b%20%5cOmega_%7bn%2be%2d%31%7d%20x%5e%7bn%2be%2d%31%7d%7d%5e%7b%5csum_%7bj%20%5cin%20E%7d%20%5cleft%28Y_j%20X_j%5en%20x%5en%20%5cprod_%7bk%20%5cne%20j%7d%20%5cleft%28%31%20%2d%20X_k%20x%5cright%29%5cright%29%20%7d"
>
</p>
If we truncate this polynomial, $\bmod n$ in math land, we can
effectively delete part of the equation:
effectively delete part of this equation:

<p align="center">
<img
alt="S(x)\Lambda(x) \bmod x^n = \overbrace{\Omega_0 + \dots + \Omega_{e-1} x^{e-1}}^{\sum_{j \in e} \left(Y_j \prod_{k \ne j} \left(1 - X_k x\right)\right)}"
src="https://latex.codecogs.com/svg.image?S%28x%29%5cLambda%28x%29%20%5cbmod%20x%5en%20%3d%20%5coverbrace%7b%5cOmega_%30%20%2b%20%5cdots%20%2b%20%5cOmega_%7be%2d%31%7d%20x%5e%7be%2d%31%7d%7d%5e%7b%5csum_%7bj%20%5cin%20e%7d%20%5cleft%28Y_j%20%5cprod_%7bk%20%5cne%20j%7d%20%5cleft%28%31%20%2d%20X_k%20x%5cright%29%5cright%29%7d"
alt="S(x)\Lambda(x) \bmod x^n = \overbrace{\Omega_0 + \Omega_1 x + \dots + \Omega_{e-1} x^{e-1}}^{\sum_{j \in E} \left(Y_j \prod_{k \ne j} \left(1 - X_k x\right)\right)}"
src="https://latex.codecogs.com/svg.image?S%28x%29%5cLambda%28x%29%20%5cbmod%20x%5en%20%3d%20%5coverbrace%7b%5cOmega_%30%20%2b%20%5cOmega_%31%20x%20%2b%20%5cdots%20%2b%20%5cOmega_%7be%2d%31%7d%20x%5e%7be%2d%31%7d%7d%5e%7b%5csum_%7bj%20%5cin%20E%7d%20%5cleft%28Y_j%20%5cprod_%7bk%20%5cne%20j%7d%20%5cleft%28%31%20%2d%20X_k%20x%5cright%29%5cright%29%7d"
>
</p>
Giving us the equation for the error-evaluator polynomial $\Omega(x)$:
Giving us the equation for the error-evaluator polynomial, $\Omega(x)$:

<p align="center">
<img
alt="\Omega(x) = S(x)\Lambda(x) \bmod x^n = \sum_{j \in e} \left(Y_j \prod_{k \ne j} \left(1 - X_k x\right)\right)"
src="https://latex.codecogs.com/svg.image?%5cOmega%28x%29%20%3d%20S%28x%29%5cLambda%28x%29%20%5cbmod%20x%5en%20%3d%20%5csum_%7bj%20%5cin%20e%7d%20%5cleft%28Y_j%20%5cprod_%7bk%20%5cne%20j%7d%20%5cleft%28%31%20%2d%20X_k%20x%5cright%29%5cright%29"
alt="\Omega(x) = S(x)\Lambda(x) \bmod x^n = \sum_{j \in E} \left(Y_j \prod_{k \ne j} \left(1 - X_k x\right)\right)"
src="https://latex.codecogs.com/svg.image?%5cOmega%28x%29%20%3d%20S%28x%29%5cLambda%28x%29%20%5cbmod%20x%5en%20%3d%20%5csum_%7bj%20%5cin%20E%7d%20%5cleft%28Y_j%20%5cprod_%7bk%20%5cne%20j%7d%20%5cleft%28%31%20%2d%20X_k%20x%5cright%29%5cright%29"
>
</p>
Expand Down

0 comments on commit 5faab16

Please sign in to comment.