# Triangle solution by Mathematica

da = 1.12; db = 1.23; dc = 0.84;
NSolve[{2 a b/(a + b) Sin[(aA + aB)/2] == dc,
2 b c/(b + c) Cos[aA/2] == da, 2 c a (c + a) Cos[aB/2] == db,
Sin[aA]/Sin[aA + aB] == da/dc, Sin[aB]/Sin[aA + aB] == db/dc}, {a,
b, c, aA, aB}]

EDIT1:

We have 5 equations and 5 unknowns.

Angle bisector formula:

$$dc=\frac{2ab}{a+b} \cos (C/2), \, da=\frac{2bc }{b+c} \cos (A/2), \, db=\frac{2ca }{c+a} \cos (B/2);$$

$$A/2+B/2+C/2= \pi/2;$$

Law of Sines:

$$\frac{\sin A}{\sin(A +B) }=\frac{da}{dc}, \quad \frac{\sin B}{\sin(A +B)}= \frac{db}{dc} ;$$

Motivation was to be able to see a solution of a question running on MSE involving given bisectors of a triangle, I ran Mathematica problem using above known bisector lengths formula but am encountering some error in the numerical itself.. it hangs. Please help with a clue what may be missing.

• @Narasimhan In the third equation there is a syntax error 2c a; (semicolom ???). Can you reduce the equations, maybe some of them are combination of others... Nov 7 '17 at 8:27
• the last two eqns are combination one of the other, so you have four eqns for five variables. I suggest to use Reduce to see where it goes... Nov 7 '17 at 10:01
• "a running problem on MSE" - can you link to it, please? Nov 7 '17 at 10:07
• Thanks @ José Antonio Díaz Navas , There are five unknowns and five equations I fixed that part, but the inverse functions and Reduce are often a hindrance. How is it Reduced? – Nov 7 '17 at 12:17
• The problem ought to be much simpler if you specify a value for the inradius in advance, so that the coordinates are uniquely determined. You might also want to exploit the fact that the barycentric coordinates of the incenter are $\sin A:\sin B:\sin C$, where $A,B,C$ are the three internal angles. Nov 7 '17 at 12:40

modified (See @somos's comment, thanks)

I just detected the question some weeks to late. But I can contribute a very simple straightforward solution using NMinimize:

da = 1.12; db = 1.23; dc = 0.84;
NMinimize[{1,
2 a b/(a + b) Sin[(aA + aB)/2] == dc,
2 b c/(b + c) Cos[aA/2] == da,
2 c a/(c + a) Cos[aB/2] == db,
Sin[aA]/Sin[aA + aB] == da/dc,
Sin[aB]/Sin[aA + aB] == db/dc}, {a,b, c, aA, aB}]

(*{1., {a -> 1.01212, b -> 0.807711, c ->3.43558, aA -> 1.0854,aB -> 1.33088}}*)
• Unfortunately there is a missing / in the code. 2 c a (c + a) should be 2 c a/(c + a). Aug 11 at 18:43

Solve the two last equations, which do not depend on a,b,c, separatly.

First TrigExpand (I rationalized the paramters)

list = {2 a b/(b + c) Sin[(aA + aB)/2] == dc,
2 b c/(b + c) Cos[aA/2] == da, 2 c a/(c + a) Cos[aB/2] == db,
Sin[aA]/Sin[aA + aB] == da/dc, Sin[aB]/Sin[aA + aB] == db/dc} //
TrigExpand;

abceq = list[[1 ;; 3]];

SinCoseq = list[[4 ;; 5]];

red = Reduce[SinCoseq, {aA, aB}];

sol = Solve[red]

(*     {{aB -> ConditionalExpression[-2 ArcTan[Sqrt[14345/23287]] +
2 \[Pi] C[1], (C[2] | C[1]) \[Element] Integers],
aA -> ConditionalExpression[-2 ArcTan[Sqrt[11023/30305]] +
2 \[Pi] C[2], (C[2] | C[1]) \[Element] Integers]}, {aB ->
ConditionalExpression[
2 ArcTan[Sqrt[14345/23287]] +
2 \[Pi] C[1], (C[2] | C[1]) \[Element] Integers],
aA -> ConditionalExpression[
2 ArcTan[Sqrt[11023/30305]] +
2 \[Pi] C[2], (C[2] | C[1]) \[Element] Integers]}}     *)

C[1],C[2] can be oven or odd, that means there are two times four solutions for the abceq uations.

eq1 = abceq /. sol //
FullSimplify[# /. {C[1] -> 2 u, C[2] -> 2 v}, {u, v} \[Element]
Integers] &

eq2 = abceq /. sol //
FullSimplify[# /. {C[1] -> 2 u + 1, C[2] -> 2 v}, {u, v} \[Element]
Integers] &

eq3 = abceq /. sol //
FullSimplify[# /. {C[1] -> 2 u, C[2] -> 2 v + 1}, {u, v} \[Element]
Integers] &

eq4 = abceq /. sol //
FullSimplify[# /. {C[1] -> 2 u + 1, C[2] -> 2 v + 1}, {u,
v} \[Element] Integers] &

sol101 = NSolve[#, {a, b, c}] & /@ eq1

(*   {{{a -> 0.244769, b -> 0.230653, c -> -0.356331}}, {{a -> 1.31884,
b -> 0.99178, c -> 1.91994}}}     *)

sol102 = NSolve[#, {a, b, c}] & /@ eq2

(*  {{{a -> -1.31884, b -> 0.487807, c -> -1.91994}}, {{a -> -0.244769,
b -> -0.782936, c -> 0.356331}}}  *)

sol103 = NSolve[#, {a, b, c}] & /@ eq3

(*   {{{a -> 0.244769, b -> 0.782936, c -> -0.356331}}, {{a -> 1.31884,
b -> -0.487807, c -> 1.91994}}}    *)

sol104 = NSolve[#, {a, b, c}] & /@ eq4

(*    {{{a -> -1.31884, b -> -0.99178, c -> -1.91994}}, {{a -> -0.244769,
b -> -0.230653, c -> 0.356331}}}    *)

If you make new variables and algebraic equations for the trigs then a solution can be obtained in reasonable time (this sort of thing has been done in a few prior MSE threads).

Clear[da, db, dc];
dvalRules = {da -> 1.12, db -> 1.23, dc -> 0.84};
trigRules = {Cos[a_] :> cs[a], Sin[a_] :> sn[a]};

eqns = {2 a b/(a + b) Sin[(aA + aB)/2] == dc,
2 b c/(b + c) Cos[aA/2] == da, 2 c a (c + a) Cos[aB/2] == db,
Sin[aA]/Sin[aA + aB] == da/dc, Sin[aB]/Sin[aA + aB] == db/dc};
polys0 = Numerator[
Together[
TrigExpand[
Apply[Subtract, eqns, {1}] /. {aA -> 2*aA, aB -> 2*aB}] /.
trigRules]];
trigIdens =
Map[#^2 + Apply[sn, #]^2 - 1 &, Cases[Variables[polys0], cs[_]]];
polys = Join[polys0, trigIdens] /. dvalRules;
vars = Variables[polys];

Now sole the system.

AbsoluteTiming[solns = NSolve[polys, vars];]

(* During evaluation of In[103]:= Solve::ratnz: Solve was unable to solve the system with inexact coefficients. The answer was obtained by solving a corresponding exact system and numericizing the result.

Out[103]= {5.424746, Null} *)

Retain real-valued solutions.

realSolns = Select[solns, FreeQ[#, Complex] &];
{a, b, c} /. realSolns

(* Out[113]= {{-1.11217844394,
1.11217844394, -0.372460206543}, {1.40256957119, -1.40256957119, \
-0.932194784531}, {-1.25024995131,
0.314387064726, -0.314387064726}, {1.35457077085,
0.608749750689, -0.608749750689}, {-0.608749750689, -1.35457077085,
1.35457077085}, {-0.314387064726,
1.25024995131, -1.25024995131}, {-0.932194784531, 0.932194784531,
1.40256957119}, {-0.372460206543,
0.372460206543, -1.11217844394}, {-2.0632420756, -4.09496314451,
20.3694113194}, {-0.23991946789,
0.20831767403, -10.688097699}, {-2.82296467293, -0.534229776885,
2.91787741243}, {-0.563848363706, -2.20962845015, -0.928872449049}, \
{-0.785573051303, 2.74272228649,
12.2621124292}, {0.252745851079, -1.09244424909, -10.863435061}, \
{-0.314348110282, 1.04701586538, 1.74202830166}, {-0.230753295866,
0.474486543322, -1.72889992565}, {-0.252745851079, 1.09244424909,
10.863435061}, {0.785573051303, -2.74272228649, -12.2621124292}, \
{0.230753295866, -0.474486543322,
1.72889992565}, {0.314348110282, -1.04701586538, -1.74202830166}, \
{0.23991946789, -0.20831767403, 10.688097699}, {2.0632420756,
4.09496314451, -20.3694113194}, {0.563848363706, 2.20962845015,
0.928872449049}, {2.82296467293,
0.534229776885, -2.91787741243}, {0.372460206543, -0.372460206543,
1.11217844394}, {0.932194784531, -0.932194784531, -1.40256957119}, \
{-1.35457077085, -0.608749750689,
0.608749750689}, {1.25024995131, -0.314387064726,
0.314387064726}, {0.314387064726, -1.25024995131,
1.25024995131}, {0.608749750689,
1.35457077085, -1.35457077085}, {-1.40256957119, 1.40256957119,
0.932194784531}, {1.11217844394, -1.11217844394, 0.372460206543}} *)
• Thanks for the reply. It appears exhaustive. (I should learn more :) ) Can we further filter out triangles with one or two negative signs for $a,b,c,$ to plot the triangles around its in-center, and to capture any pattern? Also if it is possible to get the old MSE post? Nov 8 '17 at 17:34
• In[970]:= posSolns = Select[realSolns, Apply[And, Thread[({a, b, c} /. #) >= 0]] &]; {a, b, c} /. posSolns Out[971]= {{0.563848363706, 2.20962845015, 0.928872449049}} Nov 8 '17 at 17:43
• Unfortunately there is a missing / in the code. 2 c a (c + a) should be 2 c a/(c + a). Aug 11 at 18:45
• @Somos Seems to work with the corrected equation. It even gets faster and loses a warning message. Aug 11 at 19:19
{da, db, dc} = Rationalize[{1.12, 1.23, 0.84}];
N@Solve[{
(2 a b Sin[(aA + aB)/2])/(a + b) == dc,
(2 b c Cos[aA/2])/(b + c) == da,
2 c a (c + a) Cos[aB/2] == db,
Sin[aA]/Sin[aA + aB] == da/dc,
Sin[aB]/Sin[aA + aB] == db/dc,
0 < aA < Pi, 0 < aB < Pi
}, {aA, aB, a, b, c}, Reals,
Quartics -> False, Cubics -> False] // AbsoluteTiming

Output

{2.08422,{{aA->1.0854,aB->1.33088,a->0.563848,b->2.20963,c->0.928872}, {aA->1.0854,aB->1.33088,a->2.82296,b->0.53423,c->-2.91788}}}

• Unfortunately there is a missing / in the code. 2 c a (c + a) should be 2 c a/(c + a). Aug 11 at 18:45