# Fractals/Continued fraction

            "Do not worry about your problems with mathematics, I assure you mine are far greater." Albert Einstein


# Notation

A continued fraction is an expression of the form

$a_{0}+{\cfrac {b_{1}}{a_{1}+{\cfrac {b_{2}}{a_{2}+{\cfrac {b_{3}}{a_{3}+{_{\ddots }}}}}}}}$

where :

• $a_{n}$  and $b_{n}$  are either integers, rational numbers, real numbers, or complex numbers.
• $a_{0}$ , $a_{1}$  etc., are called the coefficients or terms of the continued fraction

Variants or types :

• If $b_{n}=1$  for all $n$  the expression is called a simple continued fraction.
• If the expression contains a finite number of terms, it is called a finite continued fraction.
• If the expression contains an infinite number of terms, it is called an infinite continued fraction.

Thus, all of the following illustrate valid finite simple continued fractions:

Examples of finite simple continued fractions
Formula Numeric Remarks
$\ a_{0}$  $\ 2$  All integers are a degenerate case
$\ a_{0}+{\cfrac {1}{a_{1}}}$  $\ 2+{\cfrac {1}{3}}$  Simplest possible fractional form
$\ a_{0}+{\cfrac {1}{a_{1}+{\cfrac {1}{a_{2}}}}}$  $\ -3+{\cfrac {1}{2+{\cfrac {1}{18}}}}$  First integer may be negative
$\ a_{0}+{\cfrac {1}{a_{1}+{\cfrac {1}{a_{2}+{\cfrac {1}{a_{3}}}}}}}$  $\ {\cfrac {1}{15+{\cfrac {1}{1+{\cfrac {1}{102}}}}}}$  First integer may be zero

## simple continued fractions

### Finite

Notation :

 $a_{0}+{\cfrac {1}{a_{1}+{\cfrac {1}{a_{2}+{\cfrac {1}{a_{3}}}}}}}=[a_{0};a_{1},a_{2},a_{3}]$ Every finite continued fraction represents a rational number ${\frac {p}{q}}$ :

  ${\frac {p}{q}}=a_{0}+{\cfrac {1}{a_{1}+{\cfrac {1}{a_{2}+{\cfrac {1}{a_{3}}}}}}}=[a_{0};a_{1},a_{2},a_{3}]$ ### Infinite

Notation :

 $a_{0}+{\cfrac {1}{a_{1}+{\cfrac {1}{a_{2}+{\cfrac {1}{a_{3}+{\ddots }}}}}}}=[a_{0};a_{1},a_{2},a_{3},\ldots ]$ Every infinite continued fraction is irrational number $\alpha$  :

 $\alpha =a_{0}+{\cfrac {1}{a_{1}+{\cfrac {1}{a_{2}+{\cfrac {1}{a_{3}+{\ddots }}}}}}}=[a_{0};a_{1},a_{2},a_{3},\ldots ]$ The rational number ${\frac {p_{n}}{q_{n}}}$  obtained by limited number of terms in a continued fraction is called a n-th convergent

  ${\frac {p_{n}}{q_{n}}}=a_{0}+{\cfrac {1}{a_{1}+{\cfrac {1}{a_{2}+{\cfrac {1}{a_{3}+{\cfrac {1}{{\ddots }+{\cfrac {1}{a_{n}}}}}}}}}}}=[a_{0};a_{1},a_{2},a_{3},\ldots ,a_{n}]$ because sequence of rational numbers ${\frac {p_{n}}{q_{n}}}$  converges to irrational number $\alpha$

 $\lim _{n\rightarrow \infty }{\frac {p_{n}}{q_{n}}}=\alpha$ In other words irrational number $\alpha$  is the limit of convergent sequence.

Nominator p and denominator q can be found using the relevant recursive relation:

$p_{n}=a_{n}p_{n-1}+p_{n-2}$
$q_{n}=a_{n}q_{n-1}+q_{n-2}$

so

${\frac {p_{n}}{q_{n}}}={\frac {a_{n}p_{n-1}+p_{n-2}}{a_{n}q_{n-1}+q_{n-2}}}$

Key words :

• the sequence of continued fraction convergents ${\frac {p_{n}}{q_{n}}}$  of irrational number $\alpha$
• sequence of the convergents
• continued fraction expansion
• rational aproximation of irrational number
• a best rational approximation to a real number r by rational number p/q

# How to use it in computer programs

## Maxima CAS

In Maxima CAS one have cf and float(cfdisrep())

(%i2) a:[0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
(%o2) [0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
(%i3) t:cfdisrep(a)
(%o3) 1/(1+1/(1+1/(1+1/(1+1/(1+1/(1+1/(1+1/(1+1/(1+1/(1+1/(1+1/(1+1/(1+1/(1+1/(1+1/(1+1/(1+1/(1+1/(1+1/(1+1/(1+1/(1+1/1))))))))))))))))))))))
(%i4) float(t)
(%o4) 0.618033988957902


To compute n-th convergent:

(%i10) a;
(%o10) [0, 3, 2, 1000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
(%i11) a3: listn(a,3);
(%o11) listn([0, 3, 2, 1000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1], 3)
(%i12) a3: firstn(a,3);
(%o12)                             [0, 3, 2]
(%i13) cf3:cfdisrep(a3);
1
(%o13)                               -----
1
3 + -
2
(%i14) r3:ratsimp(cf3);
2
(%o14)                                 -
7
(%i15)


# Examples

• number theory
• continued fractions based functions over the complex plan
• " a continued fraction may be regarded as a sequence of Möbius maps" Alan F. Beardone