Skip to main content
Commonmark migration
Source Link

#Java 8, 113 92 88 82 bytes

Java 8, 113 92 88 82 bytes

(a,b,c,d)->1737*Math.acos(Math.cos(a-c)+Math.cos(a)*Math.cos(c)*(Math.cos(d-b)-1))

Inputs a,b,c,d are ϕ1,λ1,ϕ2,λ2 in radians.

-21 bytes using @miles' shorter formula.
-4 bytes thanks to @OlivierGrégore because I still used {Math m=null;return ...;} with every Math. as m., instead of dropping the return and use Math directly.
-6 bytes using @Neil's shorter formula.

Try it online.

Explanation:

(a,b,c,d)->                  // Method with four double parameters and double return-type
  1737*Math.acos(            //  Return 1737 multiplied with the acos of:
   Math.cos(a-c)             //   the cos of `a` minus `c`,
   +Math.cos(a)*Math.cos(c)  //   plus the cos of `a` multiplied with the cos of `c`
   *(Math.cos(d-b)-1))       //   multiplied with the cos of `d` minus `b` minus 1

#Java 8, 113 92 88 82 bytes

(a,b,c,d)->1737*Math.acos(Math.cos(a-c)+Math.cos(a)*Math.cos(c)*(Math.cos(d-b)-1))

Inputs a,b,c,d are ϕ1,λ1,ϕ2,λ2 in radians.

-21 bytes using @miles' shorter formula.
-4 bytes thanks to @OlivierGrégore because I still used {Math m=null;return ...;} with every Math. as m., instead of dropping the return and use Math directly.
-6 bytes using @Neil's shorter formula.

Try it online.

Explanation:

(a,b,c,d)->                  // Method with four double parameters and double return-type
  1737*Math.acos(            //  Return 1737 multiplied with the acos of:
   Math.cos(a-c)             //   the cos of `a` minus `c`,
   +Math.cos(a)*Math.cos(c)  //   plus the cos of `a` multiplied with the cos of `c`
   *(Math.cos(d-b)-1))       //   multiplied with the cos of `d` minus `b` minus 1

Java 8, 113 92 88 82 bytes

(a,b,c,d)->1737*Math.acos(Math.cos(a-c)+Math.cos(a)*Math.cos(c)*(Math.cos(d-b)-1))

Inputs a,b,c,d are ϕ1,λ1,ϕ2,λ2 in radians.

-21 bytes using @miles' shorter formula.
-4 bytes thanks to @OlivierGrégore because I still used {Math m=null;return ...;} with every Math. as m., instead of dropping the return and use Math directly.
-6 bytes using @Neil's shorter formula.

Try it online.

Explanation:

(a,b,c,d)->                  // Method with four double parameters and double return-type
  1737*Math.acos(            //  Return 1737 multiplied with the acos of:
   Math.cos(a-c)             //   the cos of `a` minus `c`,
   +Math.cos(a)*Math.cos(c)  //   plus the cos of `a` multiplied with the cos of `c`
   *(Math.cos(d-b)-1))       //   multiplied with the cos of `d` minus `b` minus 1
added 156 characters in body
Source Link
Kevin Cruijssen
  • 136.9k
  • 14
  • 158
  • 399

#Java 8, 113 92 8888 82 bytes

(a,b,c,d)->1737*Math.acos(Math.sincos(a)*Math.sin(-c)+Math.cos(a)*Math.cos(c)*Math*(Math.cos(d-b)-1))

Inputs a,b,c,d are ϕ1,λ1,ϕ2,λ2 in radians.

-21 bytes using @miles' shorter formula.
-4 bytes thanks to @OlivierGrégore because I still used {Math m=null;return ...;} with every Math. as m., instead of dropping the return and use Math directly.
-6 bytes using @Neil's shorter formula.

Try it online.Try it online.

Explanation:

(a,b,c,d)->                  // Method with four double parameters and double return-type
  1737*Math.acos(            //  Return 1737 multiplied with the acos of:
   Math.sincos(a)*Math.sin(-c)+  //   the sin of `a` multiplied with   //   the sincos of `a` minus `c`,
   +Math.cos(a)*Math.cos(c)  //   plus the cos of `a` multiplied with the cos of `c`
   *Math*(Math.cos(d-b)-1)    )       //   multiplied with the cos of `d` minus `b` minus 1

#Java 8, 113 92 88 bytes

(a,b,c,d)->1737*Math.acos(Math.sin(a)*Math.sin(c)+Math.cos(a)*Math.cos(c)*Math.cos(d-b))

Inputs a,b,c,d are ϕ1,λ1,ϕ2,λ2 in radians.

-21 bytes using @miles' shorter formula.
-4 bytes thanks to @OlivierGrégore because I still used {Math m=null;return ...;} with every Math. as m., instead of dropping the return and use Math directly.

Try it online.

Explanation:

(a,b,c,d)->                  // Method with four double parameters and double return-type
  1737*Math.acos(            //  Return 1737 multiplied with the acos of:
   Math.sin(a)*Math.sin(c)+  //   the sin of `a` multiplied with the sin of `c`,
   +Math.cos(a)*Math.cos(c)  //   plus the cos of `a` multiplied with the cos of `c`
   *Math.cos(d-b))           //   multiplied with the cos of `d` minus `b`

#Java 8, 113 92 88 82 bytes

(a,b,c,d)->1737*Math.acos(Math.cos(a-c)+Math.cos(a)*Math.cos(c)*(Math.cos(d-b)-1))

Inputs a,b,c,d are ϕ1,λ1,ϕ2,λ2 in radians.

-21 bytes using @miles' shorter formula.
-4 bytes thanks to @OlivierGrégore because I still used {Math m=null;return ...;} with every Math. as m., instead of dropping the return and use Math directly.
-6 bytes using @Neil's shorter formula.

Try it online.

Explanation:

(a,b,c,d)->                  // Method with four double parameters and double return-type
  1737*Math.acos(            //  Return 1737 multiplied with the acos of:
   Math.cos(a-c)             //   the cos of `a` minus `c`,
   +Math.cos(a)*Math.cos(c)  //   plus the cos of `a` multiplied with the cos of `c`
   *(Math.cos(d-b)-1))       //   multiplied with the cos of `d` minus `b` minus 1
added 613 characters in body
Source Link
Kevin Cruijssen
  • 136.9k
  • 14
  • 158
  • 399

#Java 8, 113 9292 88 bytes

(a,b,c,d)->{Math m=null;return 1737*m>1737*Math.acos(mMath.sin(a)*m*Math.sin(c)+m+Math.cos(a)*m*Math.cos(c)*m*Math.cos(d-b));}

Inputs a,b,c,d are ϕ1,λ1,ϕ2,λ2 in radians.

-21 bytes using @miles' shorter formula.
Input-4 bytes thanks to @OlivierGrégore because I still used {Math m=null;return ...;} with every Math. as radiansm., instead of dropping the return and use Math directly.

Try it online.Try it online.

Explanation:

(a,b,c,d)->                  // Method with four double parameters and double return-type
  1737*Math.acos(            //  Return 1737 multiplied with the acos of:
   Math.sin(a)*Math.sin(c)+  //   the sin of `a` multiplied with the sin of `c`,
   +Math.cos(a)*Math.cos(c)  //   plus the cos of `a` multiplied with the cos of `c`
   *Math.cos(d-b))           //   multiplied with the cos of `d` minus `b`

#Java 8, 113 92 bytes

(a,b,c,d)->{Math m=null;return 1737*m.acos(m.sin(a)*m.sin(c)+m.cos(a)*m.cos(c)*m.cos(d-b));}

-21 bytes using @miles' shorter formula.
Input as radians.

Try it online.

#Java 8, 113 92 88 bytes

(a,b,c,d)->1737*Math.acos(Math.sin(a)*Math.sin(c)+Math.cos(a)*Math.cos(c)*Math.cos(d-b))

Inputs a,b,c,d are ϕ1,λ1,ϕ2,λ2 in radians.

-21 bytes using @miles' shorter formula.
-4 bytes thanks to @OlivierGrégore because I still used {Math m=null;return ...;} with every Math. as m., instead of dropping the return and use Math directly.

Try it online.

Explanation:

(a,b,c,d)->                  // Method with four double parameters and double return-type
  1737*Math.acos(            //  Return 1737 multiplied with the acos of:
   Math.sin(a)*Math.sin(c)+  //   the sin of `a` multiplied with the sin of `c`,
   +Math.cos(a)*Math.cos(c)  //   plus the cos of `a` multiplied with the cos of `c`
   *Math.cos(d-b))           //   multiplied with the cos of `d` minus `b`
added 59 characters in body
Source Link
Kevin Cruijssen
  • 136.9k
  • 14
  • 158
  • 399
Loading
Source Link
Kevin Cruijssen
  • 136.9k
  • 14
  • 158
  • 399
Loading