### Calculating the quadratic irrationality whose simple continued fraction is given

The quadratic irrationality ω is given as a simple continued fraction:
ω = [a_{0},...,a_{p-1},\overline**{**b_{0},...,b_{q-1}**}**].

Here the *pre-period*, a_{0},...,a_{p-1} consists of integers, with a_{1},...,a_{p-1} positive if p > 1.

Also the *period* b_{0},...,b_{q-1} consists of positive integers.
If there is no pre-period, simply enter 0 0 in the pre-period box below.

**The construction**.

Let ζ be the purely periodic *reduced* (ie. ζ > 1 & -1 < ζ′ < 0) quadratic irrational defined by

ζ = [\overline**{**b_{0},...,b_{q-1}**}**].

Then
ζ = (A_{q-1}ζ + A_{q-2})/(B_{q-1}ζ + B_{q-2}),

where A_{n}/B_{n} is the n-th convergent to ζ. (See O. Perron, *Kettenbrüche*, Zweite verbesserte Auflage, Seite 69.)
This gives a quadratic equation:

B_{q-1}ζ^{2} + (B_{q-2} – A_{q-1})ζ – A_{q-2} = 0.

Solving for ζ gives
ζ = (A_{q-1} - B_{q-2} + √**{**(A_{q-1} – B_{q-2})^{2} + 4A_{q-2}B_{q-1}**}**) / 2B_{q-1}.

Then
ω = (A_{p-1}ζ + A_{p-2})/(B_{p-1}ζ + B_{p-2}),

where A_{n}/B_{n} is the n-th convergent to ω. (See O. Perron, *Kettenbrüche*, Zweite verbesserte Auflage, Seite 85.)
We print ω in standard form (u+√d)/v, where v divides d - u^{2} and gcd(u,v,(d-u^{2})/v = 1.

*Last modified 4th February 2013*

Return to main page