示例#1
0
文件: log.py 项目: mcognetta/sage
    def _eval_(self, z, **kwds):
        """
        EXAMPLES::

            sage: harmonic_number(0)
            0
            sage: harmonic_number(1)
            1
            sage: harmonic_number(20)
            55835135/15519504
            sage: harmonic_number(5/2)
            -2*log(2) + 46/15
            sage: harmonic_number(2*x)
            harmonic_number(2*x)
        """
        if z in ZZ:
            if z == 0:
                return Integer(0)
            elif z == 1:
                return Integer(1)
            elif z > 1:
                import sage.libs.flint.arith as flint_arith
                return flint_arith.harmonic_number(z)
        elif z in QQ:
            from sage.functions.other import psi1
            return psi1(z+1) - psi1(1)
示例#2
0
文件: log.py 项目: yarv/sage
    def _eval_(self, z, **kwds):
        """
        EXAMPLES::

            sage: harmonic_number(0)
            0
            sage: harmonic_number(1)
            1
            sage: harmonic_number(20)
            55835135/15519504
            sage: harmonic_number(5/2)
            -2*log(2) + 46/15
            sage: harmonic_number(2*x)
            harmonic_number(2*x)
        """
        if z in ZZ:
            if z == 0:
                return Integer(0)
            elif z == 1:
                return Integer(1)
            elif z > 1:
                import sage.libs.flint.arith as flint_arith
                return flint_arith.harmonic_number(z)
        elif z in QQ:
            from sage.functions.other import psi1
            return psi1(z + 1) - psi1(1)
    def dvalue(self):
        r"""
        Return a symbolic expression (or an exact value in case n=3, 4, 6)
        for the transfinite diameter (or capacity) of ``self``.

        EXAMPLES:

            sage: HeckeTriangleGroup(3).dvalue()
            1/1728
            sage: HeckeTriangleGroup(4).dvalue()
            1/256
            sage: HeckeTriangleGroup(5).dvalue()
            e^(2*euler_gamma - 4*pi/(sqrt(5) + 1) + psi(17/20) + psi(13/20))
            sage: HeckeTriangleGroup(6).dvalue()
            1/108
            sage: HeckeTriangleGroup(10).dvalue()
            e^(2*euler_gamma - pi*sec(1/10*pi) + psi(4/5) + psi(7/10))
            sage: HeckeTriangleGroup(infinity).dvalue()
            1/64
        """

        n=self._n
        if (n==3):
            return ZZ(1)/ZZ(2**6*3**3)
        elif (n==4):
            return ZZ(1)/ZZ(2**8)
        elif (n==6):
            return ZZ(1)/ZZ(2**2*3**3)
        elif (n==infinity):
            return ZZ(1)/ZZ(2**6)
        else:
            return exp(-ZZ(2)*psi1(ZZ(1)) + psi1(ZZ(1)-self.alpha())+psi1(ZZ(1)-self.beta()) - pi*sec(pi/self._n))
    def dvalue(self):
        r"""
        Return a symbolic expression (or an exact value in case n=3, 4, 6)
        for the transfinite diameter (or capacity) of ``self``.
        I.e. the first nontrivial Fourier coefficient of the Hauptmodul
        for the Hecke triangle group in case it is normalized to ``J_inv(i)=1``.

        EXAMPLES::

            sage: from sage.modular.modform_hecketriangle.hecke_triangle_groups import HeckeTriangleGroup
            sage: HeckeTriangleGroup(3).dvalue()
            1/1728
            sage: HeckeTriangleGroup(4).dvalue()
            1/256
            sage: HeckeTriangleGroup(5).dvalue()
            e^(2*euler_gamma - 4*pi/(sqrt(5) + 1) + psi(17/20) + psi(13/20))
            sage: HeckeTriangleGroup(6).dvalue()
            1/108
            sage: HeckeTriangleGroup(10).dvalue()
            e^(2*euler_gamma - 2*pi/sqrt(1/2*sqrt(5) + 5/2) + psi(4/5) + psi(7/10))
            sage: HeckeTriangleGroup(infinity).dvalue()
            1/64
        """

        n = self._n
        if (n==3):
            return ZZ(1)/ZZ(2**6*3**3)
        elif (n==4):
            return ZZ(1)/ZZ(2**8)
        elif (n==6):
            return ZZ(1)/ZZ(2**2*3**3)
        elif (n==infinity):
            return ZZ(1)/ZZ(2**6)
        else:
            return exp(-ZZ(2)*psi1(ZZ(1)) + psi1(ZZ(1)-self.alpha())+psi1(ZZ(1)-self.beta()) - pi*sec(pi/self._n))
    def dvalue(self):
        r"""
        Return a symbolic expression (or an exact value in case n=3, 4, 6)
        for the transfinite diameter (or capacity) of ``self``.
        I.e. the first nontrivial Fourier coefficient of the Hauptmodul
        for the Hecke triangle group in case it is normalized to ``J_inv(i)=1``.

        EXAMPLES:

            sage: from sage.modular.modform_hecketriangle.hecke_triangle_groups import HeckeTriangleGroup
            sage: HeckeTriangleGroup(3).dvalue()
            1/1728
            sage: HeckeTriangleGroup(4).dvalue()
            1/256
            sage: HeckeTriangleGroup(5).dvalue()
            e^(2*euler_gamma - 4*pi/(sqrt(5) + 1) + psi(17/20) + psi(13/20))
            sage: HeckeTriangleGroup(6).dvalue()
            1/108
            sage: HeckeTriangleGroup(10).dvalue()
            e^(2*euler_gamma - pi*sec(1/10*pi) + psi(4/5) + psi(7/10))
            sage: HeckeTriangleGroup(infinity).dvalue()
            1/64
        """

        n = self._n
        if (n==3):
            return ZZ(1)/ZZ(2**6*3**3)
        elif (n==4):
            return ZZ(1)/ZZ(2**8)
        elif (n==6):
            return ZZ(1)/ZZ(2**2*3**3)
        elif (n==infinity):
            return ZZ(1)/ZZ(2**6)
        else:
            return exp(-ZZ(2)*psi1(ZZ(1)) + psi1(ZZ(1)-self.alpha())+psi1(ZZ(1)-self.beta()) - pi*sec(pi/self._n))
    def get_R(p, energy):
        k = sqrt(energy)
        # left = 0
        # while left < p.n and energy < p.eigenvalues[left]:
        # 	left += 1
        # left = max(0, left - count / 2)
        # right = min(p.n, left + count)

        n0 = None

        s = _sage_const_0p0
        # print(energies)
        for i, (es, ee) in enumerate(zip(p.eigenstates, p.eigenvalues)):
            if (pi / _sage_const_2 + pi * i) / p.r_A > k:
                n0 = i
            if n0 is not None:
                X = p.r_A * k / pi
                rest = float(_sage_const_1 / pi**_sage_const_2 *
                             _sage_const_1 / X *
                             (psi1(n0 + _sage_const_0p5 + X) -
                              psi1(n0 + _sage_const_0p5 - X)))
                if rest / (abs(s) + rest) < tolerance:
                    print("Stopping at {}, rest {}".format(n0, rest))
                    break
            s += es(p.r_A)**_sage_const_2 / (ee - energy) / p.r_A
            # print("Using eigenvalue: {}".format(ee))
            # print("i = {}, R = {}".format(i, s))
        return s
def compute_R_upper_bound(p, energy):
    k = sqrt(energy)
    s = _sage_const_0p0
    rest0 = _sage_const_0p0
    n0 = None
    for i, (es, ee) in enumerate(zip(p.eigenstates, p.eigenvalues)):
        val = float(es(p.r_A)**_sage_const_2 / (ee - energy) / p.r_A)
        if (pi / _sage_const_2 + pi * i) / p.r_A < k:
            s += val
        else:
            if n0 is None:
                n0 = i
            rest0 += val

    X = p.r_A * k / pi
    rest = float(
        _sage_const_1 / pi**_sage_const_2 * _sage_const_1 / X *
        (psi1(n0 + _sage_const_0p5 + X) - psi1(n0 + _sage_const_0p5 - X)))
    print("partial sum = {}".format(s))
    print("rest0 = {}".format(rest0))
    print("rest = {}".format(rest))