2
$\begingroup$
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)?

  • 0
    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$.2012-04-18
  • 0
    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?2012-04-18
  • 0
    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.2012-04-18
  • 0
    I am technically looking for multiple h's, in practice2012-04-18
  • 0
    You have all 8 now, because as I said before, the shortest side can be either the height or the "other leg".2012-04-18
  • 0
    @TaraB I understand how it is 8 now, but I am also looking to find this for a wide range of h efficiently2012-04-18
  • 0
    I just made that comment because in the question you still have that you're trying to understand why there are 8 and you've only found four.2012-04-18
  • 0
    One more thing: In the question you don't actually specify that $l$ has to be an integer, but it you do mean it to be, right?2012-04-18
  • 0
    @TaraB I am actually not sure about that!2012-04-18
  • 0
    let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/3149/discussion-between-tara-b-and-aoaone)2012-04-18
  • 0
    Oh dear, that was very stupid of me. There's no need to specify it, because it has to be!2012-04-18
  • 0
    @TaraB No it doesn't. What about $(c,h,l)=(4,3,\sqrt7)$?2012-04-18
  • 0
    @Mike: ... well, I got it wrong eventually, anyway. =]2012-04-18

3 Answers 3

2

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.

  • 0
    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 approach2012-04-18
  • 0
    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.2012-04-18
  • 0
    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?2012-04-18
  • 0
    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.2012-04-18
  • 0
    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?2012-04-18
  • 0
    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$?2012-04-18
  • 0
    Man, I just can't win, can I, LOL. Right you are. Guess I am stuck for now, then. Thanks for the elucidation.2012-04-18
  • 0
    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?2012-04-18
  • 0
    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.2012-04-18
  • 0
    In the previous comment, I should have written $c$ instead of $h$. (In the rest of the discussion $h$ stands for height, not hypotenuse.)2012-04-19
  • 0
    Nice, do you think your approach could also be used in a more general case, special [this](http://math.stackexchange.com/q/128521/19341) and [that](http://math.stackexchange.com/q/103432/19341)?2012-04-19
  • 0
    Using the less than sign seems not to work in $\LaTeX$ in my browser-I have seen suggestions to use \lt2012-04-19
  • 0
    @ Ross Millikan : Thanks for fixing that!2012-04-19
  • 0
    @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.2012-04-19
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$.

  • 0
    Is there any way to do this with Pythagorean Triples?2012-04-18
  • 0
    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.2012-04-18
  • 0
    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.2012-04-18
  • 0
    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.2012-04-18
  • 0
    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.2012-04-18
  • 0
    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 timeconsuming2012-04-18
  • 0
    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.2012-04-18
  • 0
    @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.2012-04-18
1

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

  • 0
    Without any further information, this is more a comment than an answer, but there's still space left...2012-04-20