User:Egm6322.s12.team1.zheng.zx/TP

= Modern Applications of Continued Fraction = Zexi Zheng

Abstract
In this paper, we describe several modern applications of continued fraction in some different fields. First, we start with the introduction of a motivation from which the continued fraction derived. After that, we recall the basic formulae, Euclid's algorithm and 3-term recurrence. Second, we discuss two basic applications of CF in mathematics. Third, we discuss its application to the Solar System. Then, the contribution of CF to modern calendar. Finally, we briefly describe the using of CF in Cryptography and RSA attack.

Motivation
How the ancient Greeks measured accurately length

Method of successive subtractions, using only unmarked measuring rod and compass



If we are given two segments AB and CD as shown above. Find the common denominator EF.

Firstly, we subtract the shorter segment CD from longer segment AB, as many times as possible, as b0 times, until the remaining lngth is shorter than CD.

So, for example, AB=135 and CD=24, then b0=5, and the remainder is r0=15/24.

Note that the numbers '135' and '24' are used here just to give a concrete idea for lengths AB and CD and how the process works. The method of course can be carried out without knowing the actual 'values' of AB and CD, since the goal is to measure AB relative to CD.

For these lengths AB and CD, the expected result is :

\displaystyle \overline{AB}= \{5,1,1,1,2\} \cdot \overline{CD} =5\frac{15}{24}\cdot \overline{CD} $$
 * }
 * }
 * }

The goal is to find the remainder 15/24 by the method of successive subtractions; to do so, one must successively find the quotients 5,1,1,1,2,i.e., the continued fraction{5,1,1,1,2}.

1. Subtract $$b_0=5$$ times the length CD from the length AB; let $$r_0 < \overline{CD}$$be the remainder.

2. Subtract $$b_1=1$$ times the length r0 from the length CD; let $$r_1 < r_0$$be the remainder.

3. Subtract $$b_2=1$$ times the length r1 from the length r0; let $$r_2 < r_1$$be the remainder.

4. Subtract $$b_3=1$$ times the length r2 from the length r1; let $$r_3 < r_2$$be the remainder.

5. Subtract $$b_4=2$$ times the length r3 from the length r2; the remainder is $$r_4=0$$.

See also Holme 2010, Geometry, p.46

Basic formulae
A finite continued fraction is an expression of the form
 * {| style="width:100%" border="0" align="left"

\displaystyle a_0 + \cfrac{1}{a_1 + \cfrac{1}{a_2 + \cfrac{1}{ \ddots + \cfrac{1}{a_n} }}} $$
 * }
 * }
 * }

where $$a_0$$ is an integer(may be negtive), all other $$a_i$$ are positive integers, and $$n$$ is a non-negtive integer.

An infinite continued fraction can be written as
 * {| style="width:100%" border="0" align="left"

\displaystyle a_0 + \cfrac{1}{a_1 + \cfrac{1}{a_2 + \cfrac{1}{a_3 + \cfrac{1}{a_4 + \ddots}}}} $$ with the same constraints on the $$a_i$$ as in the finite case.
 * }
 * }
 * }

Euclid's algorithm for continued fraction
The method of successive subtractions can be written in the Euclid's algorithm.

Let
 * {| style="width:100%" border="0" align="left"

\displaystyle \overline{AB}=:x_0>x_1:=\overline{CD} $$
 * }
 * }
 * }

So step 1 above can be written as
 * {| style="width:100%" border="0" align="left"

\displaystyle x_0=b_0x_1+x_2 $$
 * }
 * }
 * }

with the remainder satisfying the condition
 * {| style="width:100%" border="0" align="left"

\displaystyle \overline{CD}=:x_1>x_2:=r_0 $$
 * }
 * }
 * }

step 2 above can be written as
 * {| style="width:100%" border="0" align="left"

\displaystyle x_1=b_1x_2+x_3 $$
 * }
 * }
 * }

such that
 * {| style="width:100%" border="0" align="left"

\displaystyle x_2>x_3 $$
 * }
 * }
 * }

step 3 above can be written as
 * {| style="width:100%" border="0" align="left"

\displaystyle x_2=b_2x_3+x_4 $$
 * }
 * }
 * }

In general, we have
 * {| style="width:100%" border="0" align="left"

\displaystyle x_{k-1}>x_k $$
 * }
 * }
 * }

step k is then
 * {| style="width:100%" border="0" align="left"

\displaystyle x_{k-1}=b_{k-1}x_k+x_{k+1} $$
 * }
 * }
 * }


 * {| style="width:100%" border="0" align="left"

\displaystyle \vdots $$
 * }
 * }
 * }


 * {| style="width:100%" border="0" align="left"

\displaystyle x_{n-1}>x_n $$
 * }
 * }
 * }

step n is then:
 * {| style="width:100%" border="0" align="left"

\displaystyle x_{n-1}=b_{n-1}x_n+x_{n+1} $$
 * }
 * }
 * }

Rational numbers: If the process ends within a finite number of steps and the remainder is zero, then it's a rational number ,i.e.,$$x_{n+1}=0$$.The greatest common divisor of $$x_0$$and $$x_1$$is then $$x_n$$

Irrational numbers: If the process never ends and the remainder never reaches zero, it's an irrational number.

And for
 * {| style="width:100%" border="0" align="left"

\displaystyle x_{k-1}=b_{k-1}x_k+x_{k+1} $$
 * }
 * }
 * }

we may write as
 * {| style="width:100%" border="0" align="left"

\displaystyle \frac{x_{k-1}}{x_k}=b_{k-1}+\frac{1}{\displaystyle \frac{x_k}{x_{k+1}}}, \ for \ k=1,2,... $$
 * }
 * }
 * }

and we have the (simple) continued fraction:
 * {| style="width:100%" border="0" align="left"

\displaystyle \frac{x_0}{x_1}=b_0+\frac{1}{\displaystyle b_1+\frac{1}{\displaystyle b_2+\frac{1}{\displaystyle b_3+\frac{1}{\displaystyle b_4+\frac{1}{\displaystyle \frac{x_5}{x_6}}}}}} $$
 * }
 * }
 * }

3-term recurrence for general continued fraction

 * {| style="width:100%" border="0" align="left"

\displaystyle \frac{x_{k-1}}{x_k}=b_{k-1}+\frac{a_k}{\displaystyle \frac{x_k}{x_{k+1}}} \ for \ k=1,2,... $$
 * }
 * }
 * }


 * {| style="width:100%" border="0" align="left"

\displaystyle \frac{x_0}{x_1}=b_0+\frac{a_1}{\displaystyle b_1+\frac{a_2}{\displaystyle b_2+\frac{a_3}{\displaystyle b_3+\frac{a_4}{\displaystyle b_4+\frac{a_5}{\displaystyle \frac{x_5}{x_6}}}}}} $$
 * }
 * }
 * }

And the corresponding 3-term recurrence relation as
 * {| style="width:100%" border="0" align="left"

\displaystyle x_{k-1}=b_{k-1}x_k+a_kx_{k+1} $$
 * }
 * }
 * }

Notations for continued fractions
The integers $$a_0\, a_1\, ...$$are called the quotients of the continued fraction. Then continued fraction can be abbreviated and written as
 * {| style="width:100%" border="0" align="left"

\displaystyle x=[a_0;a_1,a_2,a_3] $$
 * }
 * }
 * }

or, in the notation of Pringsheim, as
 * {| style="width:100%" border="0" align="left"

\displaystyle x=a_0+\frac{1|}{|a_1}+\frac{1|}{|a_2}+\frac{1|}{|a_3} $$
 * }
 * }
 * }

Here is another notation:
 * {| style="width:100%" border="0" align="left"

\displaystyle x=a_0+\frac{1}{a_1+}\frac{1}{a_2+}\frac{1}{a_3+} $$
 * }
 * }
 * }

Sometimes we can use angle brackets, like this:
 * {| style="width:100%" border="0" align="left"

\displaystyle x=\langle a_0;a_1,a_2,a_3 \rangle $$
 * }
 * }
 * }

Also one can define infinite simple continued fractions as limits:
 * {| style="width:100%" border="0" align="left"

\displaystyle [a_0;a_1,a_2,a_3,...]=\lim _{n \to \infty}[a_0;a_1,a_2,...,a_n] $$
 * }
 * }
 * }

Solving quadratic equations, including the quadratic formula
We have several methods to solve a quadratic equation and the quadratic formula, such as the most 'normal' way: factoring and then graphing the equation. Or use a less common method like applying continued fractions. But it isn't used much often for it needs a lot of calculations. And it has a big limitation: sometimes only one of the two solutions can be obtained. Let's consider the following quadratic equation:
 * {| style="width:100%" border="0" align="left"

\displaystyle x^2-5x+6=0 $$ $$
 * $$\displaystyle (Equation\;2.1.1 )
 * }
 * }

If factoring the L.H.S, we find the roots are 2 and 3.

Now using continued fractions.

Both sides of equation 2.1.1 are divided by x, then rearranging:
 * {| style="width:100%" border="0" align="left"

\displaystyle x=5-\frac{6}{x} $$ $$
 * $$\displaystyle (Equation\;2.1.2 )
 * }
 * }

Next, express x as an infinite continued fraction.
 * {| style="width:100%" border="0" align="left"

\displaystyle x=5-\frac{6}{5-}+\frac{6}{x} $$ $$
 * $$\displaystyle (Equation\;2.1.3 )
 * }
 * }

Doing the same procedure again:
 * {| style="width:100%" border="0" align="left"

\displaystyle x=5-\frac{6}{5-}+\frac{6}{5-}+\frac{6}{x} $$ $$
 * $$\displaystyle (Equation\;2.1.4 )
 * }
 * }

If we set $$x=1$$ in the R.H.S of equation 2.1.2, we get
 * {| style="width:100%" border="0" align="left"

\displaystyle x=5-\frac{6}{1}=5-6=-1 $$ if we set $$x=1$$ to the R.H.S of equation 2.1.3, we get
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle x=5-\frac{6}{5-}+\frac{6}{1}=5-\frac{6}{\displaystyle 5-\frac{6}{1}}=5-\frac{6}{-1}=11 $$ If we continue the process, we can get an infinite sequence that approaches 3:
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle x=5-\frac{6}{5-}+\frac{6}{5-}\cdots \frac{6}{5-}+\frac{6}{1}=3 $$ That's one solution of equation 2.1.1, but we can't get the second solution i.e.$$x=2$$using this method. The method can also be generalized and applied to any quadratic equation.
 * }
 * }
 * }

We may verify the answer for the example above using the following Matlab program, at the same time, we should note that the initial number can be arbitrary, not necessarily be 1.

clear x=input('Please designate an initial number x: '); n=input('Please designate the times of process: '); s=x; for i=1:n s=5-6/s; end s

Express an irrational number as a continued fraction
We can use continued fractions to express a rational or an irrational number and to approximate the value. this kind of expression will let us easily study certain properties of a number that we are interested in. Let's look at an irrational number $$\,\sqrt 2 \,$$as an example.

We may find it's not easy to express this number as a continued fraction at first glance. So let's do some manipulations first.

We observe that $$\,\sqrt 2>1 \,$$, so we can decompose that into two parts:
 * {| style="width:100%" border="0" align="left"

\displaystyle \sqrt 2= 1+\frac{1}{x} $$ then solving for a real number:
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle x=\frac{1}{\sqrt 2-1} $$ We multiply the numerator and denominator by $$\,\sqrt 2 +1\,$$
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle x=\sqrt 2 +1 $$ Then, substituting back $$\,\sqrt 2\,$$
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle x=1+\frac{1}{x}+1=2+\frac{1}{x} $$ Now we can do the substitution procedure and get the continued fraction representation:
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle \sqrt 2=1+\frac{1}{\displaystyle 2+\frac{1}{\displaystyle 2+\frac{1}{\displaystyle 2+\frac{1}{\ddots}}}} $$ $$ Or
 * $$\displaystyle (Equation\;2.1.5 )
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle \sqrt 2=[1;2,2,2,2,2,\cdots] $$ Other square roots or irrational numbers can also be expressed as a continued fraction similarly.
 * }
 * }
 * }

An application to the Solar System
Let's look at a kind of solar system: a set of cog wheels. A cog wheel has an integer number of teeth around its rim that mesh with the teeth on another cog. The ratio of the two number of teeth on each pair of cog wheels decide the speed ratio between them. For example, we have a pair of cogs, one has 40 teeth and the other has 10 teeth, the cog with 10 teeth will rotate 4 times faster than that with 40.

Solar systems are widely used, from cog wheels in a small watch to the gear box in a car. However, there exists some limitations on such systems. For example, the number of teeth is an integer, and the ratio between two integers is a rational fraction. So if we want the rotation ratio to be an irrational number such as $$\,\sqrt 2\,$$, we can't make that. But with the help of continued fraction, we may do some approximation. Sometimes if the number of teeth can be large, the result will be precise enough for engineering purpose.

For such case, if we want the ratio to be $$\,\sqrt 2 \,$$

First, let's write it as continued fraction: (see equation 2.1.5)
 * {| style="width:100%" border="0" align="left"

\displaystyle \sqrt 2=1+\frac{1}{\displaystyle 2+\frac{1}{\displaystyle 2+\frac{1}{\displaystyle 2+\frac{1}{\ddots}}}} $$ Defining:
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle \begin{align} C_1 &:=1+\frac{1}{2}\\ C_2 &:=1+\frac{1}{2+}\frac{1}{2}\\ &\ \ \ \vdots\\ C_i &:=1+\underbrace{\frac{1}{2+}\frac{1}{2+}\cdots \frac{1}{2}}_{i\ terms} \end{align} $$ $$\,C_i\,$$as the $$i$$th convergence of $$\, \sqrt 2 \,$$. We see:
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle C_0:=1 $$
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle C_1:=1+\frac{1}{2}=\frac{3}{2} $$
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle C_2:=1+\frac{1}{2+\frac{1}{2}}=1+\frac{2}{5}=\frac{7}{5} $$
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle C_3:=1+\frac{1}{2+\frac{1}{2+\frac{1}{2}}}=1+\frac{1}{2+\frac{2}{5}}=1+\frac{5}{12}=\frac{17}{12} $$
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle \begin{align} & \vdots \\ \lim_{i \to \infty}C_i &=\sqrt 2 \end{align} $$ We may use the follwoing Matlab program to verify the results and plot the convergence. clear
 * }
 * }
 * }

n=10;

f=sqrt(2); f=sym(f); f=char(f); fplot(f,[-2 2],'r','o'); legend('sqrt(2)'); hold on

disp(['C' char(48) '=']) disp(1)

f=1; f=sym(f); f=char(f); fplot(f,[-2 2]);

for x=1:n; s=0; for i=1:x; s=1/(2+s); end s=1+s; s=vpa(s); disp(['C' char(sym(x)) '=']) disp(s)

f=s; f=sym(f); f=char(f); fplot(f,[-2 2]);

end axis([-2 2 1.39 1.51])



So, the convergence says the more recurrent terms we apply, the more accurate answer we will get.

We can get a set of convergent fraction numbers after that:
 * {| style="width:100%" border="0" align="left"

\displaystyle \frac{3}{2},\,\frac{7}{5},\,\frac{17}{12},\,\frac{41}{29},\,\frac{99}{70},\cdots $$ For a pair of small cog wheels, we could have 5 teeth on one cog and 7 on the other, or 12 on one and 17 on the other; for a pair of larger cogs, we can apply 12 on one and 17 on another or if possible 99 and 70 teeth will give a closer approximation, then the error to $$\,\sqrt 2\,$$is only 0.007%.
 * }
 * }
 * }

Astronomical year and modern calendar
A calendar year is the period between two dates that with the same name in a calendar. For the calendar we use today, the numbers of days are all integers, but for astronomical year there is no such integer number of days or lunar months, for a year is $$\,365.24219878\,$$ days and one lunar month is $$\,29.530589\,$$ days, so any calendar as long as it follows an astronomical year must have its own system of adjustment such as the leap year intercalculation. We have noted that scientific calculations nowadays often use a 365-day calendar.

Many kinds of calendars are still in use today all around the world: Chinese, Ethiopian, Hebrew, Hindu etc. At a first glance,these calendar systems seam so different and are just based on arbitrary choices. However almost all calendars are based on the motion of the astronomical system, i.e. the motion of the Sun and the Moon by observation.

About 3000 years ago the 365-day calendar was first introduced, which called Alexandrian calendar. It has a sixth epagomenal day every fourth year. Our calendar in use today is directly descended from the ancient Roman calendar and following is the story.

Around 46 B.C. Julius Caesar learned about the Alexandrian calendar from Egypt through his campaign. The Alexandrian calendar at that time had a 4-year leap year cycle which He found was much more precise than the one Roman in use with 365 days. Along with him after the campaign was the Alexandrian astronomer Sosigenes, he gave Julius some advice on how to improve the accruracy. Upon the advices he received Julius created the Julian calendar based on his reform. The mean length of a year for Julian calendar is 365.25 days, which is already very precise comparing with the number 365.24219878. And the Julian calendar accumulates only one day error in about a hundred years long.

Idea of modern calendar with continued fraction
To decide a rule of modern calendar, we need to think about the idea: to have a period spanning several years during which some of the years are leap year while others are not. And the mean length of one year should be very close to the astronomical year. The period length should be either very short or very easy to use. As the Julian 4-year leap year cycle and Gregorian 400-year leap year cycle are nice examples.

Suppose we have a cycle of $$\,q \,$$ years and during which there are $$\,p \,$$ leap years.

Then there will be $$\,365q+p \,$$days in all during this period.(the leap year here is the year with 366 days)

The mean length for a year should be
 * {| style="width:100%" border="0" align="left"

\displaystyle \frac{365q+p}{q}=365+\frac{p}{q} $$ days.
 * }
 * }
 * }

For we already know there are $$\, 365.24219878 \,$$days in each year. So let's define
 * {| style="width:100%" border="0" align="left"

\displaystyle \alpha=365.24219878-365=0.24219878 $$ Then we need to find a proper number$$\,q\,$$ to make $$\,\frac{p}{q}\,$$as close as possible to $$\,\alpha\,$$.
 * }
 * }
 * }

Write $$\,\alpha\,$$as the form of continued fraction:
 * {| style="width:100%" border="0" align="left"

\displaystyle 0.24219878=\frac{1}{\displaystyle 4+\frac{1}{\displaystyle 7+\frac{1}{\displaystyle 1+\frac{1}{\displaystyle 3+\frac{1}{\displaystyle 5+\ddots}}}}} $$
 * }
 * }
 * }

Then we can write out a series of numbers of convergents.
 * {| style="width:100%" border="0" align="left"

\displaystyle C_1=\frac{p_1}{q_1}=\frac{1}{4} $$
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle C_2=\frac{p_2}{q_2}=\frac{7}{29} $$
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle C_3=\frac{p_3}{q_3}=\frac{8}{33} $$
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle C_4=\frac{p_4}{q_4}=\frac{31}{128} $$
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle C_5=\frac{p_5}{q_5}=\frac{163}{673} $$
 * }
 * }
 * }

Then we may find$$\,C_1\,$$in the sequence corresponds to the Julian 4-year-cycle system during which cycle there exists one leap year. And the remaining values seem not so convenient to be used like $$\,7\,$$leap years in a $$\,29\,$$ -year cycle as it's hard to distribute the 7 leap years. If we want to have a cycle spanning several centuries long,i.e.
 * {| style="width:100%" border="0" align="left"

\displaystyle q=100n \ \ \ n=1,2,3,\cdots,9 $$
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle \alpha = \frac{p}{q}=\frac{p}{100n}=0.24219878 $$
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle \frac{p}{n}=24.219878 $$ Then the problem turns to be finding p and n.
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle 24.219878=24+\frac{1}{\displaystyle 4+\frac{1}{\displaystyle 1+\frac{1}{\displaystyle 1+\frac{1}{\displaystyle 4+\ddots}}}} $$
 * }
 * }
 * }

The first 4 convergents are:
 * {| style="width:100%" border="0" align="left"

\displaystyle C_1=\frac{p_1}{n_1}=\frac{97}{4} $$
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle C_2=\frac{p_2}{n_2}=\frac{121}{5} $$
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle C_3=\frac{p_3}{n_3}=\frac{218}{9} $$
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle C_4=\frac{p_4}{n_4}=\frac{993}{41} $$ For we wish $$\ n\ $$ to be within [1,9]
 * }
 * }
 * }

We have three candidates 4,5 and 9.

And we may find $$\ n_1=4\ $$corresponds to $$\ q_1=100n_1=400\ $$, that's our Gregorian calendar.

For Gregorian calendar, there are 97 leap years in 400-year cycle. Then how do we assign these 97 years?

We define the year divisible by 4 except 100th, 200th and 300th be the leap year, there will be 100-3=97, just meet with the demands.

For the other two candidates, if we choose 5 as 500 years cycle.

We need 121 leap years in each cycle, we may still choose 4 year as a period, then
 * {| style="width:100%" border="0" align="left"

\displaystyle \frac{500}{4}=125 $$
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle 125-121=4 $$ We will have 4 more years if we just follow the only rule. So let's make some constraints: The year divisible by 100 with the exception of years divisible by 500 will not be accounted as leap years. Then all demands are met. This system is just as simple and as convenient as the Gregorian calendar and can provide a much better accuracy. As the last candidate 9, although it seems more accurate, the span is too long--900 years, and the distribution of 218 leap years is also a big problem.
 * }
 * }
 * }

Lastly, let's consider the situation if our calendar was based on a 500 year cycle. The problem may turn out to be the following expansion.
 * {| style="width:100%" border="0" align="left"

\displaystyle 500\times 0.24219878=121+\frac{1}{\displaystyle 10+\frac{1}{\displaystyle 16+\frac{1}{\displaystyle 3+\frac{1}{\displaystyle 2+\frac{1}{\displaystyle 2+\ddots}}}}} $$ The convergents will be:
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle [121,\ \frac{1211}{10},\ \frac{19497}{161},\ \frac{59702}{493},\ \frac{138901}{1147},\ \frac{337504}{2787},\cdots] $$ Let's see the second convergent,1211/10. It says 1211 leap years in a cycle of 5,000 years. The 5,000 year-cycle calendar will cause an accumulation of 1 day error in a 1 million years. So we can designate Feburary of year 5,000 to have 30 days. This system was proposed by Bernard Rasof.
 * }
 * }
 * }

About Public-Key Cryptography and RSA
Public-key cryptography refers to a cryptographic system that requires two different keys to fully operate, one key is in charge of locking and encrypting the plaintext, and the other is in charge of unlocking and decrypting the cyphered text. The two keys will function seperately and neither of them can do both. After that, one of the two keys is published to public and the other should be kept secret. The cryptographic approach will use asymmetric key algorithms such as RSA.

RSA is an algorithm for public key cryptography, which is based on the assumption that it's hard to do the factoring of large integers. RSA stands for three names: Ron Rivest, Adi Shamir and Leonard Adleman, who first described it in 1978. The idea of RSA is that firstly a user creates a number which is the product of two large prime numbers. Then the product along with the auxiliary value will be published to public as their public key. The two prime numbers should be kept secret, anyone can use the public key to encrypt a plaintext, but only with the currently published methods. Breaking RSA encryption is like solving an open question, but it's as hard as factoring a large number.

Wiener's attack on a typical RSA with small secret exponent
The security of RSA is based on the difficulty of finding the prime factors of large integers.

Let's define the modulus of a RSA cryptosystem as $$\,\,n\,\,$$, and it's the product of two large primes $$\,\,p\,\,$$ and $$\,\,q\,\,$$ so
 * {| style="width:100%" border="0" align="left"

\displaystyle n=p\times q $$ $$ The public exponent $$e$$ and the secret exponent $$d$$ are related by
 * $$\displaystyle (Equation\;2.4.1 )
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle e\times d\equiv 1,\ \ \ (mod \,\,\phi(n)) $$ $$ Where
 * $$\displaystyle (Equation\;2.4.2 )
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle \phi (n)=(p-1)(q-1)=n-p-q+1 $$ $$ In a typical RSA cryptosystem p and q have approximately the same number of bits, and e$$\displaystyle (Equation\;2.4.3 )
 * }
 * }

In 1990, Wiener developped a polynomial time algorithm for breaking through a typical(p and q are of the same size and e < n) RSA cryptosystem if the secret exponent d has at most 1/4 number of bits as the modulus n. i.e.
 * {| style="width:100%" border="0" align="left"

\displaystyle p\,<\,q\,<\,2p $$
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle e\,<\,n $$
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle d\,<\,\frac{1}{3}\sqrt[4]{n} $$ then d is the denominator of a convergent of the expansion of e/n in continued fraction.
 * }
 * }
 * }

''' For here I don't understand ! ''' There is an integer k such that
 * {| style="width:100%" border="0" align="left"

\displaystyle ed-k\phi(n)=0 $$ Now
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle \phi(n)\approx n $$ implies
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle \frac{k}{d}\approx \frac{e}{n} $$ More precisely, we have
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle n-3\sqrt{n} < \phi(n) < n $$ and
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle \left | \frac{k}{d}-\frac{e}{n}\right | < \frac{3k}{d\sqrt{n}} < \frac{1}{2d^2} $$ By Legendre's theorem, $$\,\frac{k}{d}\,$$ is a convergent of continued fraction expansion of $$\,\frac{e}{n}\,$$.
 * }
 * }
 * }

For the denominators grow exponentially, thus the total number of convergents of $$\,\frac{e}{n}\,$$ is of order O(log n). If we can test the convergent in polynomial time, then there will be a polynomial algorithm applicable to determine d.

Let's look at the following method to test convergents.

Let $$\frac{a}{b}$$ be a convergent of $$\frac{e}{n}$$, if it's the correct guess for $$\frac{k}{d}$$ , then $$\phi(n)$$ can be computed from
 * {| style="width:100%" border="0" align="left"

\displaystyle \phi(n)= (p-1)(q-1)=\frac{be-1}{a} $$ Now
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle \frac{pq-(p-1)(q-1)+1}{2}=\frac{p+q}{2} $$ $$ and
 * $$\displaystyle (Equation\;2.4.4 )
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle \left ( \frac{p+q}{2}\right ) ^2 -pq=\left ( \frac{q-p}{2}\right ) ^ 2 $$ $$ We can compute $$\frac{p+q}{2}$$ and $$\frac{q-p}{2}$$ from equation 2.4.4 and equation 2.4.5.
 * $$\displaystyle (Equation\;2.4.5 )
 * }
 * }

Factoring n with the help of continued fraction expansion of $$\,\frac{e}{n}\,$$
For example, let
 * {| style="width:100%" border="0" align="left"

\displaystyle n=7978886869909 $$
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle e=3594320245477 $$ and assume
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle d < 561 $$ Then, continued fraction expansion of $$\,\,\frac{e}{n}\,\,$$ is
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle \frac{e}{n}=\frac{3594320245477}{7978886869909}=\frac{1}{\displaystyle 2+\frac{1}{\displaystyle 4+\frac{1}{\displaystyle 1+\frac{1}{\displaystyle 1+\frac{1}{\displaystyle 4+\frac{1}{\displaystyle 1+\frac{1}{\displaystyle 2+\frac{1}{\displaystyle 31+\frac{1}{\displaystyle 21+\ddots}}}}}}}}} $$ the convergents are:
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle 0,\frac{1}{2},\frac{4}{9},\frac{5}{11},\frac{9}{20},\frac{41}{91},\frac{50}{111},\frac{141}{313},\frac{4421}{9814},\cdots $$ Applying test $$(2^e)^d\equiv 2\,\,(mod\,\,n)$$, we obtain $$\,\,d=313\,\,$$.
 * }
 * }
 * }

Then from the convergents result, we may find 141/313 with the denominator 313. So a/b=141/313, with
 * {| style="width:100%" border="0" align="left"

\displaystyle \begin{align} a &= 141 \\ b &= 313 \end{align} $$ After that, we can get
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle \phi(n)= (p-1)(q-1)=\frac{be-1}{a}=\frac{313\times 3594320245477-1}{141}=7978881112300 $$ Then, using equation 2.4.4:
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle \frac{p+q}{2}=\frac{pq-(p-1)(q-1)+1}{2}=\frac{n-\phi(n)+1}{2}=\frac{7978886869909-7978881112300+1}{2}=2878805 $$ And equation 2.4.5:
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle \frac{q-p}{2}=\sqrt{\left ( \frac{p+q}{2}\right )^2 -pq}=\sqrt{8287518228025-7978886869909}=555546 $$ This yields
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle \begin{align} p &= 2878805-555546=2323259 \\ q &= 2878805+555546=3434351 \end{align} $$ So, the factorization of n:
 * }
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle n=p\times q=2323259\times 3434351=7978886869909 $$
 * }
 * }
 * }

Summary
The paper consists of two parts. The first part introduced the definition and notation of continued fraction started from a motivation. The second part is the core part. We discussed the applications of CF in three different areas. Firstly, we discussed its two basic applications in mathematics. Secondly, we discussed its application to the Solar System. Thirdly, we talked about the relationship between CF and modern calendar. Lastly, we briefly described the using of CF in Cryptography and RSA attack.