[sage-support] Re: Simple continued fractions in Pari
On Wed, Apr 30, 2008 at 8:51 PM, Dan Drake <[EMAIL PROTECTED]> wrote:
> On Wed, 30 Apr 2008 at 09:10AM -0700, bill.p wrote:
> > > My present thought is that I'd need a list of integers plus another
> > > integer - the integer could either be the number of non-recurring
> > > terms, or it could be the number of recurring terms. Given the way
> > > that Python handles negative indices I guess the second option could
> > > amount to the same thing by making it negative. Again, feedback
> > > welcomed.
> > >
> > > Bill
> > Hmmm, I'll take that as 'No Interest' then
>
> I haven't been following this carefully, but I'd like to see a format
> for quadratic irrationals that is along the same lines as Mathematica:
>
> ContinuedFraction[Sqrt[15]]
>
> yields
>
> {3, {1, 6}}.
BTW, you can do this in GAP via SAGE:
sage: gap.eval("x := Indeterminate(Integers);;")
''
sage: eval(gap.eval("ContinuedFractionExpansionOfRoot(x^2-15,20)"))
[3, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1]
http://www.gap-system.org/Manuals/doc/htm/ref/CHAP015.htm#SECT005
It would probably be straightforward to write a pexpect wrapper
>
> The first entry is the integer part, and after that, we'd have a tuple
> or list that gives you the periodic stuff. Rational numbers would be
> just a list of integers:
>
> {3, 7, 15, 1, 292, 1, 1, 1, 2, 1}
>
> It would also be nice if you could do symbolic expressions as entries in
> the list.
>
> Dan
>
> --
> --- Dan Drake <[EMAIL PROTECTED]>
> - KAIST Department of Mathematical Sciences
> --- http://math.kaist.ac.kr/~drake
>
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.4.6 (GNU/Linux)
>
> iD8DBQFIGRQjr4V8SljC5LoRAqr4AKC6RNAFBhBCkilu0tzy3qzGUVyWMQCgzDZL
> IsNOy5VwOE2sENvbAZ7kXc8=
> =jGFv
> -END PGP SIGNATURE-
>
>
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---
[sage-support] Re: Simple continued fractions in Pari
On Tuesday 06 May 2008, Carl Witty wrote: > ... > > If anyone can supply more info on what Mathmatica can do in this area > > it would be appreciated > > The Mathematica documentation is available online; for example, the > documentation for ContinuedFraction is at > http://reference.wolfram.com/mathematica/ref/ContinuedFraction.html > > Carl > Thanks, Carl. Bill -- +---+ | Bill Purvis, Web Designer | | email: [EMAIL PROTECTED]| +---+ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[sage-support] Re: Simple continued fractions in Pari
On May 1, 3:15 am, bill purvis <[EMAIL PROTECTED]> wrote:
> On Thursday 01 May 2008, Dan Drake wrote:
>
> > On Wed, 30 Apr 2008 at 09:10AM -0700, bill.p wrote:
> > > > My present thought is that I'd need a list of integers plus another
> > > > integer - the integer could either be the number of non-recurring
> > > > terms, or it could be the number of recurring terms. Given the way
> > > > that Python handles negative indices I guess the second option could
> > > > amount to the same thing by making it negative. Again, feedback
> > > > welcomed.
>
> > > > Bill
>
> > > Hmmm, I'll take that as 'No Interest' then
>
> > I haven't been following this carefully, but I'd like to see a format
> > for quadratic irrationals that is along the same lines as Mathematica:
>
> > ContinuedFraction[Sqrt[15]]
>
> > yields
>
> > {3, {1, 6}}.
>
> > The first entry is the integer part, and after that, we'd have a tuple
> > or list that gives you the periodic stuff. Rational numbers would be
> > just a list of integers:
>
> > {3, 7, 15, 1, 292, 1, 1, 1, 2, 1}
>
> > It would also be nice if you could do symbolic expressions as entries in
> > the list.
>
> > Dan
>
> Thanks for the suggestion. That means I can handle the existing stuff as
> a special case (no sublists).
>
> I've not been able to afford a copy of Mathmatica (impoverished, retired,
> software engineer) so I was unaware
> of what it provided.
>
> If anyone can supply more info on what Mathmatica can do in this area
> it would be appreciated
The Mathematica documentation is available online; for example, the
documentation for ContinuedFraction is at
http://reference.wolfram.com/mathematica/ref/ContinuedFraction.html
Carl
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---
[sage-support] Re: Simple continued fractions in Pari
On Thursday 01 May 2008, Dan Drake wrote:
> On Wed, 30 Apr 2008 at 09:10AM -0700, bill.p wrote:
> > > My present thought is that I'd need a list of integers plus another
> > > integer - the integer could either be the number of non-recurring
> > > terms, or it could be the number of recurring terms. Given the way
> > > that Python handles negative indices I guess the second option could
> > > amount to the same thing by making it negative. Again, feedback
> > > welcomed.
> > >
> > > Bill
> >
> > Hmmm, I'll take that as 'No Interest' then
>
> I haven't been following this carefully, but I'd like to see a format
> for quadratic irrationals that is along the same lines as Mathematica:
>
> ContinuedFraction[Sqrt[15]]
>
> yields
>
> {3, {1, 6}}.
>
> The first entry is the integer part, and after that, we'd have a tuple
> or list that gives you the periodic stuff. Rational numbers would be
> just a list of integers:
>
> {3, 7, 15, 1, 292, 1, 1, 1, 2, 1}
>
> It would also be nice if you could do symbolic expressions as entries in
> the list.
>
> Dan
Thanks for the suggestion. That means I can handle the existing stuff as
a special case (no sublists).
I've not been able to afford a copy of Mathmatica (impoverished, retired,
software engineer) so I was unaware
of what it provided.
If anyone can supply more info on what Mathmatica can do in this area
it would be appreciated
Bill
--
+---+
| Bill Purvis, Amateur Mathematician|
| email: [EMAIL PROTECTED]|
+---+
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---
[sage-support] Re: Simple continued fractions in Pari
On Wednesday 30 April 2008, Georg Muntingh wrote: > Actually, I think this would be very nice to have. (Infinite) > continued fractions pop up everywhere (I recently saw them in the > resolution of toric singularities!). Moreover, they are so easy to > understand that they also pop up in popular scientific math questions, > like at Project Euler. > > So yes, please implement them! I didn't say I could implement them, only that I'd have a go at it! I'm not an expert in these, by any means, but find them intriguing. Also, despite being retired, I have demands on my time, so don't expect anything this week! ;-) Bill -- +---+ | Bill Purvis, Amateur Mathematician| | email: [EMAIL PROTECTED]| +---+ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[sage-support] Re: Simple continued fractions in Pari
On Wed, 30 Apr 2008 at 09:10AM -0700, bill.p wrote:
> > My present thought is that I'd need a list of integers plus another
> > integer - the integer could either be the number of non-recurring
> > terms, or it could be the number of recurring terms. Given the way
> > that Python handles negative indices I guess the second option could
> > amount to the same thing by making it negative. Again, feedback
> > welcomed.
> >
> > Bill
> Hmmm, I'll take that as 'No Interest' then
I haven't been following this carefully, but I'd like to see a format
for quadratic irrationals that is along the same lines as Mathematica:
ContinuedFraction[Sqrt[15]]
yields
{3, {1, 6}}.
The first entry is the integer part, and after that, we'd have a tuple
or list that gives you the periodic stuff. Rational numbers would be
just a list of integers:
{3, 7, 15, 1, 292, 1, 1, 1, 2, 1}
It would also be nice if you could do symbolic expressions as entries in
the list.
Dan
--
--- Dan Drake <[EMAIL PROTECTED]>
- KAIST Department of Mathematical Sciences
--- http://math.kaist.ac.kr/~drake
signature.asc
Description: Digital signature
[sage-support] Re: Simple continued fractions in Pari
Actually, I think this would be very nice to have. (Infinite) continued fractions pop up everywhere (I recently saw them in the resolution of toric singularities!). Moreover, they are so easy to understand that they also pop up in popular scientific math questions, like at Project Euler. So yes, please implement them! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[sage-support] Re: Simple continued fractions in Pari
On Apr 28, 5:39 pm, "bill.p" <[EMAIL PROTECTED]> wrote:
> On Apr 24, 5:50 pm, "William Stein" <[EMAIL PROTECTED]> wrote:
>
> > 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
>
> I now have some code for computing recurrent infinite continued
> fractions and was thinking about
> how I could fit this in with the existing CFF stuff. I've had a brief
> look at contfrac.py and it would
> seem that I will need to re-implement the whole lot as it needs more
> than just a simple vector
> of integers to express the repetition. I am willing to have a go at
> this if there is a reasonable
> probability that it would be useful. Can I request some feedback on
> this?
>
> My present thought is that I'd need a list of integers plus another
> integer - the integer could either be the
> number of non-recurring terms, or it could be the number of recurring
> terms. Given the way that
> Python handles negative indices I guess the second option could amount
> to the same thing by
> making it negative. Again, feedback welcomed.
>
> Bill
Hmmm, I'll take that as 'No Interest' then
Bill
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---
[sage-support] Re: Simple continued fractions in Pari
On Apr 24, 5:50 pm, "William Stein" <[EMAIL PROTECTED]> wrote:
> 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
I now have some code for computing recurrent infinite continued
fractions and was thinking about
how I could fit this in with the existing CFF stuff. I've had a brief
look at contfrac.py and it would
seem that I will need to re-implement the whole lot as it needs more
than just a simple vector
of integers to express the repetition. I am willing to have a go at
this if there is a reasonable
probability that it would be useful. Can I request some feedback on
this?
My present thought is that I'd need a list of integers plus another
integer - the integer could either be the
number of non-recurring terms, or it could be the number of recurring
terms. Given the way that
Python handles negative indices I guess the second option could amount
to the same thing by
making it negative. Again, feedback welcomed.
Bill
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---
[sage-support] Re: Simple continued fractions in Pari
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
-~--~~~~--~~--~--~---
[sage-support] Re: Simple continued fractions in Pari
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!
John
>
> 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
-~--~~~~--~~--~--~---
[sage-support] Re: Simple continued fractions in Pari
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]
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
-~--~~~~--~~--~--~---
