Evaluate the aspect ratio of a triangle
Jelly, 7 bytes
SH_÷@HP
Try it online!
Explanation
Let’s read this chain:
The implicit argument is a list
[a, b, c]
.First we read
S
. This takes the sum:a + b + c
.Then, we read
H
. This halves it:(a + b + c)/2
. (This iss
.)Then, we read a dyad
_
(subtract), followed by another dyad. This is a hook: it lacks a right argument, so it receives the argument to this chain,[a, b, c]
, giving us[s-a, s-b, s-c]
. (This is the fifth chain pattern in the table here.)Then, we read the dyad-monad pair
÷@H
. This is a fork:÷@
is division with the arguments flipped, andH
is halve, so our working value getsH
alf the argument to this chain÷
’d by it. This vectorizes; we’re left with[(a/2)/(s-a), (b/2)/(s-b), (c/2)/(s-c)]
. (This is the second chain pattern in the table here.)Finally, we take the product with
P
, getting usabc/(8(s-a)(s-b)(s-c))
.
View a tree-like graph of how the links fit together.
Jelly, 6 bytes
This answer is based on Emigna's 05AB1E answer. Many thanks to Dennis and Lynn for their help in figuring this answer out. Golfing suggestions welcome! Try it online!
S_Ḥ⁸÷P
Ungolfing
Implicit argument [a, b, c].
S Take the sum, a+b+c or 2*s
Ḥ Take the double, [2*a, 2*b, 2*c].
_ Vectorized subtract, giving us [2*(s-a), 2*(s-b), 2*(s-c)].
⁸÷ Vectorized divide the initial left argument, the input [a, b, c],
by [2*(s-a), 2*(s-b), 2*(s-c)].
P Take the product giving us the aspect ratio, abc/8(s-a)(s-b)(s-c).
Jelly, 6 bytes
S÷_2Pİ
Try it online!
How it works
S÷_2Pİ Main link. Argument: [a, b, c]
S Sum; compute 2s := a + b + c.
÷ Divide; yield [2s ÷ a, 2s ÷ b, 2s ÷ c].
_2 Subtract 2; yield [2s ÷ a - 2, 2s ÷ b - 2, 2s ÷ c - 2].
P Product; yield (2s ÷ a - 2)(2s ÷ b - 2)(2s ÷ c - 2).
İ Invert; yield 1 ÷ (2s ÷ a - 2)(2s ÷ b - 2)(2s ÷ c - 2).