Calculating the quadratic irrationality whose simple continued fraction is given

The quadratic irrationality ω is given as a simple continued fraction:

ω = [a0,...,ap-1,\overline{b0,...,bq-1}].

Here the pre-period, a0,...,ap-1 consists of integers, with a1,...,ap-1 positive if p > 1.
Also the period b0,...,bq-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{b0,...,bq-1}].

Then

ζ = (Aq-1ζ + Aq-2)/(Bq-1ζ + Bq-2),

where An/Bn is the n-th convergent to ζ. (See O. Perron, Kettenbrüche, Zweite verbesserte Auflage, Seite 69.)

This gives a quadratic equation:

Bq-1ζ2 + (Bq-2 – Aq-1)ζ – Aq-2 = 0.

Solving for ζ gives

ζ = (Aq-1 - Bq-2 + √{(Aq-1 – Bq-2)2 + 4Aq-2Bq-1}) / 2Bq-1.

Then

ω = (Ap-1ζ + Ap-2)/(Bp-1ζ + Bp-2),

where An/Bn 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 - u2 and gcd(u,v,(d-u2)/v = 1.

Enter the pre-period (or 0 0 if no pre-period), separated by spaces:

Enter the period, separated by spaces:

Last modified 4th February 2013
Return to main page