Introduction to Number Theory Part 2
Introduction to Number Theory Part 2
Number Systems
Number Systems
◼
The way we represent numbers is a convention that we as humans have. Arabic numerals {0,1,2,3,4,5,6,7,8,9} are used as the digits in the most common representation of decimal numbers in the world.
◼
२३४५६ = 23456
◼
Even though the study of different base 10 (decimal) number numerals is interesting in itself, we will focus on the base portion of the representation.
◼
2345 =
2*+3*+4*+5*
3
10
2
10
1
10
0
10
◼
abc=a+b+c+d
d
10
3
10
2
10
1
10
0
10
0<=a,b,c,d<10
◼
abc=a+b+c+d
d
p
3
p
2
p
1
p
0
p
0<=a,b,c,d<p
Examples
Examples
123
4
2
4
In[]:=
1*+2*4+3
2
4
Out[]=
27
1011
2
3
2
2
2
In[]:=
1+0+12+1
3
2
2
2
Out[]=
11
Number representation for bases larger than 10
Number representation for bases larger than 10
◼
When representing numbers in a base larger than 10, we will use an extension of the arabic numerals to enhance our digit {0,1,2,3,4,5,6,7,8,9,a,b,c,d,...}
◼
For representing base 11 digits we commonly use {0,1,2,3,4,5,6,7,8,9,a}
◼
For representing base 12 digits we commonly use {0,1,2,3,4,5,6,7,8,9,a,b}
◼
... and so on until base 36.
◼
Examples:
11a=++1011+2
2
11
3
11
2
11
In[]:=
3
11
2
11
Out[]=
1564
12
12
14
1=11+10
a
11
21
bacd
11
◼
We can’t calculate the last one because b does not mean anything in base 11.
In[]:=
ff
16
Out[]=
255
Where do we use this?
Where do we use this?
◼
Color picking for computers
In[]:=
SystemOpen["https://htmlcolorcodes.com/"]
◼
Number representation in computers
◼
You’ve probably heard the phrase “it’s just 0’s and 1’s” when referring to something computational. This has to do with the way that numbers(and really anything) is represented in computers, which uses the binary (or base 2) system.
◼
floating point arithmetic
In[]:=
SystemOpen["https://www.programiz.com/javascript/online-compiler/"]
In[]:=
0.1+0.2
Out[]=
0.3
In[]:=
1
3
1
3
1
3
Out[]=
1
In[]:=
BaseForm[0.1,2]
Out[]//BaseForm=
0.00011001100110011001101
2
In[]:=
BaseForm[0.2,2]
Out[]//BaseForm=
0.0011001100110011001101
2
In[]:=
BaseForm[0.3,2]
Out[]//BaseForm=
0.01001100110011001101
2
In[]:=
BaseForm[2^^0.00011001100110011001101+2^^0.0011001100110011001101,2]
Out[]//BaseForm=
0.01001100110011001101
2
Do the following calculation Manually
Do the following calculation Manually
0.000110011001100110011010.00110011001100110011010
0.01001100110011001100111
In[]:=
2^^0.01001100110011001100111
Out[]=
0.3
In[]:=
N[2.0000000000000000000000000000^-2+2^-5+2^-6+2^-9+2^-10+2^-13+2^-14+2^-17+2^-18+2^-21+2^-22+2^-23,30]
Out[]=
0.3000000715255737304687500000
The Extended Euclidean Algorithm
The Extended Euclidean Algorithm
◼
Consider the Euclidean Algorithm:
◼
Let then by following the procedure
a,b∈
*
◼
a=b+
q
1
r
1
0<=<b
r
1
◼
b=+with
r
1
q
2
r
2
0<=<
r
2
r
1
◼
r
1
r
2
q
3
r
3
0<=<
r
3
r
2
◼
...
◼
r
i
r
i+1
q
i+2
r
i+2
0<=<
r
i+2
r
i+1
◼
...
◼
r
n-2
r
n-1
q
n
r
n
◼
r
n-1
r
n
q
n+1
◼
Where is the last non-zero residue, then is GCD()
r
n
r
n
a,b
◼
Let us consider the following Procedure where our goal is to write in terms of .
r
n
a
and
b
◼
A bit of an intuition for the procedure comes from rewriting in terms of and
Indeed
=-
Then using that=+ we get that =- and substituting we get
=-(-)=(1+)+(-)
r
n
r
n-1
r
n-2
Indeed
r
n
r
n-2
q
n
r
n-1
Then using that
r
n-3
r
n-2
q
n-1
r
n-1
r
n-1
r
n-3
r
n-2
q
n-1
r
n
r
n-2
q
n
r
n-3
r
n-2
q
n-1
r
n-2
q
n
q
n-1
r
n-3
q
n
◼
Let b= ,
r
0
a=
r
-1
◼
The we have =-
r
i+2
r
i
r
i+1
q
i+2
◼
r
i
r
i-2
r
i-1
q
i
r
n
t
i-1
r
n-i
s
i-1
r
n-i+1
r
n
t
i
r
n-i
s
i-1
r
n-i-1
r
n-i
q
n-i+1
s
i-1
r
n-i-1
r
n-i
t
i
s
i-1
q
n-i+1
◼
So we define:
=-(-)
with
=- and =1
s
i
s
i-2
s
i-1
q
n-i-1
with
s
1
q
n
s
2
◼
s
i
r
n-i
r
n
s
i
r
n-i
s
i-1
r
n-i+1
◼
Thus we can express =a+b.
r
n
s
n+1
s
n
◼
To summarize: Let . There are such that . This form is called a linear combination. We call the above procedure to find and the extended Euclidean Algorithm.
a,b∈
*
x,y∈
GCD(a,b)=xa+yb
s
n+1
s
n
◼
A couple observations, if we can express a number m as a linear combination of two integer numbers , (e.g. ) then we have that the greatest common divisor of and divides m. (i.e. ).
a
and
b
m=xa+yb
a
b
GCD(a,b)|m
◼
We can write this as a theorem:
Let. If there are such that then
Let
a,b,m∈
x,y∈
ax+by=m
GCD(a,b)|m
◼
In fact, thanks to the extended Euclidean algorithm the converse also holds true:
◼
Let . If , then there exists such that .
a,b,m∈
GCD(a,b)|m
x,y∈
ax+by=m
◼
Proof: First find and such that let k = then so our solution (i.e x, and y) is given by k and k.
x
0
y
0
a+b=GCD(a,b)
x
0
y
0
m
GCD(a,b)
ak+bk=GCD(a,b)k=m
x
0
y
0
x
0
y
0
◼
Thus we have the equivalence:
◼
Let . There exists such that if and only if .
a,b,m∈
x,y∈
ax+by=m
GCD(a,b)|m
◼
Examples:
◼
GCD(2,4) = 2 and 2 = 2(1)+4(0)
◼
(2)=(4)0+2
4 = (2)2
4 = (2)2
◼
n=1
so we are looking for = 1 and =0
so we are looking for
s
2
s
1
◼
GCD(5,3)= 1 and 1 = 5(-1) + 3(2)
◼
a)
b)
c)
5=(3)1+2
b)
3=(2)1+1
c)
2=(1)2
◼
1=(3)-(2)1
1=3-(5-31)1
1=(3)-(5)+(3)
1=3(2)+(-1)5
◼
n=2
So we are looking for and
=-1 =1
=-( -1 - 1*1)=2 (by =-)
So we are looking for
s
3
s
2
s
1
s
2
s
3
s
i
s
i-2
s
i-1
q
n-i-1
Congruences
Congruences
◼
If , then we say that is congruent to modulo if . We usually denote this as and sometimes . Now if then we write .
n∈
a
b
n
n|(a-b)
a≡b(modn)
ab
≡
n
n(a-b)
a≢b(modn)
◼
This is equivalent to saying that and b have the same residue when dividing by n.Indeed, if with , and with for integers and Then we have that . Note that , so in order for we must have -=0. This implies that =. That is, the residue of when dividing by is the same as the residue of when dividing by .
a
a=nk+
r
1
0<=<n
r
1
b=nm+
r
2
0<=<n
r
2
k,m,
r
1,
r
2
a-b=n(k-m)+(-)
r
1
r
2
|-|<n
r
1
r
2
n|a-b
r
1
r
2
r
1
r
2
a
n
b
n
◼
Note that congruence modulo n is an equivalence relation.
Reflexive: n|a-a since n|0
Symmetric: If n|a-b, then n|b-a
Transitive: If a and b have the same residue when dividing by n, and b and c have the same residue when dividing by n, then a and c have the same residue when dividing by n.
Reflexive: n|a-a since n|0
Symmetric: If n|a-b, then n|b-a
Transitive: If a and b have the same residue when dividing by n, and b and c have the same residue when dividing by n, then a and c have the same residue when dividing by n.
Modular Arithmetic
Modular Arithmetic
1
.Let such that and . Then:
a,b,c,d∈
ab
≡
n
cd
≡
n
1
.1
.a+cb+d
≡
n
1
.2
.a-cb-d
≡
n
◼
Example
Multiplicative Inverses
Multiplicative Inverses
◼
We do not always have a way to divide in the integers. But we do have (for some numbers) multiplicative inverses in the setting of congruences.
◼
Examples:
◼
2 does not have a multiplicative inverse modulo 4.
Solving Congruences
Solving Congruences
◼
But we do not always have a solution...
◼
Examples:
◼
Example
◼
Example
Diophantine Equations
Diophantine Equations
◼
In many “real life problems” we are encountered with the mathematical question of finding integer solutions to equations. Some examples include balancing budgets, chemical equations, flow control for networks, and such.
◼
These type of problems are called Diophantine equations.
◼
Example:
◼
We want to find x and y such that 5x + 3y = 2
We know that (by an example above)
5(-1) + 3(2) = 1 So we have that
5(-2) + 3 (4) = 2
5(-2 - k 3) +3(4+5 k) should also give me 2.
Let us check:
5(-2) -15k + 3(4) +15k = 5(-2) +3(4) = 2
We know that (by an example above)
5(-1) + 3(2) = 1 So we have that
5(-2) + 3 (4) = 2
5(-2 - k 3) +3(4+5 k) should also give me 2.
Let us check:
5(-2) -15k + 3(4) +15k = 5(-2) +3(4) = 2
Number Theory Class Exercises
Number Theory Class Exercises
1
.Show that x-1<⌊x⌋≤x
3
.Find the GCD of the following, and express it as a linear combination of the two numbers.
3
.1
.22,55
3
.2
.15,113
4
.Find the LCM of the following:
4
.1
.15,385
4
.2
.28,577
5
.Determine the solutions to the following congruences