2
$\begingroup$

I know this question may be based on programming but its core is geometry hence I am posting it here.

Okay what I am trying to do is to write a small program to find out all the possible triangles that have the same incircle radius.

One important condition is that all the units will be in integers. That is to say the ratio between the area and semi-perimeter must be a fully divisible with each other. The area calculated by Heron's formula must be a perfect square root. Also the perimeter must be fully divisible by 2. No rounding off, values with floating points are discarded entirely.

Following the above conditions the two scalene triangles share the same incircle ie. of radius 2.

5 12 13
6 8 10

Do they have any similarities ? What is the maximum area of the triangle that can contain an incircle of radius $r$ ?

What I am doing right now is actually checking all triangles starting with sides $2r$ to $2r*100$. Its basically a brute-force. But is there a better way of determining where I should stop ?

EDIT:

Just found this algo in CodeChef for this problem. Can someone explain to me how it works ? Or whats the logic behind it is ?

for x = 1 to 2*r-1 do:
    for y=x to (3*(r*r))/x do:
        p = (r*r)*(x+y)
        q = x*y-(r*r)

        if q <= 0
          perform next iteration of inner loop

        else
            z = p/q

            if (z < y or p mod q ! = 0)
                perform next iteration of inner loop

            else
                points for the triangle are
                x+y
                x+z
                z+y
       end inner loop
end outer loop

Here $r$ is the radius of the incircle. And mod means the remainder when I divide by the divisor(Its a programming operator). For example 4 mod 2 = 0, 4 mod 3 = 1

Please note I come from a computer science background so I am not that much familiar with the mathematical language, so if the above algo seems difficult to understand in the fashion I have given it then please let me know what I can do to better present it.

  • 0
    By just looking at your examples, I can say that they are right angled.2017-01-18

1 Answers 1

3

The triangles you are looking for are either Pythagorean triangles or a sum of two (possibly scaled) Pythagorean triangles.

To see that, one can show first of all that any Pythagorean triangle has an integer inradius. Any primitive Pythagorean triple $(a,b,c)$ can be obtained from two coprime integers $m$ and $n$ (not both odd and with $m>n$) as: $$ a=m^2-n^2,\quad b=2mn,\quad c=m^2+n^2, $$ and the Pythagorean triangle derived from that triple has inradius $$ r={ab\over a+b+c}=n(m-n), $$ which is indeed an integer. Of course, a multiple $(ka,kb,kc)$ of that Pythagorean triple will still give a triangle with integer inradius $r'=kr$.

In general, a triangle with integer sides and area also has rational altitudes. The altitude relative to the largest side falls inside the base and divides then the triangle into two right-angled triangles. Those triangles have integer hypotenuses, a rational cathetus common to both, and the other catheti whose sum is an integer, so they must be (rational multiples of) Pythagorean triangles.

EDIT.

For example, a triangle with sides $AC=9$, $BC=10$, $AB=17$, has an inradius of $2$ but is not Pythagorean. Let $CH$ be the altitude with respect to base $AB$: its length is $72/17$, which is a rational number. By Pythagoras' Theorem we also get: $AH=135/17$ and $BH=154/17$, so that triangles $ACH$ and $BCH$ are rescaled Pythagorean triangles, with sides: $$ \left(9,{135\over17},{72\over17}\right)={9\over17}\left(17,15,8\right) \quad\hbox{and}\quad \left(10,{154\over17},{72\over17}\right)={2\over17}\left(85,77,36\right), $$ and inradii $27/17$ and $28/17$ respectively.

I don't know if the above is relevant or not for your search: I tried to find a simple relation between the inradius of the composite triangle and the inradii of its two constituents, but without success. At the moment, I think a brute-force approach is still preferable to find all triangles with a given inradius.

EDIT 2.

That piece of code makes sense. Tangency points divide triangle sides into $6$ parts (equal pairwise), whose lengths are $x$, $y$ and $z$ (see diagram below).

Let $2\alpha$, $2\beta$ and $2\gamma$ the angles formed by the radii joining incenter with tangency points, so that $x=r\tan\alpha$, $y=r\tan\beta$, $z=r\tan\gamma$, and suppose $x\le y\le z$. The largest value of $x$ is attained when $\alpha=\beta=\gamma=60°$, so we have a first bound: $$x\le r\tan 60°=\sqrt3 r.$$

Once $x$ is given, the largest value of $y$ is reached when $\beta=\gamma=90°-\alpha/2$, whence a second bound: $$ y\le r\tan(90°-\alpha/2)={r^2+r\sqrt{x^2+r^2}\over x}\le{3r^2\over x}. $$ Finally, once $x$ and $y$ are given one can compute: $$ z=r\tan(180°-\alpha-\beta)={r^2(x+y)\over xy-r^2}. $$

Notice that in the code the first and second bound are used in a weaker form, possibly for the sake of simplicity. But for large values of $r$, using the optimal bounds given above: $$ 1\le x\le \sqrt3 r, \quad x\le y \le {r^2+r\sqrt{x^2+r^2}\over x}, $$ could result in a faster execution.

enter image description here

  • 0
    Could you please clarify what you mean by a rational altitude ?2017-01-19
  • 0
    Also `9 10 17` I don't think this triangle is a Pythagorean triangle but it has an in circle of 2 so how is that possible ? I don't think I am looking for only Pythagorean triangles2017-01-19
  • 0
    The altitudes are the perpendicular line segments from each vertex to the opposite side; in this case all of them will have rational lengths. The rest of the answer doesn't seem to be correct though, and the error is in the assumption that the other catheti will also be rational. As you say, 9,10,17 works. The altitude relative to the largest side has length 36/17, which is rational, but it divides the longest side into two irrational lengths, so there are no pythagorean triangles involved.2017-01-19
  • 0
    See my edited answer.2017-01-19
  • 0
    @EspeciallyLime: Your computation is incorrect: see my edited answer.2017-01-19
  • 0
    @Aretino apologies, you are right.2017-01-19
  • 0
    @Aretino No I don't think brute force is the only method to find the circles. Check my answer I have edited it to include a non brute force algo. Could go through it and tell me how it works ?2017-01-21
  • 0
    Tangency points divide triangle sides into $6$ parts (equal pairwise). I presume their lengths are represented by $x$, $y$ and $z$ in that code.2017-01-22
  • 0
    And it is easy to show that $$z={r^2(x+y)\over xy-r^2}.$$2017-01-22
  • 0
    See also my second edit.2017-01-22
  • 0
    @Aretino How did you know that ${\alpha},{\beta},{\gamma}$ will not be more than $60^{\circ}$ ? Consider the triangle with angles $90^{\circ},58^{\circ}, 32^{\circ}$, the triangles formed inside the incircle corresponding to angles 58 and 32 will all have the circle angle as more than 60. But this triangle violates the problem statement since the sides are not integer. So how did you know that for only integer sides the angles of the incircle triangle can never be more than $60^{\circ}$ ? Is there a proof for that ?2017-01-24
  • 0
    @Aretino In fact take the first triangle 5 12 and 13 check it but ${\gamma}$ here will 78.5 which is more than 60. So what the logic behind that the angles won't be greater than 60 ?2017-01-24
  • 0
    The *smallest* angle is always no more than 60°. That's all we need when looking at a bound for $x$, which is smaller than $y$ and $z$.2017-01-24