Ejemplo n.º 1
0
    def _rational_(self):
        """
        EXAMPLES::

            sage: a = CFF(-17/389); a
            [-1, 1, 21, 1, 7, 2]
            sage: a._rational_()
            -17/389
            sage: QQ(a)
            -17/389
        """
        try:
            return self.__rational
        except AttributeError:
            r = convergents(self._x)[-1]
            self.__rational =r
            return r
Ejemplo n.º 2
0
    def _rational_(self):
        """
        EXAMPLES::

            sage: a = CFF(-17/389); a
            [-1, 1, 21, 1, 7, 2]
            sage: a._rational_()
            -17/389
            sage: QQ(a)
            -17/389
        """
        try:
            return self.__rational
        except AttributeError:
            r = convergents(self._x)[-1]
            self.__rational = r
            return r
Ejemplo n.º 3
0
    def convergents(self):
        """
        Return a list of rational numbers, which are the partial
        convergents of this continued fraction.

        OUTPUT:

            - list of rational numbers

        EXAMPLES::

            sage: a = CFF(pi, bits=34); a
            [3, 7, 15, 1, 292]
            sage: a.convergents()
            [3, 22/7, 333/106, 355/113, 103993/33102]
            sage: a.value()
            103993/33102
            sage: a[:-1].value()
            355/113
        """
        return convergents(self._x)
Ejemplo n.º 4
0
    def convergents(self):
        """
        Return a list of rational numbers, which are the partial
        convergents of this continued fraction.

        OUTPUT:

            - list of rational numbers

        EXAMPLES::

            sage: a = CFF(pi, bits=34); a
            [3, 7, 15, 1, 292]
            sage: a.convergents()
            [3, 22/7, 333/106, 355/113, 103993/33102]
            sage: a.value()
            103993/33102
            sage: a[:-1].value()
            355/113
        """
        return convergents(self._x)