Testing a quadratic irrational for being RCF reduced

A quadratic surd (p + √d)/q is called reduced if (p + √d)/q> 1 and -1 < (p – √d)/q < 0.
Equivalently, p < √d and q – p < √d < q + p. This in turn is equivalent to p ≤ x and q – p ≤ x < q + p, where x=int(√d).

This program takes a quadratic surd ξ=(p + √d)/q, p > 0, q > 0 and decides whether or not ξ is RCF reduced. In the case that it is RCF reduced, its RCF reduced predecessor and successor are determined.

Enter d (1 < d < 1015 and not a square):
Enter p: (> 0)
Enter q: (> 0)

Last modified 15th December 2009
Return to main page