-
Notifications
You must be signed in to change notification settings - Fork 1
/
logo.py
47 lines (34 loc) · 1.1 KB
/
logo.py
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
#!/usr/bin/env python
from transmutagen import get_CRAM_from_cache, t, plot_in_terminal
from transmutagen.analysis import setup_matplotlib_rc
from sympy import Poly, fraction, exp
import matplotlib.pyplot as plt
degree = 14
prec = 200
points = 10000
def main():
setup_matplotlib_rc()
expr = get_CRAM_from_cache(degree, prec)
c = 0.6*degree
# Get the translated approximation on [-1, 1]. This is similar logic from CRAM_exp().
n, d = map(Poly, fraction(expr))
inv = -c*(t + 1)/(t - 1)
p, q = map(lambda i: Poly(i, t), fraction(inv))
n, d = n.transform(p, q), d.transform(p, q)
rat_func = n/d.TC()/(d/d.TC())
rat_func = rat_func.evalf(prec)
plt.clf()
fig, ax = plt.subplots()
fig.set_size_inches(4, 4)
plot_in_terminal(expr - exp(-t), (0, 100), prec=prec, points=points,
axes=ax)
# Hide grid lines
ax.grid(False)
# Hide axes ticks
ax.set_xticks([])
ax.set_yticks([])
plt.axis('off')
plt.tight_layout()
plt.savefig('logo.png', transparent=True, bbox_inches='tight', pad_inches=0)
if __name__ == '__main__':
main()