コード例 #1
0
ファイル: contfrac.py プロジェクト: sageb0t/testsage
    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
コード例 #2
0
ファイル: contfrac.py プロジェクト: sajedel/testsage
    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
コード例 #3
0
ファイル: contfrac.py プロジェクト: sageb0t/testsage
    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)
コード例 #4
0
ファイル: contfrac.py プロジェクト: sajedel/testsage
    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)