Karim BELABAS on Wed, 19 Nov 2003 18:28:37 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: contfrac bug?


On Wed, 19 Nov 2003, Phil Carmody wrote:
> You-know-who says:
> In[1]:= ContinuedFraction[Pi/2, 2]
> Out[1]= {1, 1}
> In[2]:= ContinuedFraction[Pi/2, 3]
> Out[2]= {1, 1, 1}
> In[3]:=  ContinuedFraction[Pi/2, 4]
> Out[3]= {1, 1, 1, 3}
>
> Pari says:
> (16:26) gp > contfrac(Pi/2,,2)
> %14 = [1, 1]
> (16:26) gp > contfrac(Pi/2,,3)
> %15 = [1, 2]
> (16:26) gp > contfrac(Pi/2,,4)
> %16 = [1, 1, 1, 3]
>
> Both x86 2.2.6 and Alpha 2.2.7 (development CHANGES-1.855) (i.e.
> last night's nightly build) suffer from the above.
> (my x86 2.1.3 is even more bizarre, for reference).

Åccording to the doc, only the first one is faulty: answer should be [2].
Fixed in CVS.

This routine is normalized so that the last entry is never 1 ( unless the
result is [1] ). Ie. it always replaces [ a_0,..., a_n, 1] by
[ a_0,..., a_n + 1].

    Karim.
-- 
Karim Belabas                     Tel: (+33) (0)1 69 15 57 48
Dép. de Mathématiques, Bât. 425   Fax: (+33) (0)1 69 15 60 19
Université Paris-Sud              http://www.math.u-psud.fr/~belabas/
F-91405 Orsay (France)            http://pari.math.u-bordeaux.fr/  [PARI/GP]