コード例 #1
0
def makeCoeff(a,b,c,k):

    if (a,b,c) == (0,0,0):
        return 1

    #calculate the discriminant
    disc = 4 * a * c - b * b
    
    #calculate the zeta functions
    z1 = zeta(1 - k)
    z2 = zeta(3 - (2 * k))

    #make a list of nonzero coefficients of our BQF
    list = []
    for i in [a, b, c]:
        if i != 0:
            list.append(i)
            
    sm = 0
    
    #iterate through divisors of our BQF (this forms the core sum)
    for d in range(1, abs(min(list)) + 1):
        if a % d == 0 and b % d == 0 and c % d == 0:
            #add term as given in McCarthy for each divisor d
            POW = (d ** (k-1))
            HFUN = H(k-1, disc / (d ** 2))
            sm += POW * HFUN
    #finish off the calculation by multiplying by 2/(Z(1 - k) * Z(3 - 32))        
    value = 2 * sm / (z1 * z2) 
    return value
コード例 #2
0
ファイル: log.py プロジェクト: yarv/sage
    def _derivative_(self, n, m, diff_param=None):
        """
        The derivative of `H_{n,m}`.

        EXAMPLES::

            sage: k,m,n = var('k,m,n')
            sage: sum(1/k, k, 1, x).diff(x)
            1/6*pi^2 - harmonic_number(x, 2)
            sage: harmonic_number(x, 1).diff(x)
            1/6*pi^2 - harmonic_number(x, 2)
            sage: harmonic_number(n, m).diff(n)
            -m*(harmonic_number(n, m + 1) - zeta(m + 1))
            sage: harmonic_number(n, m).diff(m)
            Traceback (most recent call last):
            ...
            ValueError: cannot differentiate harmonic_number in the second parameter
        """
        from sage.functions.transcendental import zeta
        if diff_param == 1:
            raise ValueError(
                "cannot differentiate harmonic_number in the second parameter")
        if m == 1:
            return harmonic_m1(n).diff()
        else:
            return m * (zeta(m + 1) - harmonic_number(n, m + 1))
コード例 #3
0
ファイル: log.py プロジェクト: mcognetta/sage
    def _derivative_(self, n, m, diff_param=None):
        """
        The derivative of `H_{n,m}`.

        EXAMPLES::

            sage: k,m,n = var('k,m,n')
            sage: sum(1/k, k, 1, x).diff(x)
            1/6*pi^2 - harmonic_number(x, 2)
            sage: harmonic_number(x, 1).diff(x)
            1/6*pi^2 - harmonic_number(x, 2)
            sage: harmonic_number(n, m).diff(n)
            -m*(harmonic_number(n, m + 1) - zeta(m + 1))
            sage: harmonic_number(n, m).diff(m)
            Traceback (most recent call last):
            ...
            ValueError: cannot differentiate harmonic_number in the second parameter
        """
        from sage.functions.transcendental import zeta
        if diff_param == 1:
            raise ValueError("cannot differentiate harmonic_number in the second parameter")
        if m==1:
            return harmonic_m1(n).diff()
        else:
            return m*(zeta(m+1) - harmonic_number(n, m+1))
コード例 #4
0
def H(k1,N):
    #here we assign variables in a way that meshes with notation in McCarthy and Raum
    k = k1 + 1
    N = -N
    s = 2 - k
    #when N = 0 we calculate the value with the zeta func
    if N == 0:
        x = zeta((2 * s) - 1)
        return x
    #we check if N is 0 or 1 mod 4
    if N % 4 == 0 or N % 4 == 1:
        #find our kronecker character
        D0 = fundDisc(N)
        #find f
        f = isqrt(int(N / D0))
        #initialize our value
        hSum = 0
        #iterate through the divisors of f
        for d in range(1, f + 1):
            if f % d == 0:
                #when d divides f we add the appropriate term to the sum
                MOB = mobius(d)
                KRON = kronecker(D0, d)
                POW = d ** -s
                SIG = sigmaDivisor(1 - (2 * s), int(f / d))
                #print('    adding ' + str(MOB) + ' * ' + str(KRON) + ' * ' + str(POW) + ' * ' + str(SIG) + ' to H func sum.')
                hSum += MOB * KRON * POW * SIG
        LF = lfun(s, D0)
        fCalc = hSum * LF
        return fCalc
    #otherwise the value is 0
    else:
        return 0
コード例 #5
0
ファイル: log.py プロジェクト: yarv/sage
    def _derivative_(self, z, diff_param=None):
        """
        The derivative of `H_x`.

        EXAMPLES::

            sage: k=var('k')
            sage: sum(1/k,k,1,x).diff(x)
            1/6*pi^2 - harmonic_number(x, 2)
        """
        from sage.functions.transcendental import zeta
        return zeta(2) - harmonic_number(z, 2)
コード例 #6
0
ファイル: log.py プロジェクト: mcognetta/sage
    def _derivative_(self, z, diff_param=None):
        """
        The derivative of `H_x`.

        EXAMPLES::

            sage: k=var('k')
            sage: sum(1/k,k,1,x).diff(x)
            1/6*pi^2 - harmonic_number(x, 2)
        """
        from sage.functions.transcendental import zeta
        return zeta(2)-harmonic_number(z,2)
コード例 #7
0
ファイル: weilrep_misc.py プロジェクト: btw-47/weilrep
 def _eval_(self, x, D):  #symbolic value
     D = Integer(D)
     if D % 4 > 1:
         raise ValueError('Not a discriminant')
     f = D.squarefree_part()
     if f % 4 > 1 and not D % 4:
         f *= 4
     m = D // f
     if f != D:
         L = QuadraticLFunction()
         return prod(1 - p**(-x) * kronecker(f, p)
                     for p in prime_divisors(m)) * L(x, f)
     if D == 1:
         return prod(1 - p**(-x) * kronecker(f, p)
                     for p in prime_divisors(m)) * zeta(x)
     try:
         return quadratic_L_function__exact(x, D)
     except TypeError:
         pass
コード例 #8
0
ファイル: log.py プロジェクト: yarv/sage
    def _evalf_(self, z, m, parent=None, algorithm=None):
        """
        EXAMPLES::

            sage: harmonic_number(3.,3)
            zeta(3) - 0.0400198661225573
            sage: harmonic_number(3.,3.)
            1.16203703703704
            sage: harmonic_number(3,3).n(200)
            1.16203703703703703703703...
            sage: harmonic_number(5,I).n()
            2.36889632899995 - 3.51181956521611*I
        """
        if m == 0:
            if parent is None:
                return z
            return parent(z)
        elif m == 1:
            return harmonic_m1._evalf_(z, parent, algorithm)

        from sage.functions.transcendental import zeta, hurwitz_zeta
        return zeta(m) - hurwitz_zeta(m, z + 1)
コード例 #9
0
ファイル: log.py プロジェクト: mcognetta/sage
    def _evalf_(self, z, m, parent=None, algorithm=None):
        """
        EXAMPLES::

            sage: harmonic_number(3.,3)
            zeta(3) - 0.0400198661225573
            sage: harmonic_number(3.,3.)
            1.16203703703704
            sage: harmonic_number(3,3).n(200)
            1.16203703703703703703703...
            sage: harmonic_number(5,I).n()
            2.36889632899995 - 3.51181956521611*I
        """
        if m == 0:
            if parent is None:
                return z
            return parent(z)
        elif m == 1:
            return harmonic_m1._evalf_(z, parent, algorithm)

        from sage.functions.transcendental import zeta, hurwitz_zeta
        return zeta(m) - hurwitz_zeta(m,z+1)