-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from hdgarrood/master
euclidean rings etc
- Loading branch information
Showing
14 changed files
with
601 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
The Euclidean Algorithm | ||
======================= | ||
|
||
.. toctree:: | ||
euclidean-algorithm/ex1.rst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Exercise 9.1 | ||
============ | ||
|
||
We want to find the greatest common divisor of :math:`a = 1938` and :math:`b = | ||
782`. We start by dividing :math:`1938` by :math:`782`: | ||
|
||
.. math:: | ||
1938 = 2 * 782 + 374 | ||
And now we divide :math:`798` by the remainder, :math:`374`: | ||
|
||
.. math:: | ||
782 = 2 * 374 + 34 | ||
Then we divide :math:`374` by our new remainder, :math:`34`: | ||
|
||
.. math:: | ||
374 = 11 * 34 | ||
This time, it goes exactly. So the greatest common divisor is :math:`34`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Euclidean rings | ||
=============== | ||
|
||
.. toctree:: | ||
euclidean-rings/ex1.rst | ||
euclidean-rings/ex2.rst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
Exercise 11.1 | ||
============= | ||
|
||
Let :math:`a, b \in \mathbb{Z}`, with both nonzero. We want to show that | ||
:math:`\lvert a \rvert \leq \lvert ab \rvert`. | ||
|
||
There are a few ways to do this. For the way I'm going to use here, our first | ||
step is to show that :math:`\lvert ab \rvert = \lvert a \rvert \lvert b | ||
\rvert` for any integers :math:`a, b.` In fact, this always holds, even if | ||
:math:`a` or :math:`b` is zero. This can be proved by cases. We'll consider | ||
four cases: | ||
|
||
* :math:`a \geq 0, \; b \geq 0` | ||
* :math:`a \geq 0, \; b < 0` | ||
* :math:`a < 0, \; b \geq 0` | ||
* :math:`a < 0, \; b < 0` | ||
|
||
In the first case, since both :math:`a` and :math:`b` are nonnegative, we have | ||
that :math:`\lvert a \rvert = a` and :math:`\lvert b \rvert = b`, so it follows | ||
that :math:`\lvert a \rvert \lvert b \rvert` is equal to :math:`ab`. Also, | ||
since :math:`a` and :math:`b` are both nonnegative, their product :math:`ab` is | ||
also nonnegative, so :math:`\lvert ab \rvert = ab` and we are done. | ||
|
||
In the second case, we have that :math:`\lvert a \rvert = a` as before, but | ||
:math:`\lvert b \rvert = -b`, since :math:`b` is negative, and so the right | ||
hand side is equal to :math:`-ab`. Also, in this case, the product :math:`ab | ||
\leq 0`, so on the left hand side, we have :math:`\lvert ab \rvert = -ab`. So | ||
both sides are equal to :math:`-ab` and we are done. | ||
|
||
The remaining two cases play out similarly, so I won't bother to write them | ||
out. | ||
|
||
Now we know that :math:`\lvert ab \rvert = \lvert a \rvert \lvert b \rvert`, we | ||
can return to our original question. Using our new knowledge, we can rewrite | ||
the statement we are trying to prove as :math:`\lvert a \rvert \leq \lvert a | ||
\rvert \lvert b \rvert`. One thing we can do with inequalities is divide both | ||
sides by a positive number. Since we have by assumption that :math:`a` is | ||
nonzero, it follows that :math:`\lvert a \rvert > 0` and so we can divide both | ||
sides by :math:`\lvert a \rvert`, leaving us with :math:`1 \leq \lvert b | ||
\rvert`. And since :math:`b` is a nonzero integer, :math:`\lvert b \rvert` must | ||
be a positive integer, so :math:`1 \leq \lvert b \rvert` is necessarily true, | ||
and we are done. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Exercise 11.2 | ||
============= | ||
|
||
Let :math:`F` be a field and let :math:`a, b \in F[x]`, with both nonzero. We | ||
want to show that :math:`\deg(a) \leq \deg(ab)`. | ||
|
||
Consider two nonzero polynomials :math:`a, b` and think about their product | ||
:math:`ab`. We already know that the leading term of :math:`ab` comes from the | ||
product of the leading terms of :math:`a` and :math:`b`, whose powers of | ||
:math:`x` will be :math:`\deg(a)` and :math:`\deg(b)` respectively. So the | ||
power of :math:`x` in the leading term of :math:`ab` is :math:`\deg(a) + | ||
\deg(b)`, i.e. :math:`\deg(ab) = \deg(a) + \deg(b)`. | ||
|
||
So our original inequality is equivalent to :math:`\deg(a) \leq \deg(a) + | ||
\deg(b)` or equivalently, :math:`0 \leq \deg(b)`. But we know this to be true | ||
already: the degree of a nonzero polynomial is always nonnegative! So we are | ||
done. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
The Euclidean Algorithm | ||
======================= | ||
|
||
We now return to the familiar world of the integers, where we will learn (or | ||
perhaps remind ourselves) about what the **greatest common divisor** of two | ||
integers is, and about an algorithm which allows us to compute them easily, and | ||
why it works. This will form part of the motivation for the idea of a | ||
**euclidean ring**, a structure which generalises the integers. | ||
|
||
Integer division | ||
---------------- | ||
|
||
Let :math:`a, b \in \mathbb{Z}`. We say that :math:`a` **divides** :math:`b` if | ||
there exists some :math:`q \in \mathbb{Z}` such that :math:`aq = b`. Another | ||
way of understanding this is that :math:`b` can be divided exactly by :math:`a` | ||
to yield :math:`q`. Symbolically, we write :math:`a \mid b`. | ||
|
||
For example, :math:`5 \mid 20`, and also :math:`4 \mid 20`. | ||
|
||
Of course, we often have to deal with the less happy situation where integers | ||
don't divide exactly into each other. All hope is not lost, though: if we have | ||
two integers :math:`a, b`, with :math:`b > 0`, then there always exists a pair | ||
of integers :math:`q` and :math:`r` such that :math:`a = qb + r`, and :math:`0 | ||
\leq r < b`. We usually call :math:`q` the **quotient** and we call :math:`r` | ||
the **remainder**. You probably know already that a remainder of :math:`0` | ||
indicates that the pair of integers we are dealing with do divide into each | ||
other exactly. | ||
|
||
Greatest common divisors | ||
------------------------ | ||
|
||
If :math:`d` divides :math:`a`, and :math:`d` also divides :math:`b`, we say | ||
that :math:`d` is a **common divisor** of :math:`a` and :math:`b`. If :math:`d` | ||
is greater than any other common divisor of :math:`a` and :math:`b`, we say | ||
that :math:`d` is the **greatest common divisor** of :math:`a` and :math:`b`. | ||
This chapter is mostly concerned with finding the greatest common divisor of | ||
any pair of integers; we can do this by using an algorithm called the Euclidean | ||
Algorithm. | ||
|
||
Before we go on to talk about the Euclidean Algorithm, though, we first need a | ||
result concerning divisors. Here it comes: | ||
|
||
Let :math:`a, b, d \in \mathbb{Z}`, and suppose that :math:`d \mid a` and that | ||
:math:`d \mid b`. Then, :math:`d \mid ma + nb` for any :math:`m, n \in | ||
\mathbb{Z}`. | ||
|
||
To prove this, we go back to the definition; we just need to find an integer | ||
:math:`c` such that :math:`cd = ma + nb`. How might we go about that? Well we | ||
already know that :math:`d \mid a`, so we know that there is an integer | ||
:math:`c_1` such that :math:`c_1d = a`. We also know that :math:`d \mid b`, so | ||
we know that there is another integer :math:`c_2` such that :math:`c_2d = b`. | ||
It follows, then, that :math:`mc_1d = ma`, and that :math:`nc_2d = nb`. Add | ||
these equations together and you get :math:`mc_1d + nc_2d = ma + nb`. The | ||
distributive law allows us to rearrange the left hand side, yielding | ||
:math:`(mc_1 + nc_2)d = ma + nb`, from which we can immediately deduce that | ||
:math:`d \mid ma + nb`. | ||
|
||
The Euclidean Algorithm | ||
----------------------- | ||
|
||
We will start by working through an example; suppose we want to find the | ||
greatest common divisor of :math:`a = 1071` and :math:`b = 462`. Let's call | ||
their greatest common divisor :math:`d`. So immediately we have that :math:`d | ||
\mid 1071` and that :math:`d \mid 462`. | ||
|
||
We start by dividing :math:`a` by :math:`b`: | ||
|
||
.. math:: | ||
1071 = 2 * 462 + 147 | ||
That is, we get a quotient of :math:`2` and a remainder of :math:`147`. How | ||
does this help? Well, we now know that :math:`147 = 1071 - 2*462`. Using the | ||
result from a moment ago, if we choose :math:`m = 1` and :math:`n = -2`, we | ||
have that :math:`d \mid ma + nb`, that is, :math:`d \mid 147`. | ||
|
||
We now divide :math:`462` by the remainder: | ||
|
||
.. math:: | ||
462 = 3 * 147 + 21 | ||
Using the same argument as before, we see that :math:`21 = 462 - 3*147` and | ||
therefore :math:`d \mid 21`. We now divide our previous remainder by our new | ||
remainder: | ||
|
||
.. math:: | ||
147 = 7 * 21 | ||
This time, it goes exactly. The significance of this is that we have found our | ||
GCD: it is :math:`21`. Why? Well, starting from the final step and working | ||
backwards, we now know that :math:`21 \mid 147`. Looking to the previous step, | ||
since :math:`21 \mid 147` and :math:`21 \mid 21` (note that any integer divides | ||
itself), we can deduce using that same result from a moment ago that :math:`21 | ||
\mid 3 * 147 + 21` i.e. :math:`21 \mid 462`. Now going back to the very first | ||
step, we can use a similar argument to show that since :math:`21 \mid 462` and | ||
:math:`21 \mid 147`, we have that :math:`21 \mid 1071`. So we have established | ||
that :math:`21` is a common divisor of :math:`1071` and :math:`462`. It then | ||
follows that :math:`d \geq 21`. | ||
|
||
The only way that we can have :math:`d \geq 21` and :math:`d \mid 21` | ||
simultaneously is if :math:`d = 21`, so we're done. | ||
|
||
So the general form of the algorithm is that we keep dividing successive | ||
remainders into each other until we find a pair that go exactly, and then the | ||
last remainder is the greatest common divisor. In PureScript:: | ||
|
||
gcd :: Int -> Int -> Int | ||
gcd a 0 = a | ||
gcd a b = gcd b (a `mod` b) | ||
|
||
(note that ``a `mod` b`` computes the remainder when dividing ``a`` by ``b``.) | ||
|
||
**Exercise 9.1.** Perform the Euclidean Algorithm on :math:`a = 1938`, :math:`b | ||
= 782`. | ||
|
||
How do we know that the algorithm terminates, though? We refer to the theorem | ||
from the beginning of the chapter: | ||
|
||
.. note:: | ||
If we have two integers :math:`a, b`, with :math:`b > 0`, then there always | ||
exists a pair of integers :math:`q` and :math:`r` such that :math:`a = qb + r`, | ||
and :math:`0 \leq r < b`. | ||
|
||
In particular, :math:`r < b`. That is, the remainders *keep getting smaller*. | ||
A sequence of nonnegative integers which keep getting smaller is guaranteed to | ||
eventually reach :math:`0`, so we know that our algorithm will always terminate | ||
and all is well. |
Oops, something went wrong.