Skip to main content
Commonmark migration
Source Link

#JavaScript (ES7),  80 74 66  65 bytes

JavaScript (ES7),  80 74 66  65 bytes

(a,b,c)=>(s=a+b+c,(p=a*b*c/s)*p/4*(s/=2)/(s-a)/(s-b)/(s-c)-p)**.5

Try it online!

###How?

How?

This is derived from:

  • The semiperimeter \$s\$ of the triangle:

    The semiperimeter \$s\$ of the triangle:

    $$s=\frac{a+b+c}{2}$$

$$s=\frac{a+b+c}{2}$$

  • The circumradius \$R\$ of the triangle:

    The circumradius \$R\$ of the triangle:

    $$R=\frac{abc}{4\sqrt{s(s-a)(s-b)(s-c)}}$$

$$R=\frac{abc}{4\sqrt{s(s-a)(s-b)(s-c)}}$$

  • The product of the inradius \$r\$ and the circumradius:

    The product of the inradius \$r\$ and the circumradius:

    $$rR=\frac{abc}{2(a+b+c)}=\frac{abc}{4s}$$

$$rR=\frac{abc}{2(a+b+c)}=\frac{abc}{4s}$$

  • Euler's theorem:

    Euler's theorem:

    $$d=\sqrt{R(R-2r)}=\sqrt{R^2-2rR}=\sqrt{R^2-\frac{abc}{2s}}$$

$$d=\sqrt{R(R-2r)}=\sqrt{R^2-2rR}=\sqrt{R^2-\frac{abc}{2s}}$$

#JavaScript (ES7),  80 74 66  65 bytes

(a,b,c)=>(s=a+b+c,(p=a*b*c/s)*p/4*(s/=2)/(s-a)/(s-b)/(s-c)-p)**.5

Try it online!

###How?

This is derived from:

  • The semiperimeter \$s\$ of the triangle:

$$s=\frac{a+b+c}{2}$$

  • The circumradius \$R\$ of the triangle:

$$R=\frac{abc}{4\sqrt{s(s-a)(s-b)(s-c)}}$$

  • The product of the inradius \$r\$ and the circumradius:

$$rR=\frac{abc}{2(a+b+c)}=\frac{abc}{4s}$$

  • Euler's theorem:

$$d=\sqrt{R(R-2r)}=\sqrt{R^2-2rR}=\sqrt{R^2-\frac{abc}{2s}}$$

JavaScript (ES7),  80 74 66  65 bytes

(a,b,c)=>(s=a+b+c,(p=a*b*c/s)*p/4*(s/=2)/(s-a)/(s-b)/(s-c)-p)**.5

Try it online!

How?

This is derived from:

  • The semiperimeter \$s\$ of the triangle:

    $$s=\frac{a+b+c}{2}$$

  • The circumradius \$R\$ of the triangle:

    $$R=\frac{abc}{4\sqrt{s(s-a)(s-b)(s-c)}}$$

  • The product of the inradius \$r\$ and the circumradius:

    $$rR=\frac{abc}{2(a+b+c)}=\frac{abc}{4s}$$

  • Euler's theorem:

    $$d=\sqrt{R(R-2r)}=\sqrt{R^2-2rR}=\sqrt{R^2-\frac{abc}{2s}}$$

saved 1 byte
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 649

#JavaScript (ES7),  80 74 66  6665 bytes

(a,b,c)=>(s=(a+b+c)/2s=a+b+c,(p=a*b*c/2s)*p/4/4*(s/=2)/(s-a)/(s-b)/(s-c)-p/s)**.5

Try it online!Try it online!

###How?

This is derived from:

  • The semiperimeter \$s\$ of the triangle:

$$s=\frac{a+b+c}{2}$$

  • The circumradius \$R\$ of the triangle:

$$R=\frac{abc}{4\sqrt{s(s-a)(s-b)(s-c)}}$$

  • The product of the inradius \$r\$ and the circumradius:

$$rR=\frac{abc}{2(a+b+c)}=\frac{abc}{4s}$$

  • Euler's theorem:

$$d=\sqrt{R(R-2r)}=\sqrt{R^2-2rR}=\sqrt{R^2-\frac{abc}{2s}}$$

#JavaScript (ES7),  80 74  66 bytes

(a,b,c)=>(s=(a+b+c)/2,(p=a*b*c/2)*p/4/s/(s-a)/(s-b)/(s-c)-p/s)**.5

Try it online!

###How?

This is derived from:

  • The semiperimeter \$s\$ of the triangle:

$$s=\frac{a+b+c}{2}$$

  • The circumradius \$R\$ of the triangle:

$$R=\frac{abc}{4\sqrt{s(s-a)(s-b)(s-c)}}$$

  • The product of the inradius \$r\$ and the circumradius:

$$rR=\frac{abc}{2(a+b+c)}=\frac{abc}{4s}$$

  • Euler's theorem:

$$d=\sqrt{R(R-2r)}=\sqrt{R^2-2rR}=\sqrt{R^2-\frac{abc}{2s}}$$

#JavaScript (ES7),  80 74 66  65 bytes

(a,b,c)=>(s=a+b+c,(p=a*b*c/s)*p/4*(s/=2)/(s-a)/(s-b)/(s-c)-p)**.5

Try it online!

###How?

This is derived from:

  • The semiperimeter \$s\$ of the triangle:

$$s=\frac{a+b+c}{2}$$

  • The circumradius \$R\$ of the triangle:

$$R=\frac{abc}{4\sqrt{s(s-a)(s-b)(s-c)}}$$

  • The product of the inradius \$r\$ and the circumradius:

$$rR=\frac{abc}{2(a+b+c)}=\frac{abc}{4s}$$

  • Euler's theorem:

$$d=\sqrt{R(R-2r)}=\sqrt{R^2-2rR}=\sqrt{R^2-\frac{abc}{2s}}$$

removed the original answer and updated the explanation
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 649

#JavaScript (ES7),  80 74  66 bytes

(a,b,c)=>(s=(a+b+c)/2,(p=a*b*c/2)*p/4/s/(s-a)/(s-b)/(s-c)-p/s)**.5

Try it online!


 

#JavaScript (ES7),  80  74 bytes

(a,b,c)=>((b*=a*c/(k=((b+c-a)*(c+a-b)*(a+b-c)/(a+=b+c))**.5)/a)*(b-k))**.5

Try it online!

###How?

This is derived from:

  • The inradiussemiperimeter \$s\$ of the triangle:

$$r=\frac{1}{2}\sqrt{\frac{(b+c-a)(c+a-b)(a+b-c)}{a+b+c}}$$$$s=\frac{a+b+c}{2}$$

  • The circumradius \$R\$ of the triangle:

$$R=\frac{abc}{\sqrt{(a+b+c)(b+c-a)(c+a-b)(a+b-c)}}$$$$R=\frac{abc}{4\sqrt{s(s-a)(s-b)(s-c)}}$$

  • Euler's theoremThe product of the inradius \$r\$ and the circumradius:

$$d=\sqrt{R(R-2r)}$$

By setting:

$$k=\sqrt{\frac{(b+c-a)(c+a-b)(a+b-c)}{a+b+c}}$$$$rR=\frac{abc}{2(a+b+c)}=\frac{abc}{4s}$$

we have:

  • Euler's theorem:

$$R=\frac{abc}{k(a+b+c)}$$ $$d=\sqrt{R(R-k)}$$$$d=\sqrt{R(R-2r)}=\sqrt{R^2-2rR}=\sqrt{R^2-\frac{abc}{2s}}$$

#JavaScript (ES7), 66 bytes

(a,b,c)=>(s=(a+b+c)/2,(p=a*b*c/2)*p/4/s/(s-a)/(s-b)/(s-c)-p/s)**.5

Try it online!


 

#JavaScript (ES7),  80  74 bytes

(a,b,c)=>((b*=a*c/(k=((b+c-a)*(c+a-b)*(a+b-c)/(a+=b+c))**.5)/a)*(b-k))**.5

Try it online!

###How?

This is derived from:

  • The inradius of the triangle:

$$r=\frac{1}{2}\sqrt{\frac{(b+c-a)(c+a-b)(a+b-c)}{a+b+c}}$$

  • The circumradius of the triangle:

$$R=\frac{abc}{\sqrt{(a+b+c)(b+c-a)(c+a-b)(a+b-c)}}$$

  • Euler's theorem:

$$d=\sqrt{R(R-2r)}$$

By setting:

$$k=\sqrt{\frac{(b+c-a)(c+a-b)(a+b-c)}{a+b+c}}$$

we have:

$$R=\frac{abc}{k(a+b+c)}$$ $$d=\sqrt{R(R-k)}$$

#JavaScript (ES7),  80 74  66 bytes

(a,b,c)=>(s=(a+b+c)/2,(p=a*b*c/2)*p/4/s/(s-a)/(s-b)/(s-c)-p/s)**.5

Try it online!

###How?

This is derived from:

  • The semiperimeter \$s\$ of the triangle:

$$s=\frac{a+b+c}{2}$$

  • The circumradius \$R\$ of the triangle:

$$R=\frac{abc}{4\sqrt{s(s-a)(s-b)(s-c)}}$$

  • The product of the inradius \$r\$ and the circumradius:

$$rR=\frac{abc}{2(a+b+c)}=\frac{abc}{4s}$$

  • Euler's theorem:

$$d=\sqrt{R(R-2r)}=\sqrt{R^2-2rR}=\sqrt{R^2-\frac{abc}{2s}}$$

added a shorter version
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 649
Loading
added an explanation
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 649
Loading
saved 6 bytes
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 649
Loading
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 649
Loading