Skip to main content
deleted 28 characters in body
Source Link
xnor
  • 150k
  • 26
  • 290
  • 678

Python 3, 64 bytes

lambda*t:eval("+((-(%s-%s)**2+%s**2)/%s/%s)**.5"*3%(t*5))*sum(t)

Try it online!

Uses an adaptation of a formula by Surculose Sputumby Surculose Sputum, written so that the variables a,b,c repeat in a cycle when the formula is read left to right.

+((-(a-b)**2+c**2)/a/b)**.5+((-(c-a)**2+b**2)/c/a)**.5+((-(b-c)**2+a**2)/b/c)**.5

This lets us insert the input values into the formula as literals by string interpolation on the tuple (a,b,c) repeated 5 times, and then call eval to evaluate the resulting expression.


Python 3, 76 bytes

lambda a,b,c:sum((2-(a*a+b*b+c*c-2*x*x)*x/a/b/c)**.5*(a+b+c)for x in[a,b,c])

Try it online!

I took Surculose Sputum's formula and solutionSurculose Sputum's formula and solution and wrote the three summands in a closer-to-symmetric form like:

$$(a+b+c)\sqrt{2-\frac{a^2+b^2-c^2}{ab}}$$

The idea is that we want the summand to be as symmetric in \$a,b,c\$ as possible so that we can iterate a single variable \$x\$ over \$a,b,c\$ to produce each summand.

To this end, we write the core term $$\frac{a^2+b^2-c^2}{ab}$$ as the somewhat clunky

$$\frac{a^2+b^2+c^2-2c^2}{abc}\cdot c$$

so that we can write it in this symmetric form:

$$\frac{a^2+b^2+c^2-2x^2}{abc}\cdot x$$

Substituting \$x=a\$, \$x=b\$, and \$x=c\$ gives the three respective summands.

Perhaps there's a better way to put this fraction into a near-symmetric form than doing so for the numerator and denominator individually. We can split it up as $$a/b+b/a-c^2/(ab)$$ but I don't see where to go from there.

Python 3, 64 bytes

lambda*t:eval("+((-(%s-%s)**2+%s**2)/%s/%s)**.5"*3%(t*5))*sum(t)

Try it online!

Uses an adaptation of a formula by Surculose Sputum, written so that the variables a,b,c repeat in a cycle when the formula is read left to right.

+((-(a-b)**2+c**2)/a/b)**.5+((-(c-a)**2+b**2)/c/a)**.5+((-(b-c)**2+a**2)/b/c)**.5

This lets us insert the input values into the formula as literals by string interpolation on the tuple (a,b,c) repeated 5 times, and then call eval to evaluate the resulting expression.


Python 3, 76 bytes

lambda a,b,c:sum((2-(a*a+b*b+c*c-2*x*x)*x/a/b/c)**.5*(a+b+c)for x in[a,b,c])

Try it online!

I took Surculose Sputum's formula and solution and wrote the three summands in a closer-to-symmetric form like:

$$(a+b+c)\sqrt{2-\frac{a^2+b^2-c^2}{ab}}$$

The idea is that we want the summand to be as symmetric in \$a,b,c\$ as possible so that we can iterate a single variable \$x\$ over \$a,b,c\$ to produce each summand.

To this end, we write the core term $$\frac{a^2+b^2-c^2}{ab}$$ as the somewhat clunky

$$\frac{a^2+b^2+c^2-2c^2}{abc}\cdot c$$

so that we can write it in this symmetric form:

$$\frac{a^2+b^2+c^2-2x^2}{abc}\cdot x$$

Substituting \$x=a\$, \$x=b\$, and \$x=c\$ gives the three respective summands.

Perhaps there's a better way to put this fraction into a near-symmetric form than doing so for the numerator and denominator individually. We can split it up as $$a/b+b/a-c^2/(ab)$$ but I don't see where to go from there.

Python 3, 64 bytes

lambda*t:eval("+((-(%s-%s)**2+%s**2)/%s/%s)**.5"*3%(t*5))*sum(t)

Try it online!

Uses an adaptation of a formula by Surculose Sputum, written so that the variables a,b,c repeat in a cycle when the formula is read left to right.

+((-(a-b)**2+c**2)/a/b)**.5+((-(c-a)**2+b**2)/c/a)**.5+((-(b-c)**2+a**2)/b/c)**.5

This lets us insert the input values into the formula as literals by string interpolation on the tuple (a,b,c) repeated 5 times, and then call eval to evaluate the resulting expression.


Python 3, 76 bytes

lambda a,b,c:sum((2-(a*a+b*b+c*c-2*x*x)*x/a/b/c)**.5*(a+b+c)for x in[a,b,c])

Try it online!

I took Surculose Sputum's formula and solution and wrote the three summands in a closer-to-symmetric form like:

$$(a+b+c)\sqrt{2-\frac{a^2+b^2-c^2}{ab}}$$

The idea is that we want the summand to be as symmetric in \$a,b,c\$ as possible so that we can iterate a single variable \$x\$ over \$a,b,c\$ to produce each summand.

To this end, we write the core term $$\frac{a^2+b^2-c^2}{ab}$$ as the somewhat clunky

$$\frac{a^2+b^2+c^2-2c^2}{abc}\cdot c$$

so that we can write it in this symmetric form:

$$\frac{a^2+b^2+c^2-2x^2}{abc}\cdot x$$

Substituting \$x=a\$, \$x=b\$, and \$x=c\$ gives the three respective summands.

Perhaps there's a better way to put this fraction into a near-symmetric form than doing so for the numerator and denominator individually. We can split it up as $$a/b+b/a-c^2/(ab)$$ but I don't see where to go from there.

added 56 characters in body
Source Link
xnor
  • 150k
  • 26
  • 290
  • 678

Python 3, 7564 bytes

lambda a,b,clambda*t:eval("+((-(%s-%s)**2+%s**2)/%s/%s)**.5"*3%(*'abc'*5,t*5))**sum(a+b+ct)

Try it online!Try it online!

Generates and evaluates the below expression (adaptedUses an adaptation of a formula fromby Surculose Sputum), in whichwritten so that the variables cycle in a repeating a,b,c fromrepeat in a cycle when the expressionformula is read left to right. This lets us insert them nicely with string formatting.

+((-(a-b)**2+c**2)/a/b)**.5+((-(c-a)**2+b**2)/c/a)**.5+((-(b-c)**2+a**2)/b/c)**.5

This lets us insert the input values into the formula as literals by string interpolation on the tuple (a,b,c) repeated 5 times, and then call eval to evaluate the resulting expression.


Python 3, 76 bytes

lambda a,b,c:sum((2-(a*a+b*b+c*c-2*x*x)*x/a/b/c)**.5*(a+b+c)for x in[a,b,c])

Try it online!

I took Surculose Sputum's formula and solution and wrote the three summands in a closer-to-symmetric form like:

$$(a+b+c)\sqrt{2-\frac{a^2+b^2-c^2}{ab}}$$

The idea is that we want the summand to be as symmetric in \$a,b,c\$ as possible so that we can iterate a single variable \$x\$ over \$a,b,c\$ to produce each summand.

To this end, we write the core term $$\frac{a^2+b^2-c^2}{ab}$$ as the somewhat clunky

$$\frac{a^2+b^2+c^2-2c^2}{abc}\cdot c$$

so that we can write it in this symmetric form:

$$\frac{a^2+b^2+c^2-2x^2}{abc}\cdot x$$

Substituting \$x=a\$, \$x=b\$, and \$x=c\$ gives the three respective summands.

Perhaps there's a better way to put this fraction into a near-symmetric form than doing so for the numerator and denominator individually. We can split it up as $$a/b+b/a-c^2/(ab)$$ but I don't see where to go from there.

Python 3, 75 bytes

lambda a,b,c:eval("+((-(%s-%s)**2+%s**2)/%s/%s)**.5"*3%(*'abc'*5,))*(a+b+c)

Try it online!

Generates and evaluates the below expression (adapted from Surculose Sputum), in which the variables cycle in a repeating a,b,c from when the expression is read left to right. This lets us insert them nicely with string formatting.

+((-(a-b)**2+c**2)/a/b)**.5+((-(c-a)**2+b**2)/c/a)**.5+((-(b-c)**2+a**2)/b/c)**.5

Python 3, 76 bytes

lambda a,b,c:sum((2-(a*a+b*b+c*c-2*x*x)*x/a/b/c)**.5*(a+b+c)for x in[a,b,c])

Try it online!

I took Surculose Sputum's formula and solution and wrote the three summands in a closer-to-symmetric form like:

$$(a+b+c)\sqrt{2-\frac{a^2+b^2-c^2}{ab}}$$

The idea is that we want the summand to be as symmetric in \$a,b,c\$ as possible so that we can iterate a single variable \$x\$ over \$a,b,c\$ to produce each summand.

To this end, we write the core term $$\frac{a^2+b^2-c^2}{ab}$$ as the somewhat clunky

$$\frac{a^2+b^2+c^2-2c^2}{abc}\cdot c$$

so that we can write it in this symmetric form:

$$\frac{a^2+b^2+c^2-2x^2}{abc}\cdot x$$

Substituting \$x=a\$, \$x=b\$, and \$x=c\$ gives the three respective summands.

Perhaps there's a better way to put this fraction into a near-symmetric form than doing so for the numerator and denominator individually. We can split it up as $$a/b+b/a-c^2/(ab)$$ but I don't see where to go from there.

Python 3, 64 bytes

lambda*t:eval("+((-(%s-%s)**2+%s**2)/%s/%s)**.5"*3%(t*5))*sum(t)

Try it online!

Uses an adaptation of a formula by Surculose Sputum, written so that the variables a,b,c repeat in a cycle when the formula is read left to right.

+((-(a-b)**2+c**2)/a/b)**.5+((-(c-a)**2+b**2)/c/a)**.5+((-(b-c)**2+a**2)/b/c)**.5

This lets us insert the input values into the formula as literals by string interpolation on the tuple (a,b,c) repeated 5 times, and then call eval to evaluate the resulting expression.


Python 3, 76 bytes

lambda a,b,c:sum((2-(a*a+b*b+c*c-2*x*x)*x/a/b/c)**.5*(a+b+c)for x in[a,b,c])

Try it online!

I took Surculose Sputum's formula and solution and wrote the three summands in a closer-to-symmetric form like:

$$(a+b+c)\sqrt{2-\frac{a^2+b^2-c^2}{ab}}$$

The idea is that we want the summand to be as symmetric in \$a,b,c\$ as possible so that we can iterate a single variable \$x\$ over \$a,b,c\$ to produce each summand.

To this end, we write the core term $$\frac{a^2+b^2-c^2}{ab}$$ as the somewhat clunky

$$\frac{a^2+b^2+c^2-2c^2}{abc}\cdot c$$

so that we can write it in this symmetric form:

$$\frac{a^2+b^2+c^2-2x^2}{abc}\cdot x$$

Substituting \$x=a\$, \$x=b\$, and \$x=c\$ gives the three respective summands.

Perhaps there's a better way to put this fraction into a near-symmetric form than doing so for the numerator and denominator individually. We can split it up as $$a/b+b/a-c^2/(ab)$$ but I don't see where to go from there.

added 972 characters in body
Source Link
xnor
  • 150k
  • 26
  • 290
  • 678

Python 3, 75 bytes

lambda a,b,c:eval("+((-(%s-%s)**2+%s**2)/%s/%s)**.5"*3%(*'abc'*5,))*(a+b+c)

Try it online!

Generates and evaluates the below expression (adapted from Surculose Sputum), in which the variables cycle in a repeating a,b,c from when the expression is read left to right. This lets us insert them nicely with string formatting.

+((-(a-b)**2+c**2)/a/b)**.5+((-(c-a)**2+b**2)/c/a)**.5+((-(b-c)**2+a**2)/b/c)**.5

Python 3, 76 bytes

lambda a,b,c:sum((2-(a*a+b*b+c*c-2*x*x)*x/a/b/c)**.5*(a+b+c)for x in[a,b,c])

Try it online!

I took Surculose Sputum's formula and solution and wrote the three summands in a closer-to-symmetric form like:

$$(a+b+c)\sqrt{2-\frac{a^2+b^2-c^2}{ab}}$$

The idea is that we want the summand to be as symmetric in \$a,b,c\$ as possible so that we can iterate a single variable \$x\$ over \$a,b,c\$ to produce each summand.

To this end, we write the core term $$\frac{a^2+b^2-c^2}{ab}$$ as the somewhat clunky

$$\frac{a^2+b^2+c^2-2c^2}{abc}\cdot c$$

so that we can write it in this symmetric form:

$$\frac{a^2+b^2+c^2-2x^2}{abc}\cdot x$$

Substituting \$x=a\$, \$x=b\$, and \$x=c\$ gives the three respective summands.

Perhaps there's a better way to put this fraction into a near-symmetric form than doing so for the numerator and denominator individually. We can split it up as $$a/b+b/a-c^2/(ab)$$ but I don't see where to go from there.

Python 3, 76 bytes

lambda a,b,c:sum((2-(a*a+b*b+c*c-2*x*x)*x/a/b/c)**.5*(a+b+c)for x in[a,b,c])

Try it online!

I took Surculose Sputum's formula and solution and wrote the three summands in a closer-to-symmetric form like:

$$(a+b+c)\sqrt{2-\frac{a^2+b^2-c^2}{ab}}$$

The idea is that we want the summand to be as symmetric in \$a,b,c\$ as possible so that we can iterate a single variable \$x\$ over \$a,b,c\$ to produce each summand.

To this end, we write the core term $$\frac{a^2+b^2-c^2}{ab}$$ as the somewhat clunky

$$\frac{a^2+b^2+c^2-2c^2}{abc}\cdot c$$

so that we can write it in this symmetric form:

$$\frac{a^2+b^2+c^2-2x^2}{abc}\cdot x$$

Substituting \$x=a\$, \$x=b\$, and \$x=c\$ gives the three respective summands.

Perhaps there's a better way to put this fraction into a near-symmetric form than doing so for the numerator and denominator individually. We can split it up as $$a/b+b/a-c^2/(ab)$$ but I don't see where to go from there.

Python 3, 75 bytes

lambda a,b,c:eval("+((-(%s-%s)**2+%s**2)/%s/%s)**.5"*3%(*'abc'*5,))*(a+b+c)

Try it online!

Generates and evaluates the below expression (adapted from Surculose Sputum), in which the variables cycle in a repeating a,b,c from when the expression is read left to right. This lets us insert them nicely with string formatting.

+((-(a-b)**2+c**2)/a/b)**.5+((-(c-a)**2+b**2)/c/a)**.5+((-(b-c)**2+a**2)/b/c)**.5

Python 3, 76 bytes

lambda a,b,c:sum((2-(a*a+b*b+c*c-2*x*x)*x/a/b/c)**.5*(a+b+c)for x in[a,b,c])

Try it online!

I took Surculose Sputum's formula and solution and wrote the three summands in a closer-to-symmetric form like:

$$(a+b+c)\sqrt{2-\frac{a^2+b^2-c^2}{ab}}$$

The idea is that we want the summand to be as symmetric in \$a,b,c\$ as possible so that we can iterate a single variable \$x\$ over \$a,b,c\$ to produce each summand.

To this end, we write the core term $$\frac{a^2+b^2-c^2}{ab}$$ as the somewhat clunky

$$\frac{a^2+b^2+c^2-2c^2}{abc}\cdot c$$

so that we can write it in this symmetric form:

$$\frac{a^2+b^2+c^2-2x^2}{abc}\cdot x$$

Substituting \$x=a\$, \$x=b\$, and \$x=c\$ gives the three respective summands.

Perhaps there's a better way to put this fraction into a near-symmetric form than doing so for the numerator and denominator individually. We can split it up as $$a/b+b/a-c^2/(ab)$$ but I don't see where to go from there.

added 665 characters in body
Source Link
xnor
  • 150k
  • 26
  • 290
  • 678
Loading
Source Link
xnor
  • 150k
  • 26
  • 290
  • 678
Loading