| 1 | initial version |
Here is an example:
sage: a = 26 / 7
sage: c = continued_fraction(a)
sage: c
[3; 1, 2, 2]
From there one can explore the convergents:
sage: c.convergent(0)
3
sage: c.convergent(1)
4
sage: c.convergent(2)
11/3
sage: c.convergent(3)
26/7
The numerator and denominator of a convergent can be called using the methods
numerator and denominator or p and q.
sage: c.numerator(2)
11
sage: c.denominator(2)
3
sage: c.p(2)
11
sage: c.q(2)
3
One can also start from a list:
sage: c = continued_fraction([3, 1, 2, 2])
sage: c
[3; 1, 2, 2]
etc.
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.