## Finding the fundamental unit of a real quadratic field

This is a program for finding the fundamental unit η of Q(√d), where d is a squarefree positive integer. It is a BCmath version of the BC program `unit`.

The algorithm is based on K. Rosen, *Elementary number theory and its applications*, p.382, B.A. Venkov, *Elementary Number theory*, p.62 and D. Knuth, *Art of computer programming*, Vol.2, p.359, with Pohst's trick of using half the period.
η=x+yω, where ω=(1 +√d)/2 if d ≡ 1 (mod 4), ω = √d otherwise.

*Last modified 2nd June 2006*

Return to main page