5
$\begingroup$

I try to solve the simple problem of finding (integer numbers) for the sides of a triangle when its perimeter is 90 and its area is twice, three times or four times this number. My approach is this:

Grid[{#, 
FindInstance[
 a + b + c == 90 && a > b > c > 0 && 
  Area@SSSTriangle[a, b, c] == #*90, {a, b, c}, Integers, 
 3]} & /@ {2, 3, 4}, Frame -> All]

However the second solutions when the area is double and triple does not correspond to the sides of a triangle as it should comply a<b+c and this is apparent when you try to calculate the area of the triangle by Area@SSSTriangle[50, 27, 13] which reports

SSSTriangle::tri: The triangle side 50 should be less than sum of sides 27 and 13.

How the third condition is fullfiled in the FindInstance ? Is this a bug ?

$\endgroup$
9
  • 1
    $\begingroup$ No bug, just a surprise. It arises from how the evaluation proceeds. In[2172]:= Area@SSSTriangle[a, b, c] Out[2172]= 1/4 Sqrt[ Abs[(a + b - c) (a - b + c) (-a + b + c) (a + b + c)]] This is what FindInstance actually has to work with. $\endgroup$ Dec 20, 2023 at 19:06
  • 1
    $\begingroup$ Based on @DanielLichtblau 's comment adding in the constraint a <= b + c gets the desired results. $\endgroup$
    – JimB
    Dec 20, 2023 at 19:18
  • 1
    $\begingroup$ @JimB: It should be a < b+c to exclude degenerated cases. $\endgroup$
    – user64494
    Dec 20, 2023 at 19:25
  • 2
    $\begingroup$ @user64494 Sounds good but degenerates aren't all bad. $\endgroup$
    – JimB
    Dec 20, 2023 at 19:27
  • $\begingroup$ @DanielLichtblau Correct. So the expression of the area is evaluated before the warning message. The warning should be triggered before for getting the correct result without the additional constrain. $\endgroup$
    – Nitra
    Dec 20, 2023 at 22:18

2 Answers 2

4
$\begingroup$

The fix is to add the triangle inequality a < b + c:

Grid[
  {#, FindInstance[
        a + b + c == 90 && a > b > c > 0 && a < b + c && 
        Area@SSSTriangle[a, b, c] == #*90, 
        {a, b, c}, Integers, 3]
  }& /@ {2, 3, 4}, 
  Frame -> All
]

$$\begin{array}{cc} 2 & \{\{a\to 41,b\to 40,c\to 9\}\} \\ 3 & \{\{a\to 39,b\to 36,c\to 15\}\} \\ 4 & \{\{a\to 36,b\to 29,c\to 25\}\} \\ \end{array} $$

$\endgroup$
5
$\begingroup$
$Version

(* "13.3.1 for Mac OS X ARM (64-bit) (July 24, 2023)" *)

Clear["Global`*"]

$Version

(* "13.3.1 for Mac OS X ARM (64-bit) (July 24, 2023)" *)

Or using Solve

Clear["Global`*"]

sol = DeleteDuplicates[
  Solve[
   {a + b + c == 90, a + b > c, a + c > b, b + c > a,
    Mod[Area[SSSTriangle[a, b, c]], 90] == 0},
   {a, b, c}, PositiveIntegers],
  Sort[Values[#1]] == Sort[Values[#2]] &]

(* {{a -> 9, b -> 40, c -> 41}, {a -> 15, b -> 36, c -> 39}, 
    {a -> 25, b -> 29, c -> 36}} *)

Checking,

{a + b + c, Area[SSSTriangle[a, b, c]]/90} /. sol

(* {{90, 2}, {90, 3}, {90, 4}} *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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