Math 480, Spring 2015, Assignment 2
From cartan.math.umb.edu
Carefully define the following terms, then give one example and one non-example of each:[edit]
- Fast algorithm.
- Divisibility (of one integer by another).
- Greatest common divisor.
- Relatively prime.
- Congruent modulo $m$.
- $\mathbb{Z}/m\mathbb{Z}$ (as a structure, with addition and multiplication operations).
- Multiplicative inverse (modulo $m$).
- Euler totient function.
Carefully state the following theorems (you do not need to prove them):[edit]
- Theorem on the time complexity of the Euclidean algorithm (this is the statement following item (5) in Theorem 1.7).
- Theorem on the time complexity of exponentiation by repeated squaring.
Carefully describe the following algorithms:[edit]
- Division with remainder.
- Extended Euclidean algorithm.
- Algorithms for addition, subtraction, and multiplication in $\mathbb{Z}/m\mathbb{Z}$.
- Algorithms for inversion and division in $\mathbb{Z}/m\mathbb{Z}$.
- Algorithm for exponentiation in $\mathbb{Z}/m\mathbb{Z}$ (by repeated squaring, not by naive multiplication).
Solve the following problems:[edit]
- Exercises 1.6, 1.9, 1.15, and 1.16.
Coding projects:[edit]
- (Euclidean algorithm) Implement the extended Euclidean algorithm (i.e. write a function that takes two integers $a$ and $b$ as inputs and returns integers $x$, $y$, and $d$ with $d=\mathrm{gcd}(a, b)$ and $xa + yb = d$.)
- (Modular arithmetic) Implement the structure $\mathbb{Z}/m\mathbb{Z}$ with all of its operations (i.e. addition, subtraction, multiplication, inversion, division, and exponentiation). If your language supports object-oriented programming, then it is probably a good idea to write a class whose instances represent elements of $\mathbb{Z}/m\mathbb{Z}$. Each instance could store two integers (let's call them value and modulus) as data members, and the class could provide methods for all of the operations, as well as a method that provides a string representation for output to the screen. Your inversion method should throw an exception when called on a non-invertible element, and your remaining methods should throw exceptions when called on arguments with unequal moduli. (If your language does not support OOP, then you can implement elements of $\mathbb{Z}/m\mathbb{Z}$ as two-element structs, and just write functions for the operations. If exception handling is not available, then you can simulate exceptions by making each function return an integer status code.)