22
Elementary Number Theory Franz Luef Franz Luef MA1301

Elementary Number Theory - NTNU

  • Upload
    others

  • View
    13

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Elementary Number Theory - NTNU

Elementary Number Theory

Franz Luef

Franz Luef MA1301

Page 2: Elementary Number Theory - NTNU

Congruences – Modular Arithmetic

Congruence

The notion of congruence allows one to treat remainders in asystematic manner. For each positive integer greater than 1there is an arithmetic mod n that mirrors ordinaryarithmetic, but is finite, since it involves only the remainders0, 1, ..., n − 1 occuring on division by n.

Definition

Integers a and b are said to be congruent mod n, written

a ≡ b mod n,

if they leave the same remainder on division by n.In other words, a ≡ b mod n, if n divides a− b.

Franz Luef MA1301

Page 3: Elementary Number Theory - NTNU

Congruences

Definition

The set of remainders {0, 1, ..., n − 1} is called the leastsytem of residues modulo n.

We denote the system of residues modulo n bu Zn.

A set of integers a1, ..., an form a complete system ofresidues modulo n if these are congruent to {0, ..., n− 1}modulo n.

The integers that leave remainder r on division by n formwhat is called the congruence class of a,

{nk + a : k ∈ Z},

denoted by nZ + a. For example, 2Z is {even numbers}and 2Z + 1 is {ood numbers}. Each congruence class is aset of equally spaced points along the real line.

Franz Luef MA1301

Page 4: Elementary Number Theory - NTNU

Examples

Examples

8 ≡ 3 mod 5, since 8− 3 = 1 · 5Complete set of residues modulo 5: {0, 1, 2, 3, 4} but also{−5, 11, 32,−13, 24}Fact: A set of n integers a1, ..., an forms a complete set ofresidues modulo n if and only if NO two integers ai and ajare congruent modulo n, i.e. ai − aj = k · n does not holdfor a k ∈ Z.

One can add and multiply congruences very much like onecan add and multiply integers:Modular Arithmetic.

Franz Luef MA1301

Page 5: Elementary Number Theory - NTNU

Modular Arithmetic

Basic Rules

a ≡ a mod n

If a ≡ b mod n, then b ≡ a mod n.

If a ≡ b mod n and b ≡ c mod n, then a ≡ c mod n.

If a ≡ b mod n and c ≡ d mod n, then a + c ≡ b + dmod n and ac ≡ bd mod n.

If a ≡ b mod n, then ak ≡ bk mod n.

Example

3 ≡ 8 mod 5 and 8 ≡ 23 mod 5 gives 3 ≡ 23 mod 53 ≡ 8 mod 5 and 1 ≡ 11 mod 5 gives 4 ≡ 19 mod 53 ≡ 8 mod 5 and 1 ≡ 11 mod 5 gives 3 ≡ 88 mod 5

Franz Luef MA1301

Page 6: Elementary Number Theory - NTNU

Modular Arithmetic

Division

If a ≡ b mod n and c ≡ d mod n, thenac ≡ bd mod n.

In particular: If a ≡ b mod n, then ac ≡ bc mod n.

In contrast to the integers, one has to be careful aboutcancelling common factors in modular arithmetic!

15 · 2 ≡ 20 · 2 mod 10 BUT 15 6≡ 20 mod 10.

6 ≡ 16 mod 5 is 2 · 3 ≡ 2 · 8 mod 5 is the same as 3 ≡ 8mod 5.

6 · 4 ≡ 0 mod 12, BUT 6 ≡ 6 mod 12 and 4 ≡ 4mod 12.

Franz Luef MA1301

Page 7: Elementary Number Theory - NTNU

Cancellation of factors in modular arithmetic

Lemma

Suppose a ≡ b mod n. Then a ≡ b mod ngcd(c,n) .

Check it in our example: 15 · 2 ≡ 20 · 2 mod 10,gcd(2, 10) = 2 15 ≡ 20 mod 5.

Corollary

Suppose gcd(d , n) = 1. Then a · c ≡ b · c mod n impliesa ≡ b mod n.

Suppose p is a prime number. If c is not a multiple of p,then Then a · c ≡ b · c mod p implies a ≡ b mod p.

Moral: Congruences modulo a prime number p behave verydifferently from congruences modulo a composite number.

Franz Luef MA1301

Page 8: Elementary Number Theory - NTNU

Congruences – Modular Arithmetic

Definition

Integers a and b are said to be congruent mod n, written

a ≡ b mod n,

if they leave the same remainder on division by n.In other words, a ≡ b mod n, if n divides a− b.

Remark

What is −3 ≡ x mod 7? Answer: x = 4.

General case: −k mod n is n − k ≡ −k mod n

n ≡ 0 mod n is the same as n − k + k ≡ 0 mod n.Therefore, n − k ≡ −k mod n.

Franz Luef MA1301

Page 9: Elementary Number Theory - NTNU

Congruences – Modular Arithmetic

Cancelling Factors in congruences

Suppose ac ≡ bc mod n. Then a ≡ b mod ngcd(c,n) .

Special case

Suppose gcd(c , n) = 1. Then a · c ≡ b · c mod n impliesa ≡ b mod n.

Suppose p is a prime number and c is not a multiple of p.Then a · c ≡ b · c mod p implies a ≡ b mod p.

Franz Luef MA1301

Page 10: Elementary Number Theory - NTNU

Linear congruences

Linear congruences

The equation ax ≡ b mod n has a solution if and only ifd = gcd(a, n) divides b.If d = gcd(a, n) divides b, then it has d mutually incongruent

solutions modulo n: x0, x0 + nd , x0 + 2n

d , ..., x0 + (d−1)nd , where

x0 is the particular solution determined from the Euclideanalgorithm.

Corollary

Suppose gcd(a, n) = 1. Then ax ≡ b mod n has a uniquesolution.

Franz Luef MA1301

Page 11: Elementary Number Theory - NTNU

Linear congruences

Solution

Find y ∈ Z such that ay ≡ 1 mod n, i.e. find themultiplicative inverse of a modulo n.

Use the Euclidean algorithm to find such an y .

Multiply the linear congrunce ax ≡ b mod n with themultiplicative inverse y .

Then yax ≡ yb mod n, which yields x ≡ yb mod n.

Franz Luef MA1301

Page 12: Elementary Number Theory - NTNU

Linear congruences

Example

37x ≡ 15 mod 49.

gcd(37, 49) = 1 implies that the equation has exactly ONEsolution.

Find the multiplicative inverse of 37 modulo 49, i.e.37y ≡ 1 mod 49.

Euclidean algorithm: 49 = 37 + 12, 37 = 3 · 12 + 1. Thus1 = 37− 3.12 = 37− 3(49− 37) = 4 · 37− 3 · 49.

4 is the multiplicative inverse of 37 modulo 49.

37x ≡ 15 mod 49, therefore 4 · 37x ≡ 15 mod 49, i.e.x ≡ 11 mod 49.

Franz Luef MA1301

Page 13: Elementary Number Theory - NTNU

Linear congruences

Example

18x ≡ 8 mod 14.

gcd(14, 18) = 2 implies that the equation has TWOsolutions.

2 · 9x ≡ 2 · 4 mod 2 · 7 is equivalent to 9x ≡ 4 mod 7because gcd(2, 14) = 2.

Find the multiplicative inverse of 9 modulo 7, i.e. 9y ≡ 1mod 7.

Euclidean algorithm: 9 = 7 + 2, 7 = 3 · 2 + 1. Thus1 = 4 · 7− 3 · 9. −3 is the multiplicative inverse of 9modulo 7, i.e. −3 ≡ 4 mod 7.

9x ≡ 4 mod 7, therefore 4 · 9x ≡ 4 · 4 mod 7, i.e. x0 ≡ 2mod 49. The second solution:x1 = x0 + 14/2 = 2 + 7 = 9.

Franz Luef MA1301

Page 14: Elementary Number Theory - NTNU

Pascal’s triangle

Pascal’s Triangle

Franz Luef MA1301

Page 15: Elementary Number Theory - NTNU

Pascal’s triangle modulo 2

Pascal’s Triangle mod 2

Franz Luef MA1301

Page 16: Elementary Number Theory - NTNU

Binary representation of integers

Motivation

G. W. Leibniz, one of the inventors of calculus andcontempary of Newton, was the first to express integers interms of powers of 2.

In 1671 Leibniz invented a machine that could execute allfour arithmetical operations, which later was actually build.

Binary representations are ubiquitious nowadays, becausethat’s the way computers operate and all our data arestored on DVD, flashdrive,...! In other words our digitalworld has only two fingers or in Latin: two digits.

We are going to use them in our computations ofcongruences!

Franz Luef MA1301

Page 17: Elementary Number Theory - NTNU

Binary Representation

Procedure

Instead of powers of 10 we want to write a number interms of powers of 2.

The first few powers of 2 are:1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, ...

Let us write 984 = 9 · 102 + 8 · 10 + 4 · 100 in powers of 2:

Find the largest power of 2 that does not exceed 984 (thatis 512 = 29 in this case), and then procede successivelywith smaller powers of 2 as follows:

984 = 512 + 472, 472 = 256 + 216, 216 =128 + 88, 88 = 64 + 24, 24 = 16 + 8.

984 = 29+28+27+26+0 ·25+24+23+0 ·22+0 ·21+0 ·20

(984)2 = 1111011000

Franz Luef MA1301

Page 18: Elementary Number Theory - NTNU

Binary Representation

Summary

A 1 in our binary representation means we are including thepower of 2 and a 0 that we are excluding this power of 2.

Examples

What are the binary expansion of 7, 11, 15, 25 and of6, 10, 14, 20?

The answers are as follows:(7)2 = 111, (11)2 = 1011, (15)2 = 1111, (25)2 = 11001

(6)2 = 110, (10)2 = 1010, (14)2 = 1110, (20)2 = 10100.

What is the emerging pattern? odd numbers have a 1 aslast digit and even numbers a 0 in the last digit of theirbinary expansions.

Franz Luef MA1301

Page 19: Elementary Number Theory - NTNU

Linear congruences and Chinese RemainderTheorem

Linear congruences

The equation ax ≡ b mod n has a solution if and only if ddivides b, where d is the gcd(a, n).If d divides b, then it has d mutually incongruent solutionsmodulo n: x0, x0 + n

d , x0 + 2nd , ..., x0 + (d−1)n

d .

Corollary

Suppose gcd(a, n) = 1. Then ax ≡ b mod n has a uniquesolution.

Idea

The linear congruence is equivalent to the linear Diophantineequation ax − ny = b.

Franz Luef MA1301

Page 20: Elementary Number Theory - NTNU

Linear congruences and Chinese RemainderTheorem

Idea

By the result about linear Diophantine equations we have thatit is soluble if and only if d |b. Furthermore, the solutions are inthis case: Suppose x0, y0 are solutions, then any other solutionis of the form x = x0 + n

d t and y = y0 + nd t for

t = 0, 1, ..., d − 1.

Example

18x ≡ 8 mod 14

We have to find integers x , y such that 18x − 14y = 8.

gcd(18, 14) = 2

Therefore we can solve 18x − 14y = 2 with particularsolution is x0 = 4 and y0 = 5. Thus 18 · 16 ≡ 8 mod 14and the other solution is 2− 14/2 = −5 ≡ 9 mod 14.

Franz Luef MA1301

Page 21: Elementary Number Theory - NTNU

Linear congruences and Chinese RemainderTheorem

Chinese Remainder Theorem

Let n1 and n2 be two integers with gcd(n1, n2) = 1. Supposea1 and a2 are integers. Then the simultaneous congruencesx ≡ a1 mod n1 and x ≡ a2 mod n2has exactly one solution x with 0 ≤ x < n1n2.

The proof provides the method to solve these kind ofequations. Therefore, we discuss it in a particular example.

Example

What are the solutions tox ≡ 8 mod 11 and x ≡ 3 mod 19?

Franz Luef MA1301

Page 22: Elementary Number Theory - NTNU

Linear congruences and Chinese RemainderTheorem

Example

x ≡ 8 mod 11 and x ≡ 3 mod 19

The solution to the first congruence are numbers of theform x = 11y + 8.

Substitute this into the second congruence: 11y + 8 ≡ 3mod 19

11y ≡ 14 mod 19. The solution is y1 ≡ 3 mod 19.

Solutions to the original congrunence viax1 = 11y1 + 8 = 11 · 3 + 8 = 41.

Check our solution: (41− 8)/11 = 3 and (41− 3)/19 = 2.

Franz Luef MA1301