Theorems, checked on exact figures
Each function here takes a figure, builds what a theorem talks about, and tests the conclusion with exact arithmetic. holds: true means the statement is true of this figure, with no tolerance involved.
const t = triangle([0, 0], [4, 0], [1, 3]);
theorems.eulerLine(t); // { theorem, statement, holds: true, O, G, H, … }
theorems.feuerbach(t); // tangent to the incircle and the three excircles
theorems.ceva(t, D, E, F); // concurrent exactly when the product of ratios is 1
theorems.ptolemy(A, B, C, D); // equality exactly when the four points are concyclic
What a check is, and is not
A check on one triangle is not a proof for all triangles. It is still worth more than a drawing or a floating-point test, for two reasons. First, the conclusion is an exact equality, so a false statement fails rather than passing within a tolerance. Second, a statement that is an identity between polynomials or algebraic functions of the coordinates and holds at a "generic" exact point is very unlikely to be false. For a proof that covers every figure, see General proofs, where the coordinates are letters, hypotheses and conclusion become polynomials, and the proof is a certificate.
Several of the functions test both directions. ceva reports the product of the ratios and whether the lines are concurrent, and holds says these agree, so it is as informative on a figure where the lines miss as on one where they meet. ptolemy, simson and thales work the same way.
| theorems.… | statement checked |
|---|---|
| pythagoras(t) | a² + b² = c² exactly when the triangle is right-angled |
| heron(t) | area² = s(s − a)(s − b)(s − c) |
| concurrency(t) | medians, altitudes and bisectors each meet in a point; G divides the medians 2 : 1 |
| eulerLine(t) | O, G, H are collinear with GH = 2·OG |
| ninePointCircle(t) | nine points on one circle of half the circumradius |
| feuerbach(t) | the nine-point circle touches the incircle and each excircle |
| napoleon(t) | centres of the outer equilateral triangles form an equilateral triangle |
| ceva(t, D, E, F), menelaus(t, D, E, F) | product of signed ratios is 1 (concurrent) or −1 (collinear) |
| simson(t, P) | the feet from P are collinear exactly when P is on the circumcircle |
| ptolemy(A, B, C, D) | AC·BD = AB·CD + BC·DA exactly for cyclic quadrilaterals, ≤ otherwise |
| thales(circle, A, B, P) | angle APB is right exactly when AB is a diameter |
| powerOfPoint(circle, P, l1, l2) | PA·PB is the same on every secant and equals |PO|² − r² |
| varignon(A, B, C, D) | midpoints of a quadrilateral form a parallelogram of half the area |
| pentagon() | diagonal : side of the regular pentagon is the golden ratio |
Why Feuerbach's theorem is the hard one
Two circles touch when the distance between their centres equals the sum or the difference of their radii. The nine-point circle of a rational triangle is rational, but the incentre and inradius involve the three side lengths, each a square root, so the distance is a square root of an expression in three square roots, and the test is whether that equals a difference of two more such numbers. In floating point one sees agreement to fifteen digits. Here the two sides are algebraic numbers and the equality is decided from their minimal polynomials.
@ratmath/geo and Core's Rational in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.