{VERSION 6 0 "IBM INTEL LINUX" "6.0" }
{USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0
1 0 0 0 0 1 }{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Heading
1" 0 3 1 {CSTYLE "" -1 -1 "" 1 18 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }1 0 0
0 8 4 0 0 0 0 0 0 -1 0 }{PSTYLE "Heading 2" 3 4 1 {CSTYLE "" -1 -1 ""
1 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }0 0 0 -1 8 2 0 0 0 0 0 0 -1 0 }
{PSTYLE "Title" 0 18 1 {CSTYLE "" -1 -1 "" 1 18 0 0 0 0 0 1 1 0 0 0 0
0 0 0 }3 0 0 -1 12 12 0 0 0 0 0 0 19 0 }{PSTYLE "Author" 0 19 1
{CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 0 0 -1 8 8 0 0
0 0 0 0 -1 0 }}
{SECT 0 {EXCHG {PARA 18 "" 0 "" {TEXT -1 27 "Modular Arithmetic in Map
le" }}}{EXCHG {PARA 19 "" 0 "" {TEXT -1 55 "Mike O'Sullivan\nSan Diego
State University\nOctober 2004" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1
205 "A key component of algebraic number theory is modular arithmetic.
In this worksheet we will start with the basics of arithmetic in Z/n
and then move on to polynomials over Z/n and linear algebra over Z/n.
" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}}{SECT 1
{PARA 3 "" 0 "" {TEXT -1 19 "Modular Arithmetic" }}{EXCHG {PARA 0 ""
0 "" {TEXT -1 86 "Fortunately, Maple makes has some built in functions
that make computing mod n simple." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}
}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "73 -590 mod 73;\n25*73 mod \+
99;" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT
-1 69 "To make Maple think before it computes, use the \"neutral opera
tor\" &." }}{PARA 0 "" 0 "" {TEXT -1 177 "You'll see the difference he
re. In the first case it computes 66^1235346462356 and then reduces. \+
In the second it uses the repeated squaring method and reduces as it \+
proceeds." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "66^12353464623
56 mod 99;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "66 &^12353464
62356 mod 99;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 62 "Inverting mod n \+
is simple. Of course it isn't always defined." }}}{EXCHG {PARA 0 "> \+
" 0 "" {MPLTEXT 1 0 18 "53^(-1) mod 99; \n" }}}{EXCHG {PARA 0 "> " 0
"" {MPLTEXT 1 0 15 "66^(-1) mod 99;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0
0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "
" 0 "" {TEXT -1 113 "Let u be a unit mod n. now consider all of the p
owers of u. We will see in class that they must all be units. " }}
{PARA 0 "" 0 "" {TEXT -1 102 "The first repetition in the sequence u^k
mod n for k = 0 to infinity is some r such that u^r= 1 mod n." }}
{PARA 0 "" 0 "" {TEXT -1 39 "We call r the \"order of u modulo n\". \+
" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 19 "Here \+
is an example." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> \+
" 0 "" {MPLTEXT 1 0 18 "n:= 19;\n\nu := 4;\n " }}}{EXCHG {PARA 0 "> "
0 "" {MPLTEXT 1 0 45 "for i from 1 to n do\n i, u^i mod n;\nod; \n \+
" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 85 "So the order of 2 mod 19 is 1
8.\nNow change the value of u and see what orders occur.\n" }}{PARA 0
"" 0 "" {TEXT -1 35 "You can also change the value of n." }}{PARA 0 "
" 0 "" {TEXT -1 52 "Remember that you can only find the order of a uni
t!" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "
" 0 "" {TEXT -1 0 "" }}}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 9 "Exercises
" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 98 "1) Write a procedure that, gi
ven u and n ,finds the order of u modulo n. Use the for loop above."
}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 181 "2) Wr
ite a procedure that, given n, outputs each unit u and the order of th
at unit.\n\n3) Write a procedure that, given n, outputs the number of
units mod n that have a given order." }}{PARA 0 "" 0 "" {TEXT -1 66 "
That is count the number of elements of order r and output " }}
{PARA 0 "" 0 "" {TEXT -1 43 " r, the number of elements of order r
.\n" }}{PARA 0 "" 0 "" {TEXT -1 54 "4) Experiment! What orders do you
get? And how many." }}}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 ""
}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 19 "Solving Polynomials" }}{EXCHG
{PARA 0 "" 0 "" {TEXT -1 38 "You can also solve equations modulo m." }
}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "msolve(\{3*x-4*y=1,7*x+y=2
\},19);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 110 "Integers a such that \+
x^2 = a mod m has a solution (with a not congruent to 0) are called qu
adratic residues. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 37 "msol
ve(x^2 = 5 , 17); #no solutions" }}}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 20 "msolve(x^2 = 8, 17);" }}}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 18 "msolve(x^2= 1, 8);" }}}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 0 "" }}}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 9 "Exercises" }}
{EXCHG {PARA 0 "" 0 "" {TEXT -1 84 "1) Find all quadratic residues mod
ulo 8. Find the number of square roots for each.\n" }}{PARA 0 "" 0 "
" {TEXT -1 80 "2) Find all quadratic residues mod 15. Does x^2 = 2y^
2 mod 15 have a solution?" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "
" 0 "" {TEXT -1 66 "3) Write a procedure that computes all quadratic r
esidues mod n. " }}{PARA 0 "" 0 "" {TEXT -1 61 " Experiment with \+
different n. Can you form a conjecture?" }}{PARA 0 "" 0 "" {TEXT -1
0 "" }}{PARA 0 "" 0 "" {TEXT -1 88 "4) How many solutions do you thin
k a quadratic equation can have? How many on average?" }}{PARA 0 ""
0 "" {TEXT -1 40 " Can you think of some experiments?" }}}}}
{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{SECT 1 {PARA 3 "" 0 ""
{TEXT -1 14 "Linear Algebra" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 40 "Now
let's do some linear algebra mod m;." }}{PARA 0 "" 0 "" {TEXT -1 57 "
We need to include a package of linear algebra functions." }}{PARA 0 "
" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "with
(LinearAlgebra:-Modular);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0
"" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "m := 19;" }}}{EXCHG
{PARA 0 "" 0 "" {TEXT -1 175 "The function RandomMatrix() chooses the \+
entries of a matrix to be between -100 and +100.\n If you want the ent
ries to be in a specified range, then put in the generator clause." }}
}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "N := LinearAlgebra[RandomMa
trix](2,2);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 55 "N := LinearA
lgebra[RandomMatrix](2,2,generator=0..m-1);" }}}{EXCHG {PARA 0 "" 0 "
" {TEXT -1 98 "Normally you can compute the inverse of a matrix, or th
e product very simply using M^(-1) or M.N.\n" }}}{EXCHG {PARA 0 "> "
0 "" {MPLTEXT 1 0 21 "Ninv := N^(-1); N.N;" }}}{EXCHG {PARA 0 "" 0 "
" {TEXT -1 42 "Here is how to do these computations mod m" }}}{EXCHG
{PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "Ninv := Inverse(m,N); Multiply(m,N,
N);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 61 "I haven't found a way to e
xponentiate, so let's make our own." }}}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 208 "Exponentiate := proc(m, N, r)\nlocal d, Pow, i;\n\nd
:= Dimension(N)[1];\n#Create the identity matrix.\nPow := Identity(m,
d, integer); \nfor i from 1 to r do\n Pow := Multiply(m,Pow, N);\nod
;\nRETURN(Pow);\nend proc;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}
{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "Exponentiate(m,N,1);N;" }}}
{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "Determinant(m,N);" }}}{SECT
1 {PARA 4 "" 0 "" {TEXT -1 9 "Exercises" }}{EXCHG {PARA 0 "" 0 ""
{TEXT -1 71 "1) Solve some of the linear congruence problems Rosen u
sing matrices." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 ""
{TEXT -1 91 "2) How many invertible 2x2 matrices are there mod n? Tr
y for a number of different n. " }}{PARA 0 "" 0 "" {TEXT -1 56 " \+
Compare your results on the number of units mod n." }}{PARA 0 "" 0
"" {TEXT -1 0 "" }}}}}}{MARK "8" 0 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }
{PAGENUMBERS 0 1 2 33 1 1 }