This is wonderful! I’d somehow missed the classical enumeration of Pythagorean triples. I learned them as magic numbers. That structure alone is worth the price of admission.
But all such triples are non-primitive. I.e. they are of the form (ka, kb, kc) with k>1.
So all Pythagorean triples can be generated as a scaled primitive triple (a,b,c) that is generated by Euclid's formula from m,n.
Yes, this is normal. I am sorry, I am working on a more efficient implementation.
The JavaScript of this page does a lot of number crunching.
It is actually doing arithmetic on the Stern-Brocot tree. It is all written in ClojureScript and not really optimized yet. I mention in the paper that I do not even use TCO.
Anyway, thank you - and all the people here - for the kind words! I am so happy that my article was so well received today.
> I sketch how the stereographic projection of the Stern–Brocot tree forms an ordered binary tree of Pythagorean triples, which can be used to compute best approximations of turn angles of points on the circle and finally trigonometric functions
The permutation and stack problem in the page seem to indicate this is a potential method for approximations, but insufficient for _all_
That said I am reading this on mobile and may have missed something.
I think skipping transposed values is fine though. You could just mirror the output at 45degrees for that if you wanted it. It does hit all distinct triples including the multiples of triples so it’s more inclusive of everything than the ternary tree.
You can see both triples are contained in one binary tree using the big diagram in section 3. The triple [3 4 5] has the "path" RR. The triple [4 3 5] the path R.
reply