The Beauty of Roots(math.ucr.edu) |
The Beauty of Roots(math.ucr.edu) |
from itertools import chain
import numpy as np
import matplotlib
matplotlib.use('TkAgg')
from matplotlib import pyplot as plt
def gen_pm_one(m):
def array_for(n):
return map(
lambda i: 1 if not (1 << i) & n == 0 else -1,
range(m)
)
def out():
generated = 0
final = 2 ** m
while generated < final:
yield array_for(generated)
generated += 1
return out()
if __name__ == '__main__':
roots = map(
lambda roots: map(
lambda cpx: [cpx.real, cpx.imag],
roots
),
map(
np.roots,
gen_pm_one(13)
)
)
data = np.array(list(chain(*roots)))
x, y = data.T
plt.scatter(x,y)
plt.show()