Chapter 21 first version
This commit is contained in:
parent
6b3dd3d57f
commit
37ab44c308
234
luku21.tex
234
luku21.tex
|
@ -452,14 +452,14 @@ because if $m$ is a prime, then $\varphi(m)=m-1$.
|
||||||
|
|
||||||
\index{modular inverse}
|
\index{modular inverse}
|
||||||
|
|
||||||
The modular inverse of $x$ modulo $m$
|
The inverse of $x$ modulo $m$
|
||||||
is a number $x^{-1}$ such that
|
is a number $x^{-1}$ such that
|
||||||
\[ x x^{-1} \bmod m = 1. \]
|
\[ x x^{-1} \bmod m = 1. \]
|
||||||
For example, if $x=6$ and $m=17$,
|
For example, if $x=6$ and $m=17$,
|
||||||
then $x^{-1}=3$, because $6\cdot3 \bmod 17=1$.
|
then $x^{-1}=3$, because $6\cdot3 \bmod 17=1$.
|
||||||
|
|
||||||
Using modular inverses, we can do divisions
|
Using modular inverses, we can divide numbers
|
||||||
for remainders, because division by $x$
|
modulo $m$, because division by $x$
|
||||||
corresponds to multiplication by $x^{-1}$.
|
corresponds to multiplication by $x^{-1}$.
|
||||||
For example, to evaluate the value of $36/6 \bmod 17$,
|
For example, to evaluate the value of $36/6 \bmod 17$,
|
||||||
we can use the formula $2 \cdot 3 \bmod 17$,
|
we can use the formula $2 \cdot 3 \bmod 17$,
|
||||||
|
@ -469,7 +469,7 @@ However, a modular inverse doesn't always exist.
|
||||||
For example, if $x=2$ and $m=4$, the equation
|
For example, if $x=2$ and $m=4$, the equation
|
||||||
\[ x x^{-1} \bmod m = 1. \]
|
\[ x x^{-1} \bmod m = 1. \]
|
||||||
can't be solved, because all multiples of the number 2
|
can't be solved, because all multiples of the number 2
|
||||||
are even, and the remainder can never be 1.
|
are even, and the remainder can never be 1 when $m=4$.
|
||||||
It turns out that the number $x^{-1} \bmod m$ exists
|
It turns out that the number $x^{-1} \bmod m$ exists
|
||||||
exactly when $x$ and $m$ are coprime.
|
exactly when $x$ and $m$ are coprime.
|
||||||
|
|
||||||
|
@ -518,54 +518,53 @@ unsigned int x = 123456789;
|
||||||
cout << x*x << "\n"; // 2537071545
|
cout << x*x << "\n"; // 2537071545
|
||||||
\end{lstlisting}
|
\end{lstlisting}
|
||||||
|
|
||||||
\section{Yhtälönratkaisu}
|
\section{Solving equations}
|
||||||
|
|
||||||
\index{Diofantoksen yhtxlz@Diofantoksen yhtälö}
|
\index{Diophantine equation}
|
||||||
|
|
||||||
\key{Diofantoksen yhtälö} on muotoa
|
A \key{Diophantine equation} is of the form
|
||||||
\[ ax + by = c, \]
|
\[ ax + by = c, \]
|
||||||
missä $a$, $b$ ja $c$ ovat vakioita
|
where $a$, $b$ and $c$ are constants,
|
||||||
ja tehtävänä on ratkaista muuttujat $x$ ja $y$.
|
and our tasks is to solve variables $x$ and $y$.
|
||||||
Jokaisen yhtälössä esiintyvän luvun tulee
|
Each number in the equation has to be an integer.
|
||||||
olla kokonaisluku.
|
For example, one solution for the equation
|
||||||
Esimerkiksi jos yhtälö on $5x+2y=11$, yksi ratkaisu
|
$5x+2y=11$ is $x=3$ and $y=-2$.
|
||||||
on valita $x=3$ ja $y=-2$.
|
|
||||||
|
|
||||||
\index{Eukleideen algoritmi@Eukleideen algoritmi}
|
\index{Euclid's algorithm}
|
||||||
|
|
||||||
Diofantoksen yhtälön voi ratkaista
|
We can efficiently solve a Diophantine equation
|
||||||
tehokkaasti Eukleideen algoritmin avulla,
|
by using Euclid's algorithm.
|
||||||
koska Eukleideen algoritmia laajentamalla
|
It turns out that we can extend Euclid's algorithm
|
||||||
pystyy löytämään luvun $\textrm{syt}(a,b)$
|
so that it will find numbers $x$ and $y$
|
||||||
lisäksi luvut $x$ ja $y$,
|
that satisfy the following equation:
|
||||||
jotka toteuttavat yhtälön
|
|
||||||
\[
|
\[
|
||||||
ax + by = \textrm{syt}(a,b).
|
ax + by = \textrm{syt}(a,b)
|
||||||
\]
|
\]
|
||||||
|
|
||||||
Diofantoksen yhtälön ratkaisu on olemassa, jos $c$ on
|
A Diophantine equation can be solved if
|
||||||
jaollinen $\textrm{syt}(a,b)$:llä,
|
$c$ is divisible by
|
||||||
ja muussa tapauksessa yhtälöllä ei ole ratkaisua.
|
$\textrm{gcd}(a,b)$,
|
||||||
|
and otherwise it can't be solved.
|
||||||
|
|
||||||
\index{laajennettu Eukleideen algoritmi@laajennettu Eukleideen algoritmi}
|
\index{extended Euclid's algorithm}
|
||||||
|
|
||||||
\subsubsection*{Laajennettu Eukleideen algoritmi}
|
\subsubsection*{Extended Euclid's algorithm}
|
||||||
|
|
||||||
Etsitään esimerkkinä luvut $x$ ja $y$,
|
As an example, let's find numbers $x$ and $y$
|
||||||
jotka toteuttavat yhtälön
|
that satisfy the following equation:
|
||||||
\[
|
\[
|
||||||
39x + 15y = 12.
|
39x + 15y = 12
|
||||||
\]
|
\]
|
||||||
Yhtälöllä on ratkaisu, koska $\textrm{syt}(39,15)=3$
|
The equation can be solved, because
|
||||||
ja $3 \mid 12$.
|
$\textrm{syt}(39,15)=3$ and $3 \mid 12$.
|
||||||
Kun Eukleideen algoritmi laskee lukujen
|
When Euclid's algorithm calculates the
|
||||||
39 ja 15 suurimman
|
greatest common divisor of 39 and 15,
|
||||||
yhteisen tekijän, syntyy ketju
|
it produces the following sequence of function calls:
|
||||||
\[
|
\[
|
||||||
\textrm{syt}(39,15) = \textrm{syt}(15,9)
|
\textrm{gcd}(39,15) = \textrm{gcd}(15,9)
|
||||||
= \textrm{syt}(9,6) = \textrm{syt}(6,3)
|
= \textrm{gcd}(9,6) = \textrm{gcd}(6,3)
|
||||||
= \textrm{syt}(3,0) = 3. \]
|
= \textrm{gcd}(3,0) = 3 \]
|
||||||
Algoritmin aikana muodostuvat jakoyhtälöt ovat:
|
This corresponds to the following equations:
|
||||||
\[
|
\[
|
||||||
\begin{array}{lcl}
|
\begin{array}{lcl}
|
||||||
39 - 2 \cdot 15 & = & 9 \\
|
39 - 2 \cdot 15 & = & 9 \\
|
||||||
|
@ -573,29 +572,30 @@ Algoritmin aikana muodostuvat jakoyhtälöt ovat:
|
||||||
9 - 1 \cdot 6 & = & 3 \\
|
9 - 1 \cdot 6 & = & 3 \\
|
||||||
\end{array}
|
\end{array}
|
||||||
\]
|
\]
|
||||||
Näiden yhtälöiden avulla saadaan
|
Using these equations, we can derive
|
||||||
\[
|
\[
|
||||||
39 \cdot 2 + 15 \cdot (-5) = 3
|
39 \cdot 2 + 15 \cdot (-5) = 3
|
||||||
\]
|
\]
|
||||||
ja kertomalla yhtälö 4:lla tuloksena on
|
and by multiplying this by 4, the result is
|
||||||
\[
|
\[
|
||||||
39 \cdot 8 + 15 \cdot (-20) = 12,
|
39 \cdot 8 + 15 \cdot (-20) = 12,
|
||||||
\]
|
\]
|
||||||
joten alkuperäisen yhtälön ratkaisu on $x=8$ ja $y=-20$.
|
so a solution for the original equation is
|
||||||
|
$x=8$ and $y=-20$.
|
||||||
|
|
||||||
Diofantoksen yhtälön ratkaisu ei ole yksikäsitteinen,
|
A solution for a Diophantine equation is not unique,
|
||||||
vaan yhdestä ratkaisusta on mahdollista muodostaa
|
but we can form an infinite number of solutions
|
||||||
äärettömästi muita ratkaisuja.
|
if we know one solution.
|
||||||
Kun yhtälön ratkaisu on $(x,y)$,
|
If the pair $(x,y)$ is a solution, then also the pair
|
||||||
niin myös
|
\[(x+\frac{kb}{\textrm{gcd}(a,b)},y-\frac{ka}{\textrm{gcd}(a,b)})\]
|
||||||
\[(x+\frac{kb}{\textrm{syt}(a,b)},y-\frac{ka}{\textrm{syt}(a,b)})\]
|
is a solution where $k$ is any integer.
|
||||||
on ratkaisu, missä $k$ on mikä tahansa kokonaisluku.
|
|
||||||
|
|
||||||
\subsubsection{Kiinalainen jäännöslause}
|
\subsubsection{Chinese remainder theorem}
|
||||||
|
|
||||||
\index{kiinalainen jxxnnzslause@kiinalainen jäännöslause}
|
\index{Chinese remainder theorem}
|
||||||
|
|
||||||
\key{Kiinalainen jäännöslause} ratkaisee yhtälöryhmän muotoa
|
The \key{Chinese remainder theorem} solves
|
||||||
|
a group of equations of the form
|
||||||
\[
|
\[
|
||||||
\begin{array}{lcl}
|
\begin{array}{lcl}
|
||||||
x & = & a_1 \bmod m_1 \\
|
x & = & a_1 \bmod m_1 \\
|
||||||
|
@ -604,24 +604,22 @@ x & = & a_2 \bmod m_2 \\
|
||||||
x & = & a_n \bmod m_n \\
|
x & = & a_n \bmod m_n \\
|
||||||
\end{array}
|
\end{array}
|
||||||
\]
|
\]
|
||||||
missä kaikki parit luvuista $m_1,m_2,\ldots,m_n$
|
where all pairs of $m_1,m_2,\ldots,m_n$ are coprime.
|
||||||
ovat suhteellisia alkulukuja.
|
|
||||||
|
|
||||||
Olkoon $x^{-1}_m$ luvun $x$ käänteisluku
|
Let $x^{-1}_m$ be the inverse of $x$ modulo $m$, and
|
||||||
modulo $m$ ja
|
|
||||||
\[ X_k = \frac{m_1 m_2 \cdots m_n}{m_k}.\]
|
\[ X_k = \frac{m_1 m_2 \cdots m_n}{m_k}.\]
|
||||||
Näitä merkintöjä käyttäen yhtälöryhmän ratkaisu on
|
Using this notation, a solution for the equations is
|
||||||
\[x = a_1 X_1 {X_1}^{-1}_{m_1} + a_2 X_2 {X_2}^{-1}_{m_2} + \cdots + a_n X_n {X_n}^{-1}_{m_n}.\]
|
\[x = a_1 X_1 {X_1}^{-1}_{m_1} + a_2 X_2 {X_2}^{-1}_{m_2} + \cdots + a_n X_n {X_n}^{-1}_{m_n}.\]
|
||||||
Tässä ratkaisussa jokaiselle luvulle $k=1,2,\ldots,n$
|
In this solution, it holds for each number
|
||||||
pätee, että
|
$k=1,2,\ldots,n$ that
|
||||||
\[a_k X_k {X_k}^{-1}_{m_k} \bmod m_k = a_k,\]
|
\[a_k X_k {X_k}^{-1}_{m_k} \bmod m_k = a_k,\]
|
||||||
sillä
|
because
|
||||||
\[X_k {X_k}^{-1}_{m_k} \bmod m_k = 1.\]
|
\[X_k {X_k}^{-1}_{m_k} \bmod m_k = 1.\]
|
||||||
Koska kaikki muut summan osat ovat jaollisia luvulla
|
Since all other terms in the sum are divisible by $m_k$,
|
||||||
$m_k$, ne eivät vaikuta jakojäännökseen ja
|
they have no effect on the remainder,
|
||||||
koko summan jakojäännös $m_k$:lla on $a_k$.
|
and the remainder by $m_k$ for the whole sum is $a_k$.
|
||||||
|
|
||||||
Esimerkiksi yhtälöryhmän
|
For example, a solution for
|
||||||
\[
|
\[
|
||||||
\begin{array}{lcl}
|
\begin{array}{lcl}
|
||||||
x & = & 3 \bmod 5 \\
|
x & = & 3 \bmod 5 \\
|
||||||
|
@ -629,84 +627,84 @@ x & = & 4 \bmod 7 \\
|
||||||
x & = & 2 \bmod 3 \\
|
x & = & 2 \bmod 3 \\
|
||||||
\end{array}
|
\end{array}
|
||||||
\]
|
\]
|
||||||
ratkaisu on
|
is
|
||||||
\[ 3 \cdot 21 \cdot 1 + 4 \cdot 15 \cdot 1 + 2 \cdot 35 \cdot 2 = 263.\]
|
\[ 3 \cdot 21 \cdot 1 + 4 \cdot 15 \cdot 1 + 2 \cdot 35 \cdot 2 = 263.\]
|
||||||
|
|
||||||
Kun yksi ratkaisu $x$ on löytynyt,
|
Once we have found a solution $x$,
|
||||||
sen avulla voi muodostaa äärettömästi
|
we can create an infinite number of other solutions,
|
||||||
erilaisia ratkaisuja, koska kaikki luvut muotoa
|
because all numbers of the form
|
||||||
\[x+m_1 m_2 \cdots m_n\]
|
\[x+m_1 m_2 \cdots m_n\]
|
||||||
ovat ratkaisuja.
|
are solutions.
|
||||||
|
|
||||||
|
\section{Other results}
|
||||||
|
|
||||||
\section{Muita tuloksia}
|
\subsubsection{Lagrange's theorem}
|
||||||
|
|
||||||
\subsubsection{Lagrangen lause}
|
\index{Lagrange's theorem}
|
||||||
|
|
||||||
\index{Lagrangen lause@Lagrangen lause}
|
\key{Lagrange's theorem} states that every positive integer
|
||||||
|
can be represented as a sum of four squares, i.e.,
|
||||||
|
$a^2+b^2+c^2+d^2$.
|
||||||
|
For example, the number 123 can be represented
|
||||||
|
as the sum $8^2+5^2+5^2+3^2$.
|
||||||
|
|
||||||
\key{Lagrangen lauseen} mukaan jokainen positiivinen kokonaisluku voidaan
|
\subsubsection{Zeckendorf's theorem}
|
||||||
esittää neljän neliöluvun summana eli muodossa $a^2+b^2+c^2+d^2$.
|
|
||||||
Esimerkiksi luku 123 voidaan esittää muodossa $8^2+5^2+5^2+3^2$.
|
|
||||||
|
|
||||||
\subsubsection{Zeckendorfin lause}
|
\index{Zeckendorf's theorem}
|
||||||
|
\index{Fibonacci number}
|
||||||
|
|
||||||
\index{Zeckendorfin lause@Zeckendorfin lause}
|
\key{Zeckendorf's theorem} states that every
|
||||||
\index{Fibonaccin luku@Fibonaccin luku}
|
positive integer has a unique representation
|
||||||
|
as a sum of Fibonacci numbers such that
|
||||||
|
no two numbers are the same of successive
|
||||||
|
Fibonacci numbers.
|
||||||
|
For example, the number 74 can be represented
|
||||||
|
as the sum $55+13+5+1$.
|
||||||
|
|
||||||
\key{Zeckendorfin lauseen} mukaan
|
\subsubsection{Pythagorean triples}
|
||||||
jokaiselle positiiviselle kokonaisluvulle
|
|
||||||
on olemassa yksikäsitteinen esitys
|
|
||||||
Fibonaccin lukujen summana niin, että
|
|
||||||
mitkään kaksi lukua eivät ole samat eivätkä peräkkäiset
|
|
||||||
Fibonaccin luvut.
|
|
||||||
Esimerkiksi luku 74 voidaan esittää muodossa
|
|
||||||
$55+13+5+1$.
|
|
||||||
|
|
||||||
\subsubsection{Pythagoraan kolmikot}
|
\index{Pythagorean triple}
|
||||||
|
\index{Euclid's formula}
|
||||||
|
|
||||||
\index{Pythagoraan kolmikko@Pythagoraan kolmikko}
|
A \key{Pythagorean triple} is a triple $(a,b,c)$
|
||||||
\index{Eukleideen kaava@Eukleideen kaava}
|
that satisfies the Pythagorean theorem
|
||||||
|
$a^2+b^2=c^2$, which means that there is a right triangle
|
||||||
|
with side lengths $a$, $b$ and $c$.
|
||||||
|
For example, $(3,4,5)$ is a Pythagorean triple.
|
||||||
|
|
||||||
\key{Pythagoraan kolmikko} on lukukolmikko $(a,b,c)$,
|
If $(a,b,c)$ is a Pythagorean triple,
|
||||||
joka toteuttaa Pythagoraan lauseen $a^2+b^2=c^2$
|
all triples of the form $(ka,kb,kc)$
|
||||||
eli $a$, $b$ ja $c$ voivat olla suorakulmaisen
|
are also Pythagorean triples where $k>1$.
|
||||||
kolmion sivujen pituudet.
|
A Pythagorean triple is \key{primitive} if
|
||||||
Esimerkiksi $(3,4,5)$ on Pythagoraan kolmikko.
|
$a$, $b$ and $c$ are coprime,
|
||||||
|
and all Pythagorean triples can be constructed
|
||||||
|
from primitive triples using a multiplier $k$.
|
||||||
|
|
||||||
Jos $(a,b,c)$ on Pythagoraan kolmikko,
|
\key{Euclid's formula} can be used to produce
|
||||||
niin myös kaikki kolmikot muotoa $(ka,kb,kc)$
|
all primitive Pythagorean triples.
|
||||||
ovat Pythagoraan kolmikoita,
|
Each such triple is of the form
|
||||||
missä $k>1$.
|
|
||||||
Pythagoraan kolmikko on \key{primitiivinen},
|
|
||||||
jos $a$, $b$ ja $c$ ovat suhteellisia alkulukuja,
|
|
||||||
ja primitiivisistä kolmikoista voi muodostaa
|
|
||||||
kaikki muut kolmikot kertoimen $k$ avulla.
|
|
||||||
|
|
||||||
\key{Eukleideen kaavan} mukaan jokainen primitiivinen
|
|
||||||
Pythagoraan kolmikko on muotoa
|
|
||||||
\[(n^2-m^2,2nm,n^2+m^2),\]
|
\[(n^2-m^2,2nm,n^2+m^2),\]
|
||||||
missä $0<m<n$, $n$ ja $m$ ovat suhteelliset
|
where $0<m<n$, $n$ and $m$ are coprime
|
||||||
alkuluvut ja ainakin toinen luvuista $n$ ja $m$ on parillinen.
|
and at least one of the numbers $n$ and $m$ is even.
|
||||||
Esimerkiksi valitsemalla $m=1$ ja $n=2$ syntyy
|
For example, when $m=1$ and $n=2$, the formula
|
||||||
pienin mahdollinen Pythagoraan kolmikko
|
produces the smallest Pythagorean triple
|
||||||
\[(2^2-1^2,2\cdot2\cdot1,2^2+1^2)=(3,4,5).\]
|
\[(2^2-1^2,2\cdot2\cdot1,2^2+1^2)=(3,4,5).\]
|
||||||
|
|
||||||
\subsubsection{Wilsonin lause}
|
\subsubsection{Wilson's theorem}
|
||||||
|
|
||||||
\index{Wilsonin lause@Wilsonin lause}
|
\index{Wilson's theorem}
|
||||||
|
|
||||||
\key{Wilsonin lauseen} mukaan luku $n$ on alkuluku
|
\key{Wilson's theorem} states that a number $n$
|
||||||
tarkalleen silloin, kun
|
is prime exactly when
|
||||||
\[(n-1)! \bmod n = n-1.\]
|
\[(n-1)! \bmod n = n-1.\]
|
||||||
Esimerkiksi luku 11 on alkuluku, koska
|
For example, the number 11 is prime, because
|
||||||
\[10! \bmod 11 = 10,\]
|
\[10! \bmod 11 = 10,\]
|
||||||
ja luku 12 ei ole alkuluku, koska
|
and the number 12 is not prime, because
|
||||||
\[11! \bmod 12 = 0 \neq 11.\]
|
\[11! \bmod 12 = 0 \neq 11.\]
|
||||||
|
|
||||||
Wilsonin lauseen avulla voi siis tutkia, onko luku alkuluku.
|
Hence, Wilson's theorem tells us whether a number
|
||||||
Tämä ei ole kuitenkaan käytännössä hyvä tapa,
|
is prime. However, in practice, the formula can't be
|
||||||
koska luvun $(n-1)!$ laskeminen on työlästä,
|
used for large values of $n$, because it's difficult
|
||||||
jos $n$ on suuri luku.
|
to calculate the number $(n-1)!$ if $n$ is large.
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue