コード例 #1
0
 def find_root(self, *, guess=None):
     if self.num_roots():
         if guess is None:
             return ln(-self.c / self.a) / ln(self.b)
         return super(Exponent, self).find_root(guess=guess)
     else:
         return None
コード例 #2
0
def prime(n):
    # f = 2
    # n2 = 0

    try:
        return _p.prime(n)
    except (ValueError, TypeError, AttributeError):
        pass

    if n <= 0:
        raise ValueError("n must be greater than 0")
    elif n < len(known_primes):
        return known_primes[n - 1]

    # while n2 != n:
    #     test = primeQ(f)
    #     if test:
    #         n2 += 1
    #     if n2 == n:
    #         break
    #     f += 1
    # return f
    # a = 2
    # b = int(n * (log(n, e) + log(log(n, e), e)))
    #
    # while a < b:
    #     mid = (a + b) >> 1
    #     if li(mid) > n:
    #         b = mid
    #     else:
    #         a = mid + 1
    # n_primes = primepi(a - 1)
    # while n_primes < n:
    #     if primeQ(a):
    #         n_primes += 1
    #     a += 1
    # return a - 1

    lower = int(n * ln(n) + n * (ln(ln(n)) - 1))
    if lower % 2 == 0:
        lower += 1
    upper = int(n * ln(n) + n * ln(ln(n)))
    print(lower, upper)
    for i in range(lower, upper, 2):
        if not primeQ(i):
            continue
        if primepi(i) == n:
            return i
コード例 #3
0
 def get_root_bounds(self):
     return ln(-self.c / self.a) / ln(self.b), ln(-self.c / self.a) / ln(self.b)
コード例 #4
0
 def integrate(self, a=None, b=None):
     integ = Exponent(self.a / ln(self.b), self.b) + Polynomial([self.c, 0])
     if a is not None:
         return integ(b) - integ(a)
     return integ
コード例 #5
0
 def derivative(self, value=None):
     der = Exponent(self.a * ln(self.b), self.b)
     if value is not None:
         return der(value)
     return der