can be done by direct solution for Yk in the error equations matrix given above, or using the Forney algorithm. Calculate the error locations Calculate ik by taking the log base of Xk. This is generally done using a precomputed lookup table. Fix the errors Finally, e(x) is generated from ik and eik and then is subtracted from r(x) to get the originally sent message s(x), with errors corrected. Example Consider the Reed–Solomon code defined in with and (this is used in PDF417 barcodes) for a RS(7,3) code. The generator polynomial is If the message polynomial is , then a systematic codeword is encoded as follows. Errors in transmission might cause this to be received instead. The syndromes are calculated by evaluating r at powers of α. Using Gaussian elimination: The coefficients can be reversed to produce roots with positive exponents, but typically this isn't used: with the log of the roots corresponding to the error locations (right to left, location 0 is the last term in the codeword). To calculate the error values, apply the Forney algorithm. Subtracting from the received polynomial r(x) reproduces the original codeword s. Berlekamp–Massey decoder The Berlekamp–Massey algorithm is an alternate iterative procedure for finding the error locator polynomial. During each iteration, it calculates a discrepancy based on a current instance of Λ(x) with an assumed number of errors e: and then adjusts Λ(x) and e so that a recalculated Δ would be zero. The article Berlekamp–Massey algorithm has a detailed description of the procedure. In the following example, C(x) is used to represent Λ(x). Example Using the same data as the Peterson Gorenstein Zierler example above: The final value of C is the error locator polynomial, Λ(x). Euclidean decoder Another iterative method for calculating both the error locator polynomial and the error value polynomial is based on Sugiyama's adaptation of the extended Euclidean algorithm . Define S(x), Λ(x), and Ω(x) for t syndromes and e errors: The key equation is: For t = 6 and e = 3: The middle terms are zero due to the relationship between Λ and syndromes. The extended Euclidean algorithm can find a series of polynomials of the form where the degree of R decreases as i increases. Once the degree of Ri(x) < t/2, then B(x) and Q(x) don't need to be saved, so the algorithm becomes: R−1 := xt R0 := S(x) A−1 := 0 A0