"""Independent check of the submitted coordinates, lengths and all five choices."""
from fractions import Fraction as F
from math import isclose, log2, sqrt

center_x = F(7, 16)
# Equal horizontal edges have endpoints (u²,u) and (v²,v).
# Distinct heights imply u != v. Equal widths give u+v=1.
product = 1 - 2 * center_x
assert product == F(1, 8)
distance = -log2(product)/2
choices = (1, F(3, 2), 2, F(5, 2), 3)
assert [i for i, choice in enumerate(choices, start=1) if isclose(distance, choice)] == [2]

# Build the actual four vertices independently from the two roots.
u, v = ((1 + sign*sqrt(1-4*product))/2 for sign in (-1, 1))
a = (u, log2(u))
b = (v, log2(v))
c = (v**2, log2(v))
d = (u**2, log2(u))
assert all(x > 0 and y < 0 for x, y in (a,b,c,d))
assert all(isclose(log2(x), y) for x, y in (a,b))
assert all(isclose(log2(x)/2, y) for x, y in (c,d))
assert isclose(a[0]-d[0], b[0]-c[0]) and a[1] == d[1] and b[1] == c[1]
for x, y in [(a,c),(b,d)]:
    assert isclose((x[0]+y[0])/2, center_x)
    assert isclose((x[1]+y[1])/2, -distance)
print("u*v =", product, "center =", (center_x, -F(3,2)), "choice 2 only")
