def H_eff_n(self, n):
		# k<=m => j<=(n)/2
		r = 0
		for j in xrange(1, int(math.ceil( n/2. )) + 1 ):
			b = 2*(2**(2*j)-1)*mpmath.bernoulli(2*j)/mpmath.factorial(2*j)
			r += b*self.P_0.dot(self.S_k(2*j-1,n-1)).dot(self.P_0)
		return r
Пример #2
0
def stirling_series(N):
    with mpmath.workdps(100):
        coeffs = [
            mpmath.bernoulli(2 * n) / (2 * n * (2 * n - 1))
            for n in range(1, N + 1)
        ]
    return coeffs
Пример #3
0
 def H_eff_n(self, n):
     # k<=m => j<=(n)/2
     r = 0
     for j in xrange(1, int(math.ceil(n / 2.)) + 1):
         b = 2 * (2**(2 * j) - 1) * mpmath.bernoulli(
             2 * j) / mpmath.factorial(2 * j)
         r += b * self.P_0.dot(self.S_k(2 * j - 1, n - 1)).dot(self.P_0)
     return r
Пример #4
0
def zeta_even_integers(N):
    values = []
    for n in range(0, N + 1):
        zeta_2n = (
            (-1)**(n + 1)
            * mpmath.bernoulli(2 * n)
            * (2 * mpmath.pi)**(2 * n)
            / (2 * mpmath.factorial(2 * n))
        )
        values.append(zeta_2n)
    return values
Пример #5
0
def bernoulli_num(n):
    """
    Returns n'th bernoulli number

    Parameters
    ----------
    n : int
        positive integer value
    return : float
        returns bernoulli number

    """
    return mp.bernoulli(n)
	def _S(self, n):
		if n < 1:
			raise ValueError("i must be greater than or equal to zero.")
		elif n == 1:
			return self.L(self.V_od)
		elif n == 2:
			return -self.L(self.hat(self.V_d, self.S(1)))
		else:
			r = -self.L(self.hat(self.V_d, self.S(n-1)))
			# k<=m => j<=(n-1)/2
			for j in xrange(1, int(math.ceil( (n-1)/2 )) + 1 ):
				a = 2**(2*j) * mpmath.bernoulli(2*j) / mpmath.factorial(2*j)
				r += a * self.L(self.S_k(2*j, n-1))
			return r
Пример #7
0
 def _S(self, n):
     if n < 1:
         raise ValueError("i must be greater than or equal to zero.")
     elif n == 1:
         return self.L(self.V_od)
     elif n == 2:
         return -self.L(self.hat(self.V_d, self.S(1)))
     else:
         r = -self.L(self.hat(self.V_d, self.S(n - 1)))
         # k<=m => j<=(n-1)/2
         for j in xrange(1, int(math.ceil((n - 1) / 2)) + 1):
             a = 2**(2 * j) * mpmath.bernoulli(2 * j) / mpmath.factorial(
                 2 * j)
             r += a * self.L(self.S_k(2 * j, n - 1))
         return r
Пример #8
0
def stirling_series(N):
    coeffs = []
    with mpmath.workdps(100):
        for n in range(1, N + 1):
            coeffs.append(mpmath.bernoulli(2 * n) / (2 * n * (2 * n - 1)))
    return coeffs
Пример #9
0
def stirling_series(N):
    with mpmath.workdps(100):
        coeffs = [mpmath.bernoulli(2*n)/(2*n*(2*n - 1))
                  for n in range(1, N + 1)]
    return coeffs
Пример #10
0
 def test_bernoulli(self):
     assert_mpmath_equal(lambda n: sc.bernoulli(int(n))[int(n)],
                         lambda n: float(mpmath.bernoulli(int(n))),
                         [IntArg(0, 13000)],
                         rtol=1e-9, n=13000)
Пример #11
0
 def test_bernoulli(self):
     assert_mpmath_equal(lambda n: sc.bernoulli(int(n))[int(n)],
                         lambda n: float(mpmath.bernoulli(int(n))),
                         [IntArg(0, 13000)],
                         rtol=1e-9,
                         n=13000)
Пример #12
0
def getNthBernoulli( n ):
    return bernoulli( n )
Пример #13
0
def stirling_series(N):
    coeffs = []
    with mpmath.workdps(100):
        for n in range(1, N + 1):
            coeffs.append(mpmath.bernoulli(2 * n) / (2 * n * (2 * n - 1)))
    return coeffs
Пример #14
0
def getNthBernoulliNumberOperator(n):
    return bernoulli(n)