[Question]
  [
Given three sidelengths of a triangle, evaluate its aspect ratio *AR* given the following formula:
[![enter image description here](https://i.stack.imgur.com/NUubd.png)](https://i.stack.imgur.com/NUubd.png)
where
[![enter image description here](https://i.stack.imgur.com/ZkGvs.png)](https://i.stack.imgur.com/ZkGvs.png)
The closer to equilaterality a triangle is, the closer to `1` its aspect ratio is. The aspect ratio is bigger or equal to `1` for valid triangles.
### Inputs
The input is three real positive numbers which can be encapsulated in a list or anything similar if need be.
Your program must output the same value no matter what the order in which the three sidelengths are inputted is.
Those three numbers will always be valid sidelengths of a triangle (degenerate triangles like one with sidelengths `1`, `1` and `2` will not be given as input). You need not worry about floating point inaccuracies when values become extremely close to a degenerate triangle (e.g. it is acceptable that your program would error `division by 0` for input `[1, 1, 1.9999999999999999]`).
The input can be given through `STDIN`, as a function argument, or anything similar.
### Outputs
The output is a real number bigger or equal to `1` with the standard accuracy that is acceptable in your language.
The output may be printed to `STDOUT`, returned from a function, or anything similar.
### Test cases
```
Inputs                   Output
  1      1      1         1
  3      4      5         1.25
 42     42   3.14         ≈ 6.9476
 14      6     12         1.575
  6     12     14         1.575
0.5    0.6    0.7         ≈ 1.09375
```
### Scoring
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest answer in bytes wins.
  
[Answer]
# [Jelly](http://github.com/DennisMitchell/jelly), 7 bytes
```
SH_÷@HP
```
[Try it online!](http://jelly.tryitonline.net/#code=U0hfw7dASFA&input=&args=MC41LDAuNiwwLjc)
## Explanation
[![enter image description here](https://i.stack.imgur.com/zeShr.png)](https://i.stack.imgur.com/zeShr.png)
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 is `s`.)
* 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**](https://github.com/DennisMitchell/jelly/wiki/Tutorial#how-do-we-walk-down-the-chain).)
* Then, we read the dyad-monad pair `÷@H`. This is a **fork**: `÷@` is division with the arguments flipped, and `H` is halve, so our working value gets `H`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**](https://github.com/DennisMitchell/jelly/wiki/Tutorial#how-do-we-walk-down-the-chain).)
* Finally, we take the product with `P`, getting us `abc/(8(s-a)(s-b)(s-c))`.
[**View a tree-like graph of how the links fit together.**](https://i.stack.imgur.com/8NcIq.png)
[Answer]
# [Jelly](http://github.com/DennisMitchell/jelly), 6 bytes
This answer is based on [Emigna's 05AB1E answer](https://codegolf.stackexchange.com/a/101258/47581). Many thanks to Dennis and Lynn for their help in figuring this answer out. Golfing suggestions welcome! [Try it online!](http://jelly.tryitonline.net/#code=U1_huKTigbjDt1A&input=&args=Myw0LDU)
```
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).
```
[Answer]
# [Jelly](http://github.com/DennisMitchell/jelly), 6 bytes
```
S÷_2Pİ
```
[Try it online!](http://jelly.tryitonline.net/#code=U8O3XzJQxLA&input=&args=MC41LCAwLjYsIDAuNw)
### 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).
```
[Answer]
# JavaScript, 38 bytes
This is a ([curried](http://meta.codegolf.stackexchange.com/a/8427/24877)) lambda:
```
a=>b=>c=>a*b*c/(b+c-a)/(a+c-b)/(a+b-c)
```
(If you assign it to a variable `f` you'd need to call it like `f(3)(4)(5)`)
[Answer]
# [05AB1E](http://github.com/Adriandmen/05AB1E), ~~11~~ 7 bytes
05AB1E uses [CP-1252](http://www.cp1252.com) encoding.
```
O¹·-¹/P
```
[Try it online!](http://05ab1e.tryitonline.net/#code=T8K5wrctwrkvUA&input=WzQyLDQyLDMuMTRd)
**Explanation**
```
O         # sum input
 ¹        # push input again
  ·       # multiply by 2
   -      # subtract from sum
    ¹/    # divide by input
      P   # product
```
[Answer]
# [MATL](http://github.com/lmendo/MATL), ~~8~~ 7 bytes
```
tsGE-/p
```
[Try it online!](http://matl.tryitonline.net/#code=dHNHRS0vcA&input=WzE0IDYgMTJd)
### Explanation
Let's use input `[3 4 5]` as an example
```
t    % Take input implicitly. Duplicate
     % STACK: [3 4 5], [3 4 5]
s    % Sum of array
     % STACK: [3 4 5], 12
G    % Push input again
     % STACK: [3 4 5], 12, [3 4 5]
E    % Multiply by 2, element-wise
     % STACK: [3 4 5], 12, [6 8 10]
-    % Subtract, element-wise
     % STACK: [3 4 5], [6 4 2]
/    % Divide, element-wise
     % STACK: [0.5 1 2.5]
p    % Product of array. Implicitly display
     % STACK: 1.25
```
[Answer]
## R, 34 29 bytes
```
x=scan();prod(x/(sum(x)-2*x))
```
Reads input from stdin and store as the R-vector `x`. Then make use of R's vectorization to form the denominator.
[Answer]
# Haskell, 36 bytes
This defines the function `#` which takes three arguments.
```
(a#b)c=a*b*c/(b+c-a)/(a+c-b)/(a+b-c)
```
You have to call it as follows: `(3#4)5`
A little bit longer but perhaps more golfable:
```
p=product
f v=p v/p((sum v-).(2*)<$>v)
```
[Answer]
# MATLAB, ~~64 38~~ 25 bytes
This is an anyonmous function that implements the formula as provided:
```
@(v)prod(v./(sum(v)-2*v))
```
It assumes the input to be a list of three values e.g. `[3,4,5]`. This example is used in following explanation:
```
             sum(v)        = 3+4+5 = 12
             sum(v)-2*v    = 12 - 2*[3,4,5] = 12 - [6,8,10] = [6,4,2]
         v./(sum(v)-2*v))  = [3,4,5] ./ [6,4,2] = [0.5,1,2.5]
    prod(v./(sum(v)-2*v))  = 0.5 * 1 * 2.5 = 1.25
```
[Answer]
## Mathematica, 20 bytes
```
1##&@@(#/(Tr@#-2#))&
```
Takes input as a list of three values, which is referred to as `#` inside the function. `Tr@` is the shortest way to sum a list (to get `2s`) and `1##&@@(...)` multiplies the three factors `i/(2s-2i)` for `i` in `a, b, c`.
If the inputs are integers or rational numbers, you'll get an exact result.
[Answer]
# [Python 3](https://docs.python.org/3/), 42 bytes
```
lambda a,b,c:a*b*c/(b+c-a)/(a+c-b)/(a+b-c)
```
[Try It Online!](https://tio.run/nexus/python3#PU3LCsMwDLvvK3SMOzd9pR0U9ie72BmBwtaVsv/PnBxmLEtCAifc8cgveetTIKwcV2m0iZ3Ta2yFOifGWlnbSDl9TjhhKCMSth1uYJQlhpsYgTEXGUbThskPofjBgsVqYzFVGGrS@5nR@6WcG60X2Bzntn9d@j@i/AM "Python 3 – TIO Nexus")
[Answer]
# Minecraft 1.8, 1607 bytes + 85 blocks = 1692 blytes
**Warning: *Not* golfed. Golfed will take up to 1*/*3 less blytes.**
Here is a commented screenshot:
[![enter image description here](https://i.stack.imgur.com/mZDQN.png)](https://i.stack.imgur.com/mZDQN.png)
* The inputs are `a`, `b`, and `c`,and the output is `fin`
* `fin`, and all other variables in Minecraft are integers, so the standard Minecraft accuracy is 0 decimal points
* The green border: the command blocks on the left will activate after the ones on the right, which are just variable initializations.
* The lever (grey-brown rectangle in the down right) is the contraption trigger
* **It takes up so much because of the way Minecraft handles variables**. A very simplified overview:
	+ `/scoreboard objectives add name dummy` creates a new variable named "`name`"
	+ `/scoreboard players set @p name number` sets the variable `name` to `number`. Number must be a real number, not a variable.
	+ `/scoreboard players operation @p name += @p name2` increments `name` by `name2`. `name2` must be a variable, not a number.
	
	
		- `-=`, `/=`, `*=`, `=` and more can be used instead `+=` to decrement, multiply, divide, etc.
* I'm not going to post all the 43 commands here. It would help golfing this, but would also help drive me crazy copypasting
* *If 1.9 command blocks would be used, the solution would (at least) use 42 blocks less. If one-letter variables would be used, almost 200 bytes would be saved.*
[Answer]
# OCaml, 51 bytes
```
fun a b c->a*.b*.c/.(b+.c-.a)/.(a+.c-.b)/.(a+.b-.c)
```
Yay, separate operators for floats... 
[Answer]
# [Wonder](https://github.com/wonderlang/wonder), 48 bytes
```
@@@prod[#0#1#2/1- +#1#0#2/1- +#2#0#1/1- +#2#1#0]
```
RIP
Usage:
```
(((@@@prod[#0#1#2/1* * - +#1#0#2- +#2#0#1- +#2#1#0])3)4)5
```
# Explanation
Function calls are costly in Wonder when compared to infix operators in other languages. Because of this, I contained all the terms in an array and got the product of the result instead of multiplying every single term. The code would be equivalent to something like:
```
(a,b,c)=>product([a,b,c,1/(b+c-a),1/(a+c-b),1/(a+b-c)])
```
[Answer]
# [Actually](http://github.com/Mego/Seriously), ~~10~~ 8 bytes
This answer is based on [Dennis's excellent Jelly answer](https://codegolf.stackexchange.com/a/101266/47581). Golfing suggestions welcome! [Try it online!](http://actually.tryitonline.net/#code=O86j4pmAL-KZgsKsz4DDrA&input=WzMsNCw1XQ)
```
;Σ♀/♂¬πì
```
**Ungolfing**
```
     Implicit input [a, b, c].
;    Duplicate [a, b, c].
Σ    sum() to get twice the semiperimeter, 2*s.
♀/   Vectorized divide 2*s by [a, b, c] to get [2*s/a, 2*s/b, 2*s/c].
♂¬   Vectorized subtract 2 to get [2*s/a-2, 2*s/b-2, 2*s/c-2].
π    Get the product of the above to get 8*(s/a-1)*(s/b-1)*(s/c-1).
     This is the same as 8(s-a)(s-b)(s-c)/abc.
ì    Invert to get the aspect ratio, abc/8(s-a)(s-b)(s-c).
     Implicit return.
```
[Answer]
# Java, 38 bytes
```
(a,b,c)->a*b*c/(b+c-a)/(a-b+c)/(a+b-c)
```
## Testing and ungolfed
```
public class Pcg101234 {
  interface F {
    double f(double a, double b, double c);
  }
  public static void main(String[] args) {
    F f = (a,b,c)->a*b*c/(b+c-a)/(a-b+c)/(a+b-c);
    System.out.println(f.f(1,1,1));
    System.out.println(f.f(3,4,5));
    System.out.println(f.f(42,42,3.14));
    System.out.println(f.f(14,6,12));
    System.out.println(f.f(6,12,14));
    System.out.println(f.f(0.5,0.6,0.7));
  }
}
```
[Test it!](http://ideone.com/xNzffQ)
## Output
```
1.0
1.25
6.947606226693615
1.575
1.575
1.09375
```
[Answer]
## [Jellyfish](http://github.com/iatorm/jellyfish), ~~17~~ 16 bytes
*Thanks to Zgarb for saving 1 byte.*
```
p%/*-)/+i
    2%
```
[Try it online!](http://jellyfish.tryitonline.net/#code=cCUvKi0pLytpCiAgICAyJQ&input=WzAuNSAwLjYgMC43XQ)
### Explanation
This is based on the same reciprocal formula as [Dennis's answer](https://codegolf.stackexchange.com/a/101266/8478).
In more traditional functional notation, the above program reads as follows:
```
print(
  1 / fold(
    multiply,
    fold(add, i) / i - 2
  )
)
```
Where `i` is the input list. Note that `fold(multiply, ...)` just computes the product and `fold(add, ...)` the sum, so we can further simplify this to:
```
print(1 / product(sum(i) / i - 2))
```
The `sum(i) / i` is implemented via the hook `)/+` which defines a new unary function to do both steps at once.
[Answer]
# [Dyalog APL](https://dyalog.com/), ~~10~~ 9 [bytes](http://meta.codegolf.stackexchange.com/a/9429/43319)
```
×/⊢÷+/-+⍨
```
This is an anonymous [function train](http://help.dyalog.com/15.0/Content/Language/Introduction/Trains.htm) (an atop of a fork of a fork of a fork), meaning that every sub-function is applied to the argument, inside the following structure:
```
 ┌─┴─┐          
×/ ┌─┼───┐      
   ⊢ ÷ ┌─┼──┐  
      +/ - +⍨
```
[TryAPL online!](http://tryapl.org/?a=AR%u2190%D7/%u22A2%F7+/-+%u2368%20%u22C4%20AR%A8%281%201%201%29%283%204%205%29%2842%2042%203.14%29%2814%206%2012%29%286%2012%2014%29%280.5%200.6%200.7%29&run)
`×/` the product of
`⊢` the arguments
`÷` divided by
`+/` the sum of the arguments
`-` minus
`+⍨` the arguments doubled (lit. added to themselves)
[Mathematical background.](https://www.sharcnet.ca/Software/Ansys/16.2.3/en-us/help/wb_msh/msh_aspect_triangle.html)
ngn shaved a byte.
[Answer]
# [2sable](http://github.com/Adriandmen/2sable), 6 bytes
A port of [Dennis' Jelly answer](https://codegolf.stackexchange.com/a/101266/34388).
```
Os/ÍPz
```
Uses the **CP-1252** encoding. [Try it online!](http://2sable.tryitonline.net/#code=T3Mvw41Qeg&input=WzE0LCA2LCAxMl0)
[Answer]
# dc, 49 bytes
```
5k?dsa?dsb?dsc++2/sslalblc**lsla-lslb-lslc-8***/p
```
A direct implementation of the formula given. Prompts for the three inputs upon invocation on three separate lines and outputs a floating-point value with 5 digits after the decimal point to the next line.
## Explanation
```
5k                                                # Set the output precision to 5 digits after the decimal
  ?dsa                                            # Prompt for first input value on first line, duplicate it, and then store it in register `a`
      ?dsb                                        # Prompt for second input, duplicate it, and store it in register `b`
          ?dsc                                    # Prompt for third input, duplicate it, and store it in register `c`
              ++2/ss                              # Sum up the 3 values on the main stack, then divide sum by 2 and store the result in register `s`
                    lalblc**                      # Copy all three values from registers `a`,`b`,`c` onto the main stack, find their product, and push result to top of main stack
                            lsla-                 # Copy value from register `s` onto main stack, subtract register `a`'s value from it, and push result to main stack
                                 lslb-            # Copy value from register `s` onto main stack, subtract register `b`'s value from it, and push result to main stack
                                      lslc-       # Copy value from register `s` onto main stack, subtract register `c`'s value from it, and push result to main stack
                                           8***   # Find the product of the top three values and 8 and then push the result to main stack
                                               /p # Divide the second to top value (a*b*c) by the top of stack value (8*(s-a)*(s-b)*(s-c)), push the result to the main stack, and then output the result to STDOUT
```
[Answer]
# TI-Basic, 11 bytes
Input should be in the form of a list, like `{A B C}`.
```
prod(Ans)/prod(sum(Ans)-2Ans
```
Maybe this visual will help (remember that `2s = a+b+c`):
```
      abc                    abc                   abc                prod(Ans)
---------------- = --------------------- = ------------------- = -------------------
8(s-a)(s-b)(s-c)   (2s-2a)(2s-2b)(2s-2c)   (a+b+c)(1-2{a,b,c})   prod(sum(Ans)-2Ans)
```
[Answer]
# [Perl 6](https://perl6.org), 44 bytes
```
->\a,\b,\c{a*b*c/(b+c -a)/(a+c -b)/(a+b -c)}
```
[Answer]
# Python, 55 bytes
```
def f(x,y,z):s=x+y+z;return 1/((s/x-2)*(s/y-2)*(s/z-2))
```
[Credit to Dennis](/a/101266/41024). I just ported. In Python, a much-neglected language.
[Answer]
# Forth, 83 bytes
Assumes the floating point parameters start on the floating point stack. Leaves the result on the floating point stack. Using the stack for params/returning is the standard for Forth.
```
: p 3 fpick ;
: T p p p ;
: f 0 s>f T f- f+ f- T f+ f- f* T f- f- f* 1/f f* f* f* ;
```
[**Try it online**](http://ideone.com/lhvmGq) - *contains all test cases*
Uses the formula `a*b*c * 1/ ( -(a+b-c) * -(b+c-a) * (a+c-b) )`. Pretty much the entire program is using only the floating point stack. The exception is the `3` in `3 fpick`. This program requires an interpreter that supports `fpick` (Ideone works, repl.it doesn't).
**Explanation:** *slightly less golfed*
```
\ 3 fpick takes the 3rd element (0-indexed) and pushes a copy
\ Used to copy parameters on the stack over another number 'x' ( a b c x -> a b c x a b c )
: f3p 3 fpick 3 fpick 3 fpick ;
: f                     \ define a function f
0 s>f f3p f- f+ f-      \ push a zero, copy params, compute 0-(a+b-c)
                        \ the zero allows me to copy (I need an 'x' to jump over)
f3p f+ f- f*            \ copy params and compute -(b+c-a), multiply by previous result
                        \ the negatives miraculously cancel
f3p f- f- f*            \ copy and compute (a+c-b), multiply by previous result
1/f f* f* f* ;          \ take the reciprocal and multiply by a*b*c
                        \ the result is left on the floating point stack
```
[Answer]
# [ised](http://ised.sourceforge.net/): 19 bytes
```
@*$1/@*{@+$1-2.*$1}
```
Call it as `ised --l 'inputfile.txt' '@*$1/@*{@+$1-2.*$1}'`
where `inputfile.txt` can be a file with space separated array, or `-` to receive from pipe/stdin.
Unicode version (same bytecount but 3 chars less):
```
Π$1/Π{Σ$1-2.*$1}
```
Unfortunately, `ised` wastes a lot of chars for its input argument syntax.
[Answer]
# vba, 76
```
Function r(a,b,c)
s=(a+b+c)/2:r=(a*b*c)/(8*(s-a)*(s-b)*(s-c))
End Function
```
Call with
> 
> ?r(3,4,5)
> 
> 
> 
or in excel with
> 
> =r(5,12,13)
> 
> 
> 
[Answer]
## C#, 82 bytes
```
void ar(double a,double b,double c)=>Console.Write(a*b*c/(b+c-a)/(a+c-b)/(a+b-c));
```
Usage:
```
ar(42, 42, 3.14);
```
[Answer]
# Pyke, 12 bytes
```
1QFQsR/tt)B/
```
[Try it here!](//pyke.catbus.co.uk?code=1QFQsR%2Ftt%29B%2F&input=%5B.5%2C.6%2C.7%5D)
Well, BlueEyedBeast, you had your chance. I used a [good algorithm](/a/101266/41024) here.
[Answer]
# k, 19 bytes
```
{(*/x)%8*/-x-+/x%2}
```
Evaluates right to left - Divide the list x by 2, sum the result and subtract it from original x. Neg the answer and get the product of the result and 8. The result is the denominator, the numerator is the product of the list.
[Answer]
# Lua, 45 bytes
```
a,b,c=...print(a*b*c/(b+c-a)/(a+c-b)/(a+b-c))
```
Heavily based on the JavaScript answer.
]