Henry,
I am confused.
1 2 3 4 mcf 1 1 2 1 1
2 2 5 3
takes two finite continued fractions and gives the continued
fraction for the product. What do you mean by finite cf-product
if not that?
In the book for my number theory workshop, I also have
utilities for converting between (preperiod;period) and
quadratic polynomial representations (section G.2). Of interest?
Maybe you should share an illustration of what you want.
Best,
Cliff
Henry Rich wrote:
> The continued fractions I want to work with are infinite repeating, so
> converting to rational doesn't help. The products will also be infinite
> repeating, though. If we can come up with a finite cf-product, I could
> adapt it to my uses.
>
> Henry Rich
>
> Dan Bron wrote:
>> Henry wrote:
>>> Does anyone have J code for multiplying two numbers expressed as
>>> simple continued fractions, producing a continued-fraction result?
>> Roger responded:
>>> As a first approximation, convert to two single (rational) numbers;
>>> mutliply; convert back. *&.conv
>> Here's one way to do that:
>>
>> NB. Continued fraction to decimal
>> cf2d =: (+%)/
>>
>> NB. Decimal to continued fraction
>> d2cf =: }:@:<.@:(%@:(-<.)^:(_&>)^:a:&.x:)
>>
>> NB. continued fraction <-> decimal
>> cf =: cf2d :. d2cf
>>
>> NB. Multiply continued fractions
>> cfM =: *&.cf
>>
>> I'm sure there are superior algorithms, in particular for d2cf . I'm
>> thinking along the line of Euler's GCD algorithm. There's a lot of depth
>> hidden in J's rational numbers and the relevant primitives (e.g. +. |
>> #: ).
>>
>> There might also be a direct way (without the intermediate conversion to
>> decimal), but no ideas occur to me, personally.
>>
>> -Dan
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
--
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