Skip to content

Instantly share code, notes, and snippets.

@artemjackson
Last active June 2, 2016 22:04
Show Gist options
  • Save artemjackson/e3d6bc24da1b40354b7de0329e86374a to your computer and use it in GitHub Desktop.
Save artemjackson/e3d6bc24da1b40354b7de0329e86374a to your computer and use it in GitHub Desktop.
inverse polynomial in GF
(* обратный в поле полином *)
PolynomialBase = x^8 + x^4 + x^3 + x + 1;
NumericBase = 2;
InversePolynomial[p_] := Block[{result, polynomial = p, i, d, a, b},
{d, {a, b}} = PolynomialExtendedGCD[polynomial, PolynomialBase, x, Modulus -> NumericBase];
Return[PolynomialMod[a, NumericBase]];
];
InversePolynomial[x^2 + 1]
(* x + x^4 + x^6 *)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment