Revision d90ab489-ec3c-46c9-9bc7-40b2fdab80df - Code Golf Stack Exchange
# [Python 3], <s>89 87</s> 69 bytes
<!-- language-all: lang-python -->
f=lambda a,b,c,n=3:n and((c*c-(a-b)**2)/a/b)**.5*(a+b+c)+f(b,c,a,n-1)
[Try it online!][TIO-k9dolp2z]
[Python 3]: https://docs.python.org/3/
[TIO-k9dolp2z]: https://tio.run/##NU3NboQgEL7zFJM9gausimjZ1L5I08OIkpooGuSyMT67BbMl@Ri@v2F9@d/FivM07YRz1yNg2qU6ta14WkDbU6oTnVHMOpYkJXvgIz64TCjeu7tmd0NjHlObFewc53VxHrbXRohZHEyjHWC0UeCb70f7JPD@Ae0GLcy4UjMt6NMry7d1Gj1lLMRcsA29wpHqxblB@yBit1GXhT77LIasDt7qRuupue14pLB38dIHZF@wuwO@93f1@LmxswCAf4Di@XVIGUiEiDPnQqlKSRJZFSCjI3mpRCElqQNr4oZQqCVvlGo@JCm5gIpLqHkDouBVpZom/wM "Python 3 – Try It Online"
A recursive function, takes in 3 sides of the triangle as input.
###How
We can see that each side of the hexagon is the base of an isosceles triangle, whose vertex angle is an angle of the original triangle. For example:
- \$C_aC_b\$ is the base of \$CC_aC_b\$ - an isosceles triangle with leg \$c\$ and vertex angle \$\widehat{C}\$.
- \$A_bB_a\$ is the base of \$CA_bB_a\$ - an isosceles triangle with leg \$a+b\$ and vertex angle \$\widehat{C}\$.
Given the leg \$l\$ and vertex angle \$\theta\$ of an isosleces triangle, the base is calculated as:
$$l\sqrt{2-2\cos{\theta}}$$
Consider 2 opposites side of the hexagon, says \$C_aC_b\$ and \$A_bB_a\$. Since their corresponding triangles have the same vertex angle, their total length is:
$$c\sqrt{2-2\cos{\widehat{C}}}+(a+b)\sqrt{2-2\cos{\widehat{C}}}$$$$=(a+b+c)\sqrt{2-2\cos{\widehat{C}}}$$
Then the perimeter of the hexagon is the sum of 3 opposite pairs:
$$(a+b+c)\left(\sqrt{2-2\cos{\widehat{A}}}+\sqrt{2-2\cos{\widehat{B}}}+\sqrt{2-2\cos{\widehat{C}}}\right)$$
The cosine of an angle can be calculated from the sides of the triangle:
$2ドル-2\cos{\widehat{C}}=\frac{c^2-(a-b)^2}{ab}$$
Thus, the final formula for the hexagon's perimeter is:
$$(a+b+c)\left(\sqrt{\frac{a^2-(b-c)^2}{bc}}+\sqrt{\frac{b^2-(a-c)^2}{ac}}+\sqrt{\frac{c^2-(a-b)^2}{ab}}\right)$$