Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.
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)?

share|improve this question
    
Try looking for ones where 12 is the shortest side (there are two). And then it looks like every triple is being counted twice, because the shortest side could be either $h$ or $l$. –  Tara B Apr 18 '12 at 16:17
    
I think I found the other two. Is there a general approach? I know about Pythagorean Triples but how do I generate these and how do I know when to stop? –  AOAOne Apr 18 '12 at 16:20
    
The problems of (i) counting (or listing) factors of $h^2$ and (ii) counting (or listing) Pythagorean triples with one leg $h$ are one small step from each other. So the "other than $\dots$" part makes the question unanswerable. –  André Nicolas Apr 18 '12 at 18:14
    
I am technically looking for multiple h's, in practice –  AOAOne Apr 18 '12 at 18:19
    
You have all 8 now, because as I said before, the shortest side can be either the height or the "other leg". –  Tara B Apr 18 '12 at 18:39
show 8 more comments

3 Answers

up vote 2 down vote accepted

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.

share|improve this answer
    
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=k*2*mn, 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
show 9 more comments

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$.

share|improve this answer
    
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^r*q^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
show 3 more comments

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

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.