Difference between revisions of "Euclidean division algorithm"
Line 5: | Line 5: | ||
{{:Proof:Euclidean division algorithm}} | {{:Proof:Euclidean division algorithm}} | ||
− | Note that even though this is a proof, it also contains an ''algorithm'' for finding the [[quotient]] and [[remainder]]. If <math>a = 0</math>, follow the instructions in the base case; if <math>a > 0</math>, then first find the quotient q' and remainder r' for <math>a' = a-1</math> and <math>b</math>, then follow the instructions in the inductive step. Of course, while we are finding <math>q'</math> and <math>r'</math>, we may need to also find the quotient <math>q''</math> and remainder <math>r''</math> of <math>a'' = a'-1</math> and <math>b</math>, and so on. | + | Note that even though this is a proof, it also contains an ''algorithm'' for finding the [[quotient]] and [[remainder]]. If <math>a = 0</math>, follow the instructions in the base case; if <math>a > 0</math>, then first find the quotient q' and remainder r' for <math>a' = a-1</math> and <math>b</math>, then follow the instructions in the inductive step. Of course, while we are finding <math>q'</math> and <math>r'</math>, we may need to also find the quotient <math>q' '</math> and remainder <math>r' '</math> of <math>a' ' = a'-1</math> and <math>b</math>, and so on. |
This is a general pattern: most [[specific|proofs that something exists]] give you instructions for finding it. In fact, there are whole programming languages where instead of writing a program, you write a proof; after the computer checks your proof, it extracts a program for you (which is guaranteed to be correct!). | This is a general pattern: most [[specific|proofs that something exists]] give you instructions for finding it. In fact, there are whole programming languages where instead of writing a program, you write a proof; after the computer checks your proof, it extracts a program for you (which is guaranteed to be correct!). |
Revision as of 21:55, 25 September 2018
While studying number theory, we will be primarily interested in the properties of the integers and natural numbers. This means that if we want to write something like " ", we'll have to be very careful to check that divides . This makes everything very complicated, so instead, we'll avoid dividing natural numbers.
We can, however, do division with remainder. The Euclidean division algorithm is just a fancy way of saying this:
Here quotient and remainder of over :
and are theNote that all this is a theorem, it is called the "Euclidean division algorithm" because its proof contains an algorithm.
Base case: We want to show P(0). Let . Then and since .
Inductive step: Assume ; we want to show . By , we know that there exists numbers and such that . We want to show that there exists numbers and such that .
Since either or . In the former case, we can let and . Then (and clearly ).
, we know thatIn the latter case, we can let and . Then . Again it is clear that .
In either case, we have shown that there exist and satisfying (1) and (2), as required.Note that even though this is a proof, it also contains an algorithm for finding the quotient and remainder. If , follow the instructions in the base case; if , then first find the quotient q' and remainder r' for and , then follow the instructions in the inductive step. Of course, while we are finding and , we may need to also find the quotient and remainder of and , and so on.
This is a general pattern: most proofs that something exists give you instructions for finding it. In fact, there are whole programming languages where instead of writing a program, you write a proof; after the computer checks your proof, it extracts a program for you (which is guaranteed to be correct!).