Document related concepts

Sieve of Eratosthenes wikipedia , lookup

Algorithm characterizations wikipedia , lookup

Algorithm wikipedia , lookup

Determination of the day of the week wikipedia , lookup

Factorization of polynomials over finite fields wikipedia , lookup

Polynomial greatest common divisor wikipedia , lookup

Euclidean algorithm wikipedia , lookup

Transcript
```1
Elementary Properties of the Integers
1. Basis Representation Theorem (Thm 1-3)
2. Euclid’s Division Lemma (Thm 2-1)
3. Greatest Common Divisor
4. Properties of Prime Numbers
5. Fundamental Theorem of Arithmetic (Thm 2-5)
2
The Integers: Z
For most of this course, we restrict ourselves to the set of integers. Some
helpful hints to keep in mind:
• Addition, subtraction, and multiplication work normally.
The
sum/difference/product of two integers is always another integer.
Commutative, associative, and distributive laws hold.
• The reciprocal of an integer is almost never an integer. What are the
exceptions?
• Division/fractions must be handled with care. If you use a fraction within
an equation, be ABSOLUTELY CERTAIN that the fraction represents
an integer. If you are unsure, don’t use the fraction.
3
• It is valid to use constant fractions within inequalities (example: x > 12 ),
but it may be confusing to do so. Consider the sets:
A=
1
x∈Z:x>
,
2
B = {x ∈ Z : x ≥ 1} .
• The Cancellation Laws still work. If ax = ay, we can cancel the a from
both sides to get x = y, as long as a 6= 0. The same is true for xa = ya.
• Nonnegative integer exponents work normally. Negative or fractional
exponents should generally be avoided. In particular, reciprocals and
roots are not always defined, and might behave differently even when
they exist.
4
The Natural Numbers: N
We will occasionally restrict ourselves to non-negative integers. These are
called Natural Numbers (or Whole Numbers, in older texts).
• Addition and multiplication work normally.
• Negation does not make sense. Subtraction is not always defined.
• Reciprocals, division/fractions, exponents/roots have the same issues as
in Z.
• A nonempty subset of N always contains a minimal element. This is
known as Well-Ordering or the Least Integer Principle.
• Mathematical induction can (and often will be) used to prove that a
result holds for all natural numbers.
5
Integer Division with Remainder
Theorem (Euclid’s Division Lemma (Thm 2-1)). For each integer j and
each positive integer k, there is a unique pair of integers q and r such
that 0 ≤ r < k and j = kq + r.
For j > 0, this is the familiar division problem j ÷ k = q REM r. One way
to find the values of q and r:
• If j < k, we can choose q = 0 and r = j.
• If j ≥ k, then j − k ≥ 0 is still positive. If j − k ≥ k, subtract another
copy of k (to get j − 2k ≥ 0).
• Repeating this, we’ll eventually get a j − qk that is nonnegative and
smaller than k. We let r = j − qk.
6
Note: This is certainly NOT the most efficient way to compute a
quotient/reminder, but it makes for an easy proof (using Well-Ordering).
Proof. (Existence): Given j and k, consider the subset of natural numbers
S = {j − xk : x ∈ Z}. Why is this set nonempty?
• By the Well-Ordering Principle, S has a smallest element. Let r = j − qk
be this smallest element.
• We need to show r < k. Assume this is not true, then r ≥ k and thus
r − k ≥ 0. However,
r − k = (j − qk) − k = j − (q + 1)k.
• Thus r − k ∈ S, but this is impossible, since r − k < r and r was the
smallest element of S.
7
(Uniqueness): Suppose that (q, r) and (q 0, r0) both satisfy the conclusion
of the Theorem. Then
kq + r = kq 0 + r0
since both sides are equal to j. Rearranging gives:
r0 − r
(q − q ) =
.
k
0
• The right-hand side must be an integer (why?)
• We know that 0 ≤ r0 < k and −k < −r ≤ 0. Adding these together
gives −k < r0 − r < k.
• Thus −1 <
r 0 −r
k
< 1. What does this tell us?
8
(Uniqueness, continued):
• The only integer between −1 and 1 is zero.
r 0 −r
k
• We thus have
= 0, which immediately gives r0 = r. This trick is
available precisely because we’ve restricted ourselves to integer values.
• It also follow that q − q 0 = 0. In other words, q = q 0.
This proof contains a common method for showing that a certain object is
unique (in this case, the pair (q, r)): assume you have two things satisfying
a given condition, and show that those two things must be equal.
9
Divisibility (Section 2-2)
Definition. Given an integer n and a nonzero integer d, we say that d
divides n if there is an integer c such that n = cd. We write d | n if d
divides n, and d - n if d does not divide n.
• Note that “d | n is equivalent to “ nd is an integer.” However, you are
• In terms of the Division Lemma, “d | n” is equivalent to “n leaves
a remainder of zero when divided by d.” Keep this in mind: many
divisibility proofs use this idea.
• Divisibility is one of the key concepts of this course. It leads to the idea
of congruence (modulo n), which will be another central theme.
10
Exercise: Properties of Divisibility
Prove these directly from the definition (do not use fractions!):
• If a is a nonzero integer, then a | 0 and 1 | a.
• If a | b and b | c, then a | c.
• [IMPORTANT!] If d | a and d | b, then d | (am + bn) for any m, n ∈ Z.
• If a | b and b | a, then a = ±b.
Find positive integers a, b, c such that a | bc, but a - b and a - c.
11
Greatest Common Divisor/Factor
• You know from basic arithmetic that, given two integers, we can find
their greatest common divisor (or greatest common factor ).
• One way to find a g.c.d. is using prime factorization. For example:
– 1512 = 23 · 33 · 7
– 4410 = 2 · 32 · 5 · 72
– gcd(1512, 4410) = 2 · 32 · 7 = 126
• This is not always so simple. Try finding
– gcd(18, 42) (easy!)
– gcd(629, 1517) (more work!)
12
We use the following definition of gcd(a, b):
Definition (2-1). Let a and b be two integers, not both zero. The greatest
common divisor of a and b is a positive integer d which satisfies the
following properties:
1. d | a and d | b. In other words, d is a common divisor of a and b.
2. For any positive integer c for which c | a and c | b, we have c | d.
Thus, any common divisor of a and b must also divide d.
• This definition is easier to use in practice.
• It can be shown that if d satisfies this definition and c is any common
divisor of a and b, then d ≥ c.
13
The Euclidean Algorithm
It turns out that we can compute a gcd without using prime factorization.
For example, we find gcd(1517, 629) by repeated use of the Division Lemma:
1517 =(629)(2) + 259
629 =(259)(2) + 111
259 =(111)(2) + 37
111 =(37)(3) + 0
• To show that 37 is a common divisor, start with the last equation and
work up.
• To show any common divisor divides 37, start with the first equation and
work down.
14
The Euclidean Algorthim
The same process can be used to find gcd(a, b) if a and b are positive:
1. Let DIVIDEND = larger of a and b, DIVISOR = smaller of a and b.
2. Find the REMAINDER of DIVIDEND ÷ DIVISOR.
3. If REMAINDER = 0, then DIVISOR is the gcd. [Stop]
4. Otherwise, let DIVIDEND = DIVISOR, then DIVISOR = REMAINDER.
5. Go back to step 2.
15
Exercises: Euclidean Algorithm
Use the Euclidean Algorithm to find the following gcd’s. Keep all of your
work; we will use it for a different purpose later.
• gcd(90, 25)
• gcd(2499, 182)
• gcd(629, 518)
• gcd(4721, 1361)
• gcd(89, 55)
16
Theorem (2-2). If a and b are integers, not both zero, then gcd(a, b)
exists and is unique.
Note that this result is trivial if either a or b is zero. Also note that changing
the sign of a or b or swapping a for b does not change the gcd. Without
loss of generality, we may thus assume that 0 < b ≤ a.
For existence, we need to show that the Euclidean Algorithm eventually
produces a remainder of zero, at which point the algorithm terminates.
This follows from the Division Lemma, noting that the remainder at any
stage is always smaller than the divisor at that stage. Since the remainder at
one stage becomes the divisor in the next stage, the sequence of remainders
decreases by at least 1 at each step.
Thus, we have 0 ≤ ri ≤ b − i. So we get a remainder of zero after at most
a steps (and usually, much fewer).
17
The equation ax + by = c
Choose nonzero integers a, b, c. Are there integers x, y that satisfy the
above equation?
• Suppose such integers x and y do exist. Let d = gcd(a, b).
• Since x and y are integers, the left-hand side is divisible by d.
• So a necessary condition is that gcd(a, b) | c. If this is not true, then
we cannot find integers x, y that satisfy the equation.
• It turns out that this condition is also sufficient.
• The difficult step is using the Euclidean Algorithm to solve ax + by = d;
the rest is very easy.
18
Here is most of our work from gcd(1517, 629) = 37. I’ve rearranged each
equation on the right to help with the upcoming process:
1517 = (629)(2) + 259 −→ 259 = 1517 − 2
629 = (259)(2) + 111 −→ 111 = 629 − 2
259 = (111)(2) + 37 −→ 37 = 259 − 2(111)
Start with the last equation, substitute the value of 111 and simplify:
37 = 259 − 2(111) = 259 − 2(629 − 2) = 5(259) − 2(629).
We can now use the same process to eliminate 259:
37 = 5(259) − 2(629) = 5(1517 − 2) − 2(629) = 5(1517) − 12(629).
19
The general case: ax + by = c
To find a solution, assuming c = m · gcd(a, b):
• Find x, y such that ax + by = gcd(a, b). You can use the method based
on the Euclidean Algorithm, although you might find a solution by lucky
guess.
• Multiply both sides of the equation by m; rearrange to get
a(xm) + b(xm) = c.
Note: In each case, these methods produce only one solution. We’ll see
that if there is at least one solution, then there are infinitely many.
```