Question to math geeks. I need a method of finding rational right triangle side lengths for a given integer triangle area.

Note: not every integer area is possible.

Any hints?

@xpil it’s been a while since I did any sort of math on the regular, but the first thing that comes to mind is combining what you know with the Pythagorean theorem:

We know that the area is the height multiplied by the width divided by two: A = (h * w) / 2

The height and width form the sides of the triangle that make the right corner. Let’s call the hypotenuse (long side) of the triangle c and we have: c = sqrt(h^2 + w^2)

Now pick values for h and w that fit your given area, and solve for c 🙂

@xpil I should note that any given area will probably have multiple solutions for the three sides (h, w, c), since you can switch around the sides, make one longer and another shorter, and apply many kinds of transformations to the triangle to make it fit any given area.

@xpil let’s do an example with a triangle of area 1:

I’ll go ahead and choose h = 1 and w = 2. I chose those numbers because they fit the area - (1 * 2) / 2 = 1 - they’re not the only possible values.

Now to figure out c:

c = sqrt(1^2 + 2^2) = sqrt(1 + 4) = sqrt(5) ~ 2.2361

And we have the three sides!

h = 1
w = 2
c = sqrt(5)

Hope that helps!

@xpil You've probably already tried iterating through lengths and using the Pythagorean theorem to check if the other side is rational.

I haven't gotten far with this other idea, but a little research introduced me to:
(a) Euclid's formula for Pythagorean triples
(b) Heron's formula / Heronian triangles

These are both fairly new ideas to me and I'm not really sure how to apply them to this problem. However, they /might/ make a faster solution?

@xpil When there is a solution with rational lengths you can scale it up to a solution with integer lengths. These three numbers a,b,c are Pythagorean triplets which can be found with several methods:

The scaled² up area is another boundary condition for a and b.

For your problem you have to go this way backwards 😃

(I hope there is no mistake in my thoughts.)

I think you're on the right track with this one. I have some reasoning now using that: 

@kdkeller @xpil Say we are looking for a triangle T area A and rational sides x,y,z
Let there be a Pythagorean Triple a,b,c and their triangle have area Δ

T exists if such a triple exists that
x=as, y=bs, z=cs

Where s (scale) must contain the LCM of a,b,c as a factor.

This is still quite new to me, so I can't be too sure about my reasoning. I don't know either if cases outside this can or can't exist.

Sign in to participate in the conversation

Fosstodon is an English speaking Mastodon instance that is open to anyone who is interested in technology; particularly free & open source software.