I think you will need terms of the form a + c*%:b in your products.
This requires using different periodic portions
qp_to_pcf x:_15 _4 1 NB. 2+%:19
+-+-----------+
|6|2 1 3 1 2 8|
+-+-----------+
qp_to_pcf x:_37 _2 1 NB. 1+2*%:19
+-+----+
|7|6 12|
+-+----+
It is entirely tractable to create an inverse to qp_to_pcf and then
multiply the quadratics given the form you suggest. However,
I have not seen that done, only described by example.
I still think that it might be more practical to use rational
approximations...
Is it possible you could use quadratics as your representation?
Just brainstorming...
Henry Rich wrote:
> Yes, of interest, please. (and thanks Ambrus, but I would like to stick
> with continued-fraction form).
>
> What I meant was, something that operated on the continued fraction
> without converting to rational, which it seemed that mcf did.
>
> You are right that in general products of these are not repeating, but
> (a + %:b) * (c + %:b) would be, and I am trying to see if I can make use
> of that in something I am working on.
>
> Henry Rich
>
> Cliff Reiter wrote:
>> 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
>>>
> ----------------------------------------------------------------------
> 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