Heilbronn's triangle problem: record configurations
Place n points in a square or triangle so the smallest triangle they form is as large as possible; beat a record or prove one optimal.
| 1 | """The record for n = 10 points in the unit square, the smallest open case, with its tied smallest triangles. |
| 2 | |
| 3 | Coordinates: Comellas and Yebra's configuration as listed by Tej Stead's record tables, |
| 4 | https://math.tejstead.com/heilbronn/square/10/points.txt (exact closed form from arXiv:2603.11107, truncated to 30 digits). |
| 5 | Every triangle area is recomputed here in exact rational arithmetic; a triangle ties with the smallest when it is within |
| 6 | a relative 1e-9 of it, the tables' tie window (truncating the coordinates moves the tied areas apart by less than that). |
| 7 | """ |
| 8 | from fractions import Fraction as F |
| 9 | from itertools import combinations |
| 10 | from pathlib import Path |
| 11 | |
| 12 | import kit |
| 13 | |
| 14 | POINTS = [ |
| 15 | ('0.157805568804305564655835692968', '0'), |
| 16 | ('0.747612632460630047142556610421', '0'), |
| 17 | ('0', '0.157805568804305564655835692968'), |
| 18 | ('1', '0.252387367539369952857443389578'), |
| 19 | ('0.684388862391388870688328614063', '0.315611137608611129311671385936'), |
| 20 | ('0.315611137608611129311671385936', '0.684388862391388870688328614063'), |
| 21 | ('0', '0.747612632460630047142556610421'), |
| 22 | ('1', '0.842194431195694435344164307031'), |
| 23 | ('0.252387367539369952857443389578', '1'), |
| 24 | ('0.842194431195694435344164307031', '1'), |
| 25 | ] |
| 26 | P = [(F(x), F(y)) for x, y in POINTS] |
| 27 | |
| 28 | |
| 29 | def area(a, b, c): |
| 30 | return abs((b[0] - a[0]) * (c[1] - a[1]) - (c[0] - a[0]) * (b[1] - a[1])) / 2 |
| 31 | |
| 32 | |
| 33 | areas = {t: area(*(P[i] for i in t)) for t in combinations(range(len(P)), 3)} |
| 34 | smallest = min(areas.values()) |
| 35 | tied = [t for t, a in areas.items() if a <= smallest * (1 + F(1, 10 ** 9))] |
| 36 | assert len(P) == 10 and all(0 <= c <= 1 for p in P for c in p) |
| 37 | assert f'{float(smallest):.10f}' == '0.0465374196', smallest # the README's record value |
| 38 | assert len(tied) == 16, len(tied) |
| 39 | |
| 40 | S, X0, Y0 = 236, (kit.W - 236) / 2, 14 |
| 41 | at = lambda p: (X0 + float(p[0]) * S, Y0 + (1 - float(p[1])) * S) |
| 42 | |
| 43 | body = kit.polygon([(X0, Y0), (X0 + S, Y0), (X0 + S, Y0 + S), (X0, Y0 + S)], 'faint-s', ' stroke-width="2"') |
| 44 | body += ''.join(kit.polygon([at(P[i]) for i in t], 'f-soft') for t in tied) |
| 45 | body += ''.join(kit.polygon([at(P[i]) for i in t], 'f-s', ' stroke-width="2" stroke-opacity=".75"') for t in tied) |
| 46 | body += ''.join(kit.dot(*at(p), r=6.5) for p in P) |
| 47 | kit.write(__file__, 'mathematics', body, label=f'n = 10 · {len(tied)} smallest triangles tie at 0.0465') |
