Skip to main content

Crate ct_sternbrocot

Crate ct_sternbrocot 

Source
Expand description

§ct-sternbrocot — Stern-Brocot Constrained Pythagorean Snap

Uses Stern-Brocot descent to find the optimal Pythagorean triple for a given angle. Falls back to Euclid enumeration when SB misses.

Key insight: the Stern-Brocot tree finds best rational approximations, but mediants of Pythagorean triples aren’t always Pythagorean. This crate combines SB guidance with Euclid verification for correctness.

Structs§

SnapTriple
Result of a snap operation.

Functions§

generate_triples
Generate Pythagorean triples via Euclid’s formula.
is_pythagorean
Check if (a, b, c) is a valid Pythagorean triple.
sternbrocot_bound
Stern-Brocot optimal bound: the best possible rational approximation of tan(theta) with denominator constraint.
sternbrocot_snap
Stern-Brocot guided snap: use SB to narrow the search, then verify.