(* You should be able to copy and paste this text file directly into Mathematica. These notes will be interpreted as commented code. *) (* Here are some useful functions for computing common divisors and doing the Euclidean algorithm in Z[i] and F[x] *) QuotientRemainder[7+3I, 2+2I] (* This computes the quotient and remainder when dividing 7+3i by 2+2i in Z[i]. The QuotientRemainder[] command automatically recognizes Gaussian integers when you use them. Note that the imaginary unit i must be capitalized as "I" for Mathematica to recognize it as the square root of -1. *) GCD[7+3I, 2+2I] (* This computes the GCD of 7+3i and 2+2i in Z[i]. The GCD[] command automatically recognizes Gaussian integers when you use them. *) ExtendedGCD[7+3I, 2+2I] (* This computes the GCD d of a,b along with Gaussian integers {x,y} such that d = xa + yb. The ExtendedGCD[] command automatically recognizes Gaussian integers when you use them. *) PolynomialQuotientRemainder[x^3 + 2x + 7, x^2 + x + 1, x] (* This computes the quotient and remainder when dividing x^3 + 2x + 7 by x^2 + x + 1, where the variable is x. Note that the third argument x is needed to tell Mathematica what variable is being used. By default, Mathematica will return quotients and remainders with complex coefficients (though of course here, the coefficients are all rational numbers). *) PolynomialQuotientRemainder[x^3 + 2x + 7, x^2 + x + 1, x, Modulus -> 3] (* This computes the quotient and remainder when dividing x^3 + 2x + 7 by x^2 + x + 1, where the variable is x, and the coefficients are considered modulo 3 -- in other words, it performs the computations in the polynomial ring F_3[x]. You can set the modulus to be any prime number. *) PolynomialGCD[x^3 + 2x + 7, x^2 + x + 1] (* This computes the polymomial GCD of x^3 + 2x + 7 and x^2 + x + 1. Note that you do *not* pass PolynomialGCD[] the variable name x. *) PolynomialGCD[x^3 + 2x + 7, x^2 + x + 1, Modulus -> 13] (* This computes the polymomial GCD of x^3 + 2x + 7 and x^2 + x + 1 with coefficients modulo 13. Note that you do *not* pass PolynomialGCD[] the variable name x. *) PolynomialExtendedGCD[x^3 + 2x + 7, x^2 + x + 1, x] (* This computes the polymomial GCD of x^3 + 2x + 7 by x^2 + x + 1 along with polynomials s and t such that sa + tb = d. Note that you *do* pass PolynomialExtendedGCD[] the variable name x. *) (* Here are some useful functions for doing modular arithmetic in Z[i] and F[x] *) Mod[7+3I, 2+2I] (* This computes the remainder when 7+3i is divided by 2+2i -- in other words, a small residue class representing 7+3i mod 2+2i in Z[i]. *) PolynomialMod[x^3 + 2x + 7, x^2 + x + 1] (* This computes the remainder when x^3 + 2x + 7 is divided by x^2 + x + 1 -- in other words, a small residue class representing x^3 + 2x + 7 mod x^2 + x + 1 in Q[x] or R[x] or C[x]. Note that you do *not* pass PolynomialMod[] the variable x. *) PolynomialMod[x^3 + 2x + 7, x^2 + x + 1, Modulus -> 13] (* This computes the remainder when x^3 + 2x + 7 is divided by x^2 + x + 1 where coefficients are considered mod 13 -- in other words, a small residue class representing x^3 + 2x + 7 mod x^2 + x + 1 in F_13[x]. Note that you do *not* pass PolynomialMod[] the variable x. *) (* Here are some useful other functions *) Expand[(2-I)(3+2I)] (* This expands the product of Gaussian integers above. *) Simplify[(9 + 8I) / (2 - 3I)] (* This simplifies the quotient of Gaussian integers above. Both Expand[] and Simplify[] can be used to evaluate expressions. Simplify will sometimes factor expressions, which may not be what you want. *) Simplify[(2 + Sqrt[-10]) (3 - Sqrt[-10])] (* This expands the product of elements of Z[sqrt(-10)] above. Mathematica will generally write square roots of negative numbers as a multiple of i. *) FullSimplify[(33 + 5 Sqrt[-2]) / (8 + 11 Sqrt[-2])] (* Sometimes Simplify won't actually simplify an expression. FullSimplify[] will work harder to simplify expressions. For this quotient of elements of Z[sqrt(-2)], Simplify[] will just return the quotient again, but FullSimplify[] will actually rationalize the denominator and return a simplified expression. *)