By the way, unless you cf represent only surds of the form %:n,
(not a+b*%:n), I think the product is quartic and so the cf
expansion of the product will not be periodic.
Here is a bit more from my script (updated to 602) that was used
in that book, in case they might be of interest.
NB. quadratic poly translation
qp_tr=: 0 1 1&*...@] + (] p. -...@[) , (-...@+:@[ * {:@]),0:
3 qp_tr 0 0 1
10 qp_tr 3 1000 10
NB. floor of root of quadratic poly
p. 6 _5 1
p. 1 _5 6
fr_qp =: >./@:<.@:>@:{:@p.
]t=:fr_qp _10 0 1
(-t) qp_tr _10 0 1
p. _10 0 1
p. (-t) qp_tr _10 0 1
NB. quadratic poly to periodic continued fraction
NB. (extra: list of polys)
qp_to_pcfx=:3 : 0
qpl=.,: qp=.(*...@{:) y
z=.i.0
while. -. qp e. }: qpl do.
t=.fr_qp qp
z=.z,t
qp=.(*...@{:)|. (-t) qp_tr qp
qpl=.qpl,qp
end.
z;qpl
)
qp_to_pcfx _3 0 1
NB. quadratic poly to periodic continued fraction
qp_to_pcf =: 3 : 0
'z qpl'=. qp_to_pcfx y
i=.(}: i. {:)qpl
(i{.z);i}.z
)
qp_to_pcf _3 0 1
; qp_to_pcf _106 0 1
fcf_to_cv ; qp_to_pcf _106 0 1
]'x y'=._2{fcf_to_cv ;qp_to_pcf _106 0 1
(x^2) - 106 *y^2
c_f_unit=: _2&{@:fcf_to_cv@:;@:qp_to_pcf@:(,&0 1)@:-"0
n=: 101 102 103 105 106 107 108 109
]'x y'=:|:c_f_unit n
(x^2) - n *y^2
sel_sqf=: <&2@:(>./)@:{:@:(__&q:)"0 # ]
(;"0 1 c_f_unit)sel_sqf 1000+i.20
Alas, I can't offer the book (156pp+) as the fonts don't work
in the 90s era wordprocessor I used to write the book &
I threw away the extra hardcopies last summer when my office
was repainted :(.
--
Clifford A. Reiter
Mathematics Department, Lafayette College
Easton, PA 18042 USA, 610-330-5277
http://www.lafayette.edu/~reiterc
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm