• API
• FAQ
• Tools
• Archive
daily pastebin goal
80%
SHARE
TWEET

# Untitled

a guest Mar 21st, 2019 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. from mpmath import nsum, inf, nprod
2. import math
3. def fgh(iter, num):
4.     if iter == 0:
5.         return num + 1
6.     elif iter == 1:
7.         return num * 2
8.     elif iter == 2:
9.         return 2 ** num
10.     else:
11.         result = fgh(iter - 1, num)
12.         for i in range(num - 1):
13.             result = fgh(iter - 1, result)
14.         return result
15.
16. def sgh(iter, num):
17.     if iter == 0:
18.         return 0
19.     else:
20.         return sgh(iter - 1, num) + 1
21.
22. def mgh(iter, num):
23.     if iter == 0:
24.         return num + 1
25.     else:
26.         return mgh(iter - 1, mgh(iter - 1, num))
27.
28. def hh(iter, num):
29.     if iter == 0:
30.         return num
31.     else:
32.         return hh(iter - 1, num + 1)
33.
34. def fact(num):
35.     if num == 1:
36.         return 1
37.     else:
38.         return num * fact(num - 1)
39.
40. def pochhammer_symbol(num, iter):
41.     if num == 1 or iter == 0:
42.         return num
43.     else:
44.         result = num
45.         for it in range(1, iter):
46.             result *= it + num
47.         return result
48.
49. def qfact(k, q):
50.     result = 1
51.     chapter = 1
52.     for iter in range(1, k):
53.         chapter += q ** iter
54.         result *= chapter
55.     return result
56.
57. def qseries(a, q, n):
58.     result = 1 - a
59.     for _ in range(1, n):
60.         result *= 1 - a * (q ** _)
61.     return result
62.
63. def qps(a, q, k=inf):
64.     if k > 0:
65.         return nprod(lambda j: 1 - a * (q ** j), [0, k - 1])
66.     elif k == 0:
67.         return 1
68.     elif k < 0:
69.         return nprod(lambda j: (1 - a * (q ** -j)) ** -1, [0, math.abs(k - 1)])
70. def qbc(n, k):
71.     if 0 <= k and k < n:
72.         return fact(n) / (fact(k) * fact(n - k))
73.     else:
74.         return 0
75.
76. def qhypgeom(asl, bsl, q, z):
77.     return nsum(lambda x: (nprod(lambda a: qps(asl[int(a)], q, x), [0, len(asl) - 1]) / nprod(lambda b: qps(bsl[int(b)], q, x), [0, len(bsl) - 1]) * ((z ** x) / qps(q, q, x)) * ((-1 ** x) * (q ** (x * (x - 1)/2))) ** (1 + len(bsl) - len(asl))), [0, inf])
78.
79. def qe(q, x):
80.     return nsum(lambda x: (z ** x) / qps(q, q, x), [0, inf])
81. def qE(q, x):
82.     return qps(-x, q, inf)
83. def gamma(z):
84.     #Euler's limit
85.     return (1.0 / z) * nprod(lambda x: ((1 + (1.0 / x)) ** z) * ((1 + (z / x)) ** -1), [1, inf])
86. def qgamma(q, z):
87.     return (qps(q, q, inf) / qps(q ** z, q, inf)) * ((1 - q) ** (1 - x))
88. def beta(q, a, b):
89.     return (qgamma(q, a) * qgamma(q, b)) / qgamma(a + b)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top