If are nonzero integers, , and is one solution of the linear Diophantine equation , then all solutions are
Subtract two solutions and use the fact that and are coprime integers. The linear Diophantine equation solvability criterion says that a particular solution exists exactly when divides ; the extended Euclidean algorithm constructs one. This parametrization separates existence from the complete family of answers.
Bézout coefficient 2026-10-13
Bézout coefficients for integers are integers satisfying Bézout's identity . The extended Euclidean algorithm computes one pair. They need not be unique: both and work for , since and .
Bézout's identity 2026-10-13
For integers not both zero, there are integers such that . The extended Euclidean algorithm constructs them. For example, and ; the second identity also gives the modular inverse of modulo .
The identity converts a greatest common divisor into a solvability certificate. The linear Diophantine equation is solvable in integers precisely when divides . Every common divisor divides any integer linear combination; conversely, multiplying a Bézout identity by constructs a solution when that quotient is integral. The coefficients generally are not unique, as the description of all solutions of a linear Diophantine equation makes explicit.
For univariate polynomials over a field, not both zero, there are polynomials such that , where is their monic greatest common divisor. In particular, coprime polynomials admit . The extended Euclidean algorithm constructs the coefficients.
Modular exponentiation Created 2026-10-06 Updated 2026-10-20
Modular exponentiation computes the remainder for an integer base , a nonnegative integer exponent , and, here, an integer modulus . It applies exponentiation by squaring while reducing after each multiplication, including each squaring. The result is the unique representative in . There is no requirement that the base be coprime to the modulus when the exponent is nonnegative.[ref]
Take , , and . Initialize ; the remaining digits give
Hence . The final operation multiplies by , since the preceding square has already been reduced. The computation never needs to construct .
In general reduce the base first, . For , initialize and process the remaining binary digits with , followed, for a digit one, by . The loop invariant is
where is the processed prefix value. The congruence is preserved because modular arithmetic respects multiplication: if , then and . Thus changing representatives never changes the final congruence class.
Both factors in every product are less than , so the unreduced product is less than , and the stored result is again less than . The same bounds hold for a gigantic exponent, such as : there are squarings, each on bounded-size residues. For base two, the corresponding ordinary power would have binary digits. The benefit is avoiding the huge ordinary power altogether, rather than constructing it and taking one final remainder. Initial reduction is essential when the supplied base is much larger than the modulus.
For , return under the same empty-product convention as exponentiation by squaring. For , require , find the modular multiplicative inverse , and compute ; the extended Euclidean algorithm can find that inverse. Its cost is separate from the positive-exponent binary powering multiplication count. For example, , while is undefined because and are not coprime.
Modular inversion 2026-10-20
The computation of an integer satisfying . An inverse exists exactly when . The extended Euclidean algorithm produces such an from a Bezout identity .
For distinct evaluation points and , the Reed-Solomon code is
This is a linear code of dimension : evaluation is linear, and a nonzero polynomial of degree less than cannot vanish at all distinct points. The assertion of cyclicity concerns the primitive, unextended construction: set and , where generates the multiplicative group of a finite field . Arbitrary evaluation sets or arbitrary coordinate orders need not make a Reed-Solomon code a cyclic code.
For this ordered full-length construction, shifting the evaluation vector to the right gives . This is the evaluation vector of , whose degree is still less than , so it is a cyclic code. Its generator polynomial follows from the finite geometric series
Here the scalar is nonzero in . Write and . For ,
since . Thus every word is divisible by . This monic divisor of generates a cyclic code of dimension , equal to the evaluation code by inclusion and dimension. Hence
It is useful to allow a starting exponent for the consecutive zeros of a cyclic code. Define the primitive cyclic Reed-Solomon code
All exponents are understood modulo . The same geometric-sum calculation shows that
Indeed evaluating its word polynomial at , , gives sums with exponents between one and . This is a generalized Reed-Solomon code, with nonzero coordinate multipliers ; is the unweighted evaluation code. Directly, a right shift corresponds to replacing by , so these offset codes are also cyclic codes.
A maximum distance separable code, or MDS code, is a linear code attaining the Singleton bound, with . To see the bound, deleting any coordinates is injective on a code of minimum Hamming distance , since two words with the same puncture would differ in at most positions. Therefore and . For a nonzero Reed-Solomon evaluation word, the polynomial has at most distinct polynomial roots, so at least coordinates are nonzero. Nonzero coordinate multipliers do not change these zero positions. This proves for both Reed-Solomon codes and generalized Reed-Solomon codes. Equality can also be exhibited: choose any evaluation points and take their linear factors as ; it vanishes exactly at those points and has weight . Thus
The duality of primitive cyclic Reed-Solomon codes is especially transparent in the evaluation form. Assume first . A vector of has coordinates , ; a vector of has coordinates , . Their standard dot product is
Every monomial in has exponent at least one and at most , and every such power sum vanishes. Thus . Both sides have dimension , giving
In particular has generator . This agrees with the general dual of a cyclic code rule: invert the roots belonging to the complementary factor . The dual is a Reed-Solomon code in the consecutive-zero convention. With the strictly unweighted evaluation definition, its coordinates instead have the form , so it is a generalized Reed-Solomon code; it need not equal the unweighted code of dimension on the same points. This convention distinction is essential. The case is the full word space and its dual is the zero code, obtained by taking .
For code encoding, use the finite-field discrete Fourier transform and its inverse:
For a message , put for , and set all other transform coordinates to zero. The inverse discrete Fourier transform returns
The zero transform coordinates are precisely the root checks defining . This gives non-systematic encoding by evaluation. For systematic polynomial encoding of a cyclic code with a message polynomial of degree less than , put and calculate the remainder of upon division by . Then is divisible by , and the last coefficients are the message coefficients. Both methods use the same generator polynomial and the same ordered powers of .
For bounded-distance decoding, let , put , and assume at most symbol errors. The following description uses the Reed-Solomon key equation and fixes the transform and locator conventions explicitly.
  • Set , all other error coordinates to zero, and output . Verify that all root checks vanish and that the correction has weight at most . Recover the message from the unconstrained transform coordinates by , or from the last coefficients if systematic encoding was used.
The denominator in the Forney algorithm is nonzero for distinct locations. The minimum-distance error-detection and correction guarantee gives unique recovery because . If the required locator or a valid correction cannot be found, declare decoding failure. Beyond errors, a received word may lie near a different codeword, so successful root checks alone do not certify recovery of the originally transmitted message. The guaranteed correction radius is symbol errors.
The integer is prime: none of the primes below divides it. Since , Fermat's little theorem gives . Therefore is the modular inverse of . The extended Euclidean algorithm yields
and back-substitution gives . Consequently
Indeed, , directly checking the required modular inverse.
The Euclidean algorithm gives
Thus the greatest common divisor is . The extended Euclidean algorithm reverses these divisions:
This supplies the Bezout identity with , .
To obtain all solutions of a linear Diophantine equation, subtract this particular solution from any other and divide by . The result is . Since and are coprime integers, divides , giving
Every displayed pair satisfies the original linear Diophantine equation, so the parametrization is exhaustive.
For the modular arithmetic calculation, , so is the modular inverse of . Multiplication gives . The admissible integers are for , ending at ; the next is . There are such integers.
The extended Euclidean algorithm gives
Back-substituting in these equations produces the Bezout identity
Thus one integer solution is . In fact, subtracting this Bezout identity from any other solution and using that and are coprime integers gives all solutions: , , where .
For the modular arithmetic calculation, is a prime number and is coprime to it, so Fermat little theorem gives . Since , and the preceding Bezout identity identifies as the modular multiplicative inverse of , we obtain
Consequently the least positive representative is .
In the RSA cryptosystem, choose distinct large primes , put , and choose coprime to
The decryption exponent is the modular multiplicative inverse
Thus . For a message with , the Fermat-Euler theorem gives
For , . The extended Euclidean algorithm gives
so
Reed-Solomon key equation 2026-10-14
With syndromes and distinct error-location values , form and the error locator polynomial . There is an error evaluator polynomial of degree less than the number of errors satisfying the key equation. When the number of errors is at most , the Berlekamp-Massey algorithm or extended Euclidean algorithm recovers these polynomials, normalized by .
Unit modulo n Created 2026-09-29 Updated 2026-10-14
For a positive integer modulus , a residue class is a unit when it has a modular multiplicative inverse: some integer satisfies . Modulo twelve, the units are exactly
In particular, five is its own modular inverse, since . Multiplying all twelve residue classes by five gives a permutation; multiplying the outputs by five recovers the inputs. By contrast, multiplying by six gives only zero and six, with six inputs for each output. It cannot be reversed.
Figure 1.
Multiplication by five permutes all twelve residue classes, whereas multiplication by six merges distinct inputs
. Details.
In general, the exact criterion is
For the forward direction, implies every common divisor of divides one. Conversely, if their greatest common divisor is one, Bézout's identity supplies , so is a modular inverse. The extended Euclidean algorithm computes these coefficients. The units form the unit group under multiplication. [ref]
Multiplicative cancellation while keeping the same integer modulus is valid for a unit modulo n: from , multiply by a modular inverse of to get . A nonunit cannot be cancelled as a general rule. For example, , yet . Thus division by six cannot undo this multiplication; solving a linear congruence instead keeps track of all possible classes.
This distinction marks the boundary between commutative rings and fields. Modulo a prime number , every nonzero residue class is a unit, so is a finite field. Modulo twelve it is a commutative ring with zero divisors, and is not a field. For , the sole class satisfies and is a unit; this one-element zero ring is not a field. [ref]