-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmodular_forms.py
More file actions
67 lines (49 loc) · 1.55 KB
/
modular_forms.py
File metadata and controls
67 lines (49 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from polynomial import BasicPolynomial
from bernoulli_numbers import BernoulliNumber
from divisor import divisors
def E(k, N):
"""
E_k = 1 - 2*k / B_k * sum_{n=1}^{N} sigma_{k-1}(n) q^n
Args:
k: weight
N: Get up to the q^N power approximation
Returns:
"""
dc = {0: 1}
coeff = int(-2*k / BernoulliNumber().get(k))
for i in range(1, N+1):
dc[i] = coeff*int(divisors(k-1, i))
return BasicPolynomial(dc, 'q')
def discriminant_modular_form(N):
"""
/Delta = 1/1728 * (E_4^3 - E_6^2)
Args:
N: highest power to approximate E_4 and E_6
Returns: BasicPolynomial class
"""
return 1/1728 * (E(4, N)**3 - E(6, N)**2)
def j_invariant(N):
"""
j = E_4^3 / Delta
Args:
N: highest power to approximate E_4 and E_6
Returns: BasicPolynomial class
"""
return E(4, N) ** 3 / discriminant_modular_form(N)
def print_ramanujan_tau_function(delta, N):
for i in range(1, N+1):
print('T({}) = {}'.format(i, delta.dc_powers.get(i, 0)))
def main():
approx = 10
# print('E_4 = {}'.format(E(4, approx)))
print('E_4^3 = {}'.format(E(4, approx)**3))
print('1 / E_4^3 = {}'.format((E(4, approx)**3).invert(approx)))
print('E_6 = {}'.format(E(6, approx)))
print('E_6^2 = {}'.format(E(6, approx)**2))
delta = discriminant_modular_form(approx)
print('Delta = {}'.format(delta))
# print_ramanujan_tau_function(delta, approx)
# j_func = j_invariant(approx)
# print('j = {}'.format(j_func))
if __name__ == '__main__':
main()