2
Let h = the height of the right triangle (an integer).
Let c = the hypotenuse
Let l = the other leg

So l^2+h^2=c^2

I am trying to figure out, for instance, why there are 8 such triangles when h=12. I try to figure this out manually and I'm only finding (EDIT) 4:

5 12 13
9 12 15
16 12 20
35 12 37

Is there a general approach to finding these (other than factorizations of h^2)?

AOAOne
  • 491

3 Answers3

1

You can rewrite the Pythagorean theorem for your case as $144=c^2-\ell^2=(c-\ell)(c+\ell)$. There are lots of ways to factorize 144, which means lots of ways of writing it as $(c-\ell)(c+\ell)$.

Addendum: Just expanding a bit on some of what was covered in the comments. In response to Maesumi's answer, you make the remark,

I'm trying to basically find the sum of the number of triangles given height $n$ over a range of $n$.

If $h$ is odd, then, writing $h^2=xy$ with $x\lt h$ and $y\gt h$, the triples $(a,b,c)$ with $b=h$ are $((y-x)/2,h,(y+x)/2)$. If $h$ is even, then, writing $h^2=4wz$ with $w\lt h/2$ and $z\gt h/2$, the triples are $(z-w,h,z+w)$. This implies that a formula for the number of triangles of height $h$ is $$ \begin{cases} \frac{\sigma_0(h^2)-1}{2} & h\text{ odd,}\\ \frac{\sigma_0((h/2)^2)-1}{2} & h\text{ even,} \end{cases} $$ where $\sigma_0(n)$ is the number of divisors of $n$. Not that this helps you at all, since it's equivalent to what you're already doing. I gather that you are needing to compute this for a very large number of very large values of $h$. I'm not sure that there's any faster way to do this than by actually factorizing those values of $h$.

You've probably seen the Online Enyclopedia of Integer Sequences page related to your problem, http://oeis.org/A046079, but if not, it's worth having a look.

Addendum II: Filling in more details from the comments, which I muddled due to bad notation. You ask for a bound on the hypotenuse, $c$, given the height $h$. Let $\ell$ be the length of the other leg. The bound is different for $h$ even and for $h$ odd.

$h$ even: Since $c$ and $\ell$ must have the same parity if $h$ is even, we have $\ell\le c-2$ in this case, and so $$ h^2=c^2-\ell^2\ge c^2-(c-2)^2=4c-4. $$ Hence $c\le c_\text{max}=(h/2)^2+1$.

$h$ odd: Since $c$ and $\ell$ must have opposite parity when $h$ is odd, we have $\ell\le c-1$ in this case. From this it follows that $c\le c_\text{max}=(h^2+1)/2$.

Interestingly, there is always a triple with maximal hypotenuse since $c_\text{max}^2-h^2$ is always a perfect square.

Ross Millikan
  • 374,822
Will Orrick
  • 18,220
  • I know I didn't mention it before, but I'm trying to avoid doing this with factorizations -- I know how to get the counts using the number of divisors of h^2 and am trying to go for a more direct approach – AOAOne Apr 18 '12 at 16:30
  • Regarding your question how to know when to stop, you know that $h$ can't be greater than 37. The reason is that 144 must equal the difference of two squares. Since the closest square to $37^2$ of the same parity is $35^2$, which gives difference 144, the difference of two squares, one or both of which is larger than $37^2$, will be bigger than 144. This at least reduces it to a finite search, if you don't want to use factorizations. – Will Orrick Apr 18 '12 at 16:59
  • I am not that versed in math jargon; by parity do you mean the same even/odd status as the original number? As in, since 37 is odd, the next lowest odd number is 35? – AOAOne Apr 18 '12 at 17:04
  • Yes, that's right. We need that to ensure the difference is even. There is, of course, a formula for Pythagorean triples, but to use that would, I should think, be equivalent to using the factorization method. – Will Orrick Apr 18 '12 at 17:10
  • Well I can generate them with a=k(m^2-n^2), b=k2mn, and c=k(m^2+n^2), I believe. Each value of m and n I give would technically give valid triangles, yes? – AOAOne Apr 18 '12 at 17:13
  • Yes, but since $b$ (or $a$) must equal a specified number, aren't you again stuck with factorizing that number in order to find $k$, $m$, and $n$? – Will Orrick Apr 18 '12 at 17:16
  • Man, I just can't win, can I, LOL. Right you are. Guess I am stuck for now, then. Thanks for the elucidation. – AOAOne Apr 18 '12 at 17:17
  • Is there a quick way to get that limit, btw? If I know h=12, I know the hypotenuse must be larger than 144. How can I quickly determine the maximum hypotenuse limit other than trial and error? – AOAOne Apr 18 '12 at 17:47
  • For $h=2n+1$, we have $(2n+1)^2-(2n-1)^2\le144$ implies $8n\le 144$ or $n\le18$. So $h=2n+1\le37$. You can do something similar for $h$ even. – Will Orrick Apr 18 '12 at 19:57
  • In the previous comment, I should have written $c$ instead of $h$. (In the rest of the discussion $h$ stands for height, not hypotenuse.) – Will Orrick Apr 19 '12 at 14:36
  • Nice, do you think your approach could also be used in a more general case, special this and that? – draks ... Apr 19 '12 at 14:45
  • Using the less than sign seems not to work in $\LaTeX$ in my browser-I have seen suggestions to use \lt – Ross Millikan Apr 19 '12 at 15:52
  • @ Ross Millikan : Thanks for fixing that! – Will Orrick Apr 19 '12 at 15:55
  • @draks : Your questions are very interesting. Since this Pythagorean problem involves the difference of two squares, which factorizes over the integers, the analysis is straightforward. I don't immediately see anything analogous for sums of powers, but I will think about it. – Will Orrick Apr 19 '12 at 15:56
1

If you take (3,4,5) and multiply by 3 you get (9,12,15) but if you multiply with 4 you get (12,16,20). If your problem allows 0 and negative numbers or switching numbers then the count will change. For general solutions write $x^2+12^2=z^2$. This gives you $(z-x)*(z+x)=144$. factor 144 to two numbers, both have to be even (or both odd which does not happen here) to get integer answers, so you get $((z-x),(z+x))=(2,72),(4,36),(6,24),(8,18)$. First one gives $z=37,x=35$, next $z=20 x=16$, next $z=15,x=9$, next $z=13, x=5$. If you allow for exchanging legs you get 8. So the unfamiliar answer was $12^2+35^2=37^2$.

Maesumi
  • 3,702
  • Is there any way to do this with Pythagorean Triples? – AOAOne Apr 18 '12 at 16:55
  • So your question becomes: If a number n^2 is given, how many ways it factors as a*b where both a and b are odd or both even. – Maesumi Apr 18 '12 at 16:57
  • you need a little theorem which tells you the number of factors of n if n=p^rq^s... then you can answer your question in general. – Maesumi Apr 18 '12 at 17:05
  • I have an implementation that will find prime factorizations of a number based on trial division, but it is too slow for my purposes. I'm trying to basically find the sum of the number of triangles given height n over a range of n. Finding the prime factorization of each n is proving to be timeconsuming and so I'm trying other approaches. – AOAOne Apr 18 '12 at 17:07
  • perhaps you can generate "all" triplets and then sift them for the ones you want by solving some inequalities. If that is faster than prime factorization might not be easy to tell. – Maesumi Apr 18 '12 at 17:19
  • Yes, this was my other thought as well... I figure I can just generate all triplets up until my maximum N or something, but you are right that it could be very timeconsuming – AOAOne Apr 18 '12 at 17:23
  • What are you writing this in? Surely it would be better to use a ready-made factorisation algorithm than writing your own slow one? (I only program in GAP, so I would just use the inbuilt factorisation function.) I guess which approach will be faster depends on what you're aiming for. If you want to do it for a whole range of heights, then Maesumi's most recent suggestion will probably be faster. If you just want to be able to input a single number and get an answer, then provided your numbers aren't really really huge, factorisation is surely going to be better. – Tara B Apr 18 '12 at 18:52
  • @TaraB My factorization algorithm is quite fast, but my limit is up into the trillions. Even good factorization algorithms are not fast enough here. I've already spent a week on the factorization approach and just could not get it to run in reasonable runtime. – AOAOne Apr 18 '12 at 19:04
1

You might find this paper of interest: http://www.math.ou.edu/~dmccullough/teaching/pythagoras2.pdf

  • Without any further information, this is more a comment than an answer, but there's still space left... – draks ... Apr 20 '12 at 07:05