"""One case of the conjecture, found here: 4/7 written as 1/x + 1/y + 1/z with x < y < z. Drawn as fraction bars on one whole (the faint frame): four sevenths above, the three unit fractions below, the same length exactly. Of all the solutions for n = 7, this is the one whose smallest piece is largest, so every piece can be seen.""" from fractions import Fraction as F from pathlib import Path import kit n = 7 def solutions(n): """Every x < y < z with 4/n = 1/x + 1/y + 1/z: x is at most 3n/4, and then y at most 2/(4/n - 1/x).""" for x in range(n // 4 + 1, 3 * n // 4 + 1): r = F(4, n) - F(1, x) for y in range(max(x + 1, int(1 / r) + 1), int(2 / r) + 1): s = r - F(1, y) if s > 0 and s.numerator == 1 and s.denominator > y: yield x, y, s.denominator x, y, z = min(solutions(n), key=lambda t: t[2]) assert F(1, x) + F(1, y) + F(1, z) == F(4, n) and (x, y, z) == (3, 6, 14) x0, x1, h = 24, 616, 64 # the whole runs from x0 to x1 X = lambda q: x0 + (x1 - x0) * float(q) box = lambda a, b, top, cls, extra='': kit.polygon([(X(a), top), (X(b), top), (X(b), top + h), (X(a), top + h)], cls, extra) body = ''.join(box(0, 1, top, 'faint-s', ' stroke-width="2" stroke-dasharray="3 7"') for top in (40, 150)) # the whole, twice body += ''.join(box(F(k, n), F(k + 1, n), 40, 'ink-s', ' stroke-width="3"') for k in range(4)) # four sevenths edges = [F(0), F(1, x), F(1, x) + F(1, y), F(4, n)] for a, b in zip(edges, edges[1:]): # the three unit fractions body += box(a, b, 150, 'f-soft') + box(a, b, 150, 'f-s', ' stroke-width="3"') kit.write(__file__, 'mathematics', body, label=f'4/{n} = 1/{x} + 1/{y} + 1/{z}, three unit fractions')