Selenius' algorithm for converting the regular continued fraction (RCF) period to the nearest square continued fraction (NSCF) period

See Clas-Olaf Selenius, Konstruction und Theorie Halbregelmässiger Kettenbrüche mit idealer relativer Approximation, Acta Acad. Abo. Math. Phys. 22, (1960), 3-77.

The algorithm was presented by Selenius for ξ0=√D, but is valid if ξ0=(P0+√D)/Q0 is reduced or ξ0=(P0+√D)/Q0 is not reduced, but Q0>0.

Here ξ0=(u+t√d)/v, t non-zero, u,v,t,d integers, d > 1 and non-square.

We find the NSCF expansion until the end of the first RCF period is reached.
The output includes the positive and negative representations of the resulting NSCF complete quotients &xin (See page 25, of the paper by A.A. Krisnaswami Ayyangar)

(Pn,Qn) = an + (P'n,Q'n)-1 = an + 1 - (P"n,Q"n)-1,

where (Pn,Qn) represents ξn = (Pn + √d)/Qn and an = ⌊&xin⌋.

Enter d (1 < d < 1015 and not a square):
Enter t (nonzero):
Enter u:
Enter v: (nonzero)

Last modified 22nd April 2008
Return to main page