πŸ–ŠοΈ
Crypto
  • Crypto
  • Fundamentals
    • Divisibility, Factors and Euclid's Algorithms
    • Modular Arithmetic
    • Rings, Fields and Euler's Totient Function
  • Further Maths
    • Continued Fractions
  • RSA
    • Overview
    • Public Exponent Attacks
      • e=1
      • Small e
      • Multi-party RSA with Small e
      • Wiener's Attack
    • Choice of Primes
      • N is prime
      • Mersenne Primes
      • P=Q
      • Fermat Factorisation
    • Factorisation Methods
      • Pollard's p-1
  • Diffie-Hellman Key Exchange
    • Overview
    • Solving the DLP
      • Baby Step, Giant Step
Powered by GitBook
On this page
  • Overview
  • Example
  • Convergents
  • Properties of Convergences
  • Sage

Was this helpful?

  1. Further Maths

Continued Fractions

Overview

Continued Fractions are a way of representing real numbers as a sequence of positive integers. Let's say we have a real number Ξ±1\alpha_1Ξ±1​. We can form a sequence of positive integers from Ξ±1\alpha_1Ξ±1​ in this way:

Ξ±1=a1+1Ξ±2,whereΒ a1=⌊xβŒ‹\alpha_1 = a_1 + \frac{1}{\alpha_2}, \text{where } a_1=\left \lfloor{x}\right \rfloor Ξ±1​=a1​+Ξ±2​1​,whereΒ a1​=⌊xβŒ‹

​For example, let's say Ξ±1=1.5\alpha_1=1.5Ξ±1​=1.5​. We can say that

Ξ±1=1+12,withΒ Ξ±2=2\alpha_1 = 1 + \frac{1}{2}, \text{with } \alpha_2 = 2Ξ±1​=1+21​,withΒ Ξ±2​=2

​The trick here is that if Ξ±2∉Z\alpha_2\not\in \mathbb{Z}Ξ±2β€‹ξ€ βˆˆZ, we can continue this exact process with Ξ±2\alpha_2Ξ±2​ and keep the continued fraction going.

Ξ±1=a1+1a2+1a3+1β‹±\alpha_1 = a_1 + \frac{1}{a_2 + \frac{1}{a_3 + \frac{1}{\ddots}}}Ξ±1​=a1​+a2​+a3​+β‹±1​1​1​

Example

Let's take another example, that of 1711\frac{17}{11}1117​:

1711=1+611=1+1116=1+11+56=1+11+165=1+11+11+15\frac{17}{11} = 1 + \frac{6}{11} = 1 + \frac{1}{\frac{11}{6}} = 1 + \frac{1}{1 + \frac{5}{6}} = 1 + \frac{1}{1 + \frac{1}{\frac{6}{5}}} = 1 + \frac{1}{1 + \frac{1}{1 + \frac{1}{5}}}1117​=1+116​=1+611​1​=1+1+65​1​=1+1+56​1​1​=1+1+1+51​1​1​

​The list of continued fractions is represented as a list of the coefficients aia_iai​, in this case

1711=[1;1,1,5]\frac{17}{11} = \left[ 1; 1, 1, 5 \right]1117​=[1;1,1,5]

Convergents

The kkkth convergent of a continued fraction is the approximation of the fraction we gain by truncating the continued fraction and using only the first kkk terms of the sequence, for example the 2nd convergence of 1711\frac{17}{11}1117​ is 1+11=21=21 + \frac{1}{1} = \frac{2}{1} = 21+11​=12​=2​ while the 3rd would be 1+11+11=1+12=321 + \frac{1}{1 + \frac{1}{1}} = 1 + \frac{1}{2} = \frac{3}{2}1+1+11​1​=1+21​=23​.

One of the obvious applications of these convergents is as rational approximations to irrational numbers.

Properties of Convergences

  • As a sequence, they have a limit

    • This limit is Ξ±1\alpha_1Ξ±1​, the real number you are attempting to approximate

  • They are alternately greater than and less than Ξ±1\alpha_1Ξ±1​

Sage

In Sage, we can define a continue fraction very easily:

f = continued_fraction(17/11)

We can then print off the list of coefficients:

print(f)
>>> [1; 1, 1, 5]

And the convergents are even calculated for us:

print(f.convergents())
>>> [1, 2, 3/2, 17/11]
PreviousRings, Fields and Euler's Totient FunctionNextOverview

Last updated 3 years ago

Was this helpful?