On Thu, Apr 24, 2008 at 9:47 AM, John Cremona <[EMAIL PROTECTED]> wrote:
>
> 2008/4/24 William Stein <[EMAIL PROTECTED]>:
>
>
> >
> > On Thu, Apr 24, 2008 at 7:35 AM, bill.p <[EMAIL PROTECTED]> wrote:
> > >
> > > I needed to derive some continued fractions and a quick search of the
> > > index suggests that the Pari-GP function 'contfrac' might be what I
> > > needed.
> > > A simple test in the notebook:
> > >
> > > gp('contfrac(sqrt(6))')
> > >
> > > produced
> > >
> > > [2, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2,
> 4,
> > > 2, 4, 2, 4, 2,
> > > 4, 2, 4, 2, 4, 2]
> > >
> > > which is not exactly what I expected. I'd expect either:
> > >
> > > [2;2,4]
> > > or
> > > [2,2,4,2,4,2,4,2,4,....]
> > >
> > > the latter implying that the expansion continues. Does the result
> > > given mean that
> > > Pari is using a limited precision evaluation of sqrt(6)?
> >
> > Yes.
> >
> >
> > > I'd prefer
> > > the first of my expected
> > > results, giving a simple infinite continued fraction.
> >
> > There is no such functionality in pari or as far as I know in Sage.
> >
> > By the way, Sage also has a continued_fraction command.
> >
> > sage: a = continued_fraction(sqrt(6),200); a
> >
> > [2, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4,
> > 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2,
> > 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4]
> > [2, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 2, 1]
>
> In fact there is a whole "continued fraction field" implemented in
> sage.rings.contfrac.py, with a lot of clever looking code in it, but
> it does not (as far as I could see) implement the construction which
> bill.p wanted from a quadratic surd. That file seems to have no
> Author listed, so I don't know who wrote it!
>
I wrote it. It indeed doesn't have any notion of infinite
continued fraction.
-- William
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---