[math-fun] Optimum algorithms for generating Heron triangles; better count bounds & generators for d-simplices
Unfortunately my post was wrong. I now explain the (stupid) problem and correct it. It all was valid for Heron triangles a,b,c which happen to be generated by Bucholtz's parameterization: a = (n^2 + k^2)m, b = (m^2 + k^2)n, c = (m + n)(m n - k^2), semiperimeter = s = (m + n)m n, area = d = k m n(m + n)(m n - k^2); However, stupidly, I forgot that Heron triangles often arise from this parameterization only in nonprimitive form and then you'd need to divide a,b,c by gcd(a,b,c) to primitivize. To try to recover from my error, we can employ this 4-parameter description of ALL heron triangles a,b,c [now no need to divide by GCDs to primitivize, in the sense that the primitive ones already are represented directly] stated by Derrick N Lehmer: Rational triangles, Annals of Maths 2ser 1 (1899-1900) 97-102 and as he says also known to various previous authors: a = p q (r^2 + s^2) b = (p s +- q r) (p r -+ q s) c = r s (p^2 + q^2) area = p q r s (p s +- q r) (p r -+ q s) circumradius = (p^2 + q^2) (r^2 + s^2) / 4 semiperimeter = (a+b+c)/2 inradius * semiperimeter = area Now, attempt to recapitulate my old argument, basically.
From a, we can factor it into 3 factors in a^o(1) ways at most and represent the 3rd factor as sum of 2 squares in a^o(1) ways at most. Hence there are at most a^o(1) heron triangles with side a.
Similar argument for side c. [Similar argument for circumradius!] For side b it is trickier. Focusing on the first sign choice wlog, b = X*Y where X=(p s + q r) and Y=(p r - q s) we can factor b=X*Y in all possible ways namely <b^o(1) ways. Then solving for p,q in terms of X,Y,r,s we find q = (r*X-s*Y)/(r^2+s^2) p = (r*Y+s*X)/(r^2+s^2) or similarly r=(p*Y+q*X)/(p^2+q^2) s=(p*X-q*Y)/(p^2+q^2). or we can solve for other pairs of variables instead. If we solve for {p,r} then we find r = X/(2*q) + squareroot( X^2 - 4*q*Y*s - 4*q^2*s^2 )/(2*q) p = X/(2*s) - squareroot( X^2 - 4*q*Y*s - 4*q^2*s^2 )/(2*s) for example. Thus a rational solution {p,r} only exists if X^2-4*Y*q*s-4*(q*s)^2 is a square. Similarly for {q,s} to exist we need X^2+4*Y*p*r-4*(p*r)^2 to be square. Similarly for {q,r} to exist we need Y^2+4*X*s*p-4*(s*p)^2 to be square. Similarly for {p,s} to exist we need Y^2+4*X*q*r-4*(q*r)^2 to be square. By "completing the square" on the last quadratic(q*r), i.e. rewriting it as Y^2 + X^2 - (2*q*r-X)^2 we can express this as a demand that Y^2+X^2 be a sum of two squares. We can proceed similarly for all the other 3 quadratics. Thus the ways in which Y^2+X^2 is a sum of 2 squares yield the values of p,q,r,s. More precisely: By first factoring b=X*Y all possible ways and then finding all possible ways to write X^2+Y^2 as sum of two squares, and then considering each unsquared square as 2*q*r-X and the like, we deduce q*r, s*p, p*r, and q*s. Then by factoring them in all possible ways we deduce p,q,r,s. Hence we realize the number of possibilities is b^o(1) and we can find them all in this time bound. So-- now without the error I made last time-- THEOREM: the number of Heron triangles with side=n [or area=n, or circumradius=n, apparently also work! And I do not need to demand n be the LONGEST side either!], is bounded by n^o(1) and all of them may be found by algorithm in time n^o(1). And now everything I said last post -- all of which are corollaries of this theorem-- are restored to validity. (Until another bug is found...:)
participants (1)
-
Warren Smith