Average Error: 24.9 → 14.2
Time: 1.7min
Precision: binary64
Cost: 151360
\[R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}}{\sqrt{1 - \left({\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right) \]
\[\begin{array}{l} t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_1 := {\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\\ R \cdot \left(2 \cdot \tan^{-1}_* \frac{\mathsf{log1p}\left(\mathsf{expm1}\left(\sqrt{\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right) + t_1}\right)\right)}{\sqrt{1 - \left(t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right) + t_1\right)}}\right) \end{array} \]
(FPCore (R lambda1 lambda2 phi1 phi2)
 :precision binary64
 (*
  R
  (*
   2.0
   (atan2
    (sqrt
     (+
      (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
      (*
       (* (* (cos phi1) (cos phi2)) (sin (/ (- lambda1 lambda2) 2.0)))
       (sin (/ (- lambda1 lambda2) 2.0)))))
    (sqrt
     (-
      1.0
      (+
       (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
       (*
        (* (* (cos phi1) (cos phi2)) (sin (/ (- lambda1 lambda2) 2.0)))
        (sin (/ (- lambda1 lambda2) 2.0))))))))))
(FPCore (R lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
        (t_1
         (pow
          (-
           (* (sin (* phi1 0.5)) (cos (* 0.5 phi2)))
           (* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
          2.0)))
   (*
    R
    (*
     2.0
     (atan2
      (log1p
       (expm1
        (sqrt
         (+
          (*
           (cos phi1)
           (* (cos phi2) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0)))
          t_1))))
      (sqrt (- 1.0 (+ (* t_0 (* (* (cos phi1) (cos phi2)) t_0)) t_1))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * sin(((lambda1 - lambda2) / 2.0))) * sin(((lambda1 - lambda2) / 2.0))))), sqrt((1.0 - (pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * sin(((lambda1 - lambda2) / 2.0))) * sin(((lambda1 - lambda2) / 2.0))))))));
}
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = sin(((lambda1 - lambda2) / 2.0));
	double t_1 = pow(((sin((phi1 * 0.5)) * cos((0.5 * phi2))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 2.0);
	return R * (2.0 * atan2(log1p(expm1(sqrt(((cos(phi1) * (cos(phi2) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0))) + t_1)))), sqrt((1.0 - ((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + t_1)))));
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * Math.sin(((lambda1 - lambda2) / 2.0))) * Math.sin(((lambda1 - lambda2) / 2.0))))), Math.sqrt((1.0 - (Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * Math.sin(((lambda1 - lambda2) / 2.0))) * Math.sin(((lambda1 - lambda2) / 2.0))))))));
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
	double t_1 = Math.pow(((Math.sin((phi1 * 0.5)) * Math.cos((0.5 * phi2))) - (Math.cos((phi1 * 0.5)) * Math.sin((0.5 * phi2)))), 2.0);
	return R * (2.0 * Math.atan2(Math.log1p(Math.expm1(Math.sqrt(((Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0))) + t_1)))), Math.sqrt((1.0 - ((t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)) + t_1)))));
}
def code(R, lambda1, lambda2, phi1, phi2):
	return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * math.sin(((lambda1 - lambda2) / 2.0))) * math.sin(((lambda1 - lambda2) / 2.0))))), math.sqrt((1.0 - (math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * math.sin(((lambda1 - lambda2) / 2.0))) * math.sin(((lambda1 - lambda2) / 2.0))))))))
def code(R, lambda1, lambda2, phi1, phi2):
	t_0 = math.sin(((lambda1 - lambda2) / 2.0))
	t_1 = math.pow(((math.sin((phi1 * 0.5)) * math.cos((0.5 * phi2))) - (math.cos((phi1 * 0.5)) * math.sin((0.5 * phi2)))), 2.0)
	return R * (2.0 * math.atan2(math.log1p(math.expm1(math.sqrt(((math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0))) + t_1)))), math.sqrt((1.0 - ((t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) + t_1)))))
function code(R, lambda1, lambda2, phi1, phi2)
	return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * sin(Float64(Float64(lambda1 - lambda2) / 2.0))) * sin(Float64(Float64(lambda1 - lambda2) / 2.0))))), sqrt(Float64(1.0 - Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * sin(Float64(Float64(lambda1 - lambda2) / 2.0))) * sin(Float64(Float64(lambda1 - lambda2) / 2.0)))))))))
end
function code(R, lambda1, lambda2, phi1, phi2)
	t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0))
	t_1 = Float64(Float64(sin(Float64(phi1 * 0.5)) * cos(Float64(0.5 * phi2))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2)))) ^ 2.0
	return Float64(R * Float64(2.0 * atan(log1p(expm1(sqrt(Float64(Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0))) + t_1)))), sqrt(Float64(1.0 - Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + t_1))))))
end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Log[1 + N[(Exp[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}}{\sqrt{1 - \left({\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right)
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\mathsf{log1p}\left(\mathsf{expm1}\left(\sqrt{\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right) + t_1}\right)\right)}{\sqrt{1 - \left(t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right) + t_1\right)}}\right)
\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 24.9

    \[R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}}{\sqrt{1 - \left({\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right) \]
  2. Applied egg-rr24.3

    \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\color{blue}{\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot 0.5\right)\right)}}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}}{\sqrt{1 - \left({\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right) \]
  3. Applied egg-rr14.2

    \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot 0.5\right)\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}}{\sqrt{1 - \left({\color{blue}{\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot 0.5\right)\right)}}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right) \]
  4. Applied egg-rr14.2

    \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\sqrt{{\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2} + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right)}\right)\right)}}{\sqrt{1 - \left({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot 0.5\right)\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right) \]
  5. Final simplification14.2

    \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\mathsf{log1p}\left(\mathsf{expm1}\left(\sqrt{\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right) + {\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}\right)\right)}{\sqrt{1 - \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) + {\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right) \]

Alternatives

Alternative 1
Error14.2
Cost138880
\[\begin{array}{l} t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_1 := t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right) + {\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\\ R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1}}{\sqrt{1 - t_1}}\right) \end{array} \]
Alternative 2
Error15.6
Cost138697
\[\begin{array}{l} t_0 := \cos \phi_1 \cdot \cos \phi_2\\ t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_2 := {\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\\ t_3 := \sqrt{1 - \left(t_1 \cdot \left(t_0 \cdot t_1\right) + t_2\right)}\\ \mathbf{if}\;\lambda_1 \leq -3.15 \cdot 10^{-6} \lor \neg \left(\lambda_1 \leq 3.3 \cdot 10^{+28}\right):\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot \left(\cos \phi_1 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}\right) + t_2}}{t_3}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2} + t_2}}{t_3}\right)\\ \end{array} \]
Alternative 3
Error15.6
Cost138697
\[\begin{array}{l} t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_1 := \cos \phi_1 \cdot \cos \phi_2\\ t_2 := {\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\\ t_3 := t_0 \cdot \left(t_1 \cdot t_0\right) + t_2\\ \mathbf{if}\;\lambda_1 \leq -2.5 \cdot 10^{-6} \lor \neg \left(\lambda_1 \leq 3.3 \cdot 10^{+28}\right):\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_3}}{\sqrt{1 - \left(\cos \phi_2 \cdot \left(\cos \phi_1 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}\right) + t_2\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2} + t_2}}{\sqrt{1 - t_3}}\right)\\ \end{array} \]
Alternative 4
Error19.4
Cost138696
\[\begin{array}{l} t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_1 := \cos \phi_1 \cdot \cos \phi_2\\ t_2 := t_0 \cdot \left(t_1 \cdot t_0\right)\\ t_3 := {\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\\ t_4 := t_2 + t_3\\ t_5 := \sqrt{t_4}\\ \mathbf{if}\;\lambda_2 \leq -3.5 \cdot 10^{-119}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_5}{\sqrt{1 + \left(\frac{\cos \left(\phi_1 - \phi_2\right) + -1}{2} - t_2\right)}}\right)\\ \mathbf{elif}\;\lambda_2 \leq 1.2 \cdot 10^{-9}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot \left(\cos \phi_1 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}\right) + t_3}}{\sqrt{1 - t_4}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_5}{\sqrt{{\left(\sqrt[3]{1 - \mathsf{fma}\left(t_1, {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}\right)}^{3}}}\right)\\ \end{array} \]
Alternative 5
Error24.3
Cost112704
\[\begin{array}{l} t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_1 := t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)\\ R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + {\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 + \left(\frac{\cos \left(\phi_1 - \phi_2\right) + -1}{2} - t_1\right)}}\right) \end{array} \]
Alternative 6
Error24.9
Cost92864
\[\begin{array}{l} t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_1 := t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)\\ R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 + \left(\frac{\cos \left(\phi_1 - \phi_2\right) + -1}{2} - t_1\right)}}\right) \end{array} \]
Alternative 7
Error24.3
Cost92360
\[\begin{array}{l} t_0 := {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\\ t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_2 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\ t_3 := \cos \phi_2 \cdot t_2\\ t_4 := \sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - t_3}\\ \mathbf{if}\;\phi_2 \leq -6.5 \cdot 10^{-6}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(t_2, \cos \phi_2, t_0\right)}}{t_4}\right)\\ \mathbf{elif}\;\phi_2 \leq 7 \cdot 10^{-6}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_1\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot t_2}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_3}}{t_4}\right)\\ \end{array} \]
Alternative 8
Error27.7
Cost92233
\[\begin{array}{l} t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\ t_1 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\ t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_3 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_2\\ \mathbf{if}\;\phi_1 \leq -29500000000000 \lor \neg \left(\phi_1 \leq 200\right):\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_3 \cdot \sin \left(0.5 \cdot \lambda_1\right)}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot t_1}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 \cdot t_3 + t_0}}{\sqrt{\left(0.5 - \cos \phi_2 \cdot t_1\right) + 0.5 \cdot \cos \left(2 \cdot \left(\phi_2 \cdot -0.5\right)\right)}}\right)\\ \end{array} \]
Alternative 9
Error30.4
Cost91652
\[\begin{array}{l} t_0 := \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\\ t_1 := {t_0}^{2}\\ t_2 := \cos \phi_2 \cdot t_1\\ t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_4 := {\sin \left(-0.5 \cdot \left(\phi_2 - \phi_1\right)\right)}^{2}\\ \mathbf{if}\;\lambda_1 - \lambda_2 \leq -5 \cdot 10^{-8}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(t_1, \cos \phi_2, {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - t_2}}\right)\\ \mathbf{elif}\;\lambda_1 - \lambda_2 \leq 5 \cdot 10^{-13}:\\ \;\;\;\;\tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(t_0 \cdot t_0\right), t_4\right)}}{\sqrt{1 - t_4}} \cdot \left(R \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_3 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_3\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\left(0.5 - t_2\right) + 0.5 \cdot \cos \left(2 \cdot \left(\phi_2 \cdot -0.5\right)\right)}}\right)\\ \end{array} \]
Alternative 10
Error30.5
Cost86536
\[\begin{array}{l} t_0 := {\sin \left(-0.5 \cdot \left(\phi_2 - \phi_1\right)\right)}^{2}\\ t_1 := \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\\ t_2 := \cos \phi_2 \cdot {t_1}^{2}\\ t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ \mathbf{if}\;\lambda_1 - \lambda_2 \leq -5 \cdot 10^{-8}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_2 \cdot -0.5\right)}^{2} + t_2}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - t_2}}\right)\\ \mathbf{elif}\;\lambda_1 - \lambda_2 \leq 10^{-25}:\\ \;\;\;\;\tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(t_1 \cdot t_1\right), t_0\right)}}{\sqrt{1 - t_0}} \cdot \left(R \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_3 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_3\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\left(0.5 - t_2\right) + 0.5 \cdot \cos \left(2 \cdot \left(\phi_2 \cdot -0.5\right)\right)}}\right)\\ \end{array} \]
Alternative 11
Error30.5
Cost86344
\[\begin{array}{l} t_0 := {\sin \left(-0.5 \cdot \left(\phi_2 - \phi_1\right)\right)}^{2}\\ t_1 := \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\\ t_2 := \cos \phi_2 \cdot {t_1}^{2}\\ t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ \mathbf{if}\;\lambda_1 - \lambda_2 \leq -5 \cdot 10^{-8}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_2 \cdot -0.5\right)}^{2} + t_2}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - t_2}}\right)\\ \mathbf{elif}\;\lambda_1 - \lambda_2 \leq 10^{-25}:\\ \;\;\;\;\tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(t_1 \cdot t_1\right), t_0\right)}}{\sqrt{1 - t_0}} \cdot \left(R \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_3 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_3\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{0.5 + \left(0.5 \cdot \cos \left(-\phi_2\right) - t_2\right)}}\right)\\ \end{array} \]
Alternative 12
Error30.5
Cost85641
\[\begin{array}{l} t_0 := {\sin \left(-0.5 \cdot \left(\phi_2 - \phi_1\right)\right)}^{2}\\ t_1 := \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\\ t_2 := \cos \phi_2 \cdot {t_1}^{2}\\ \mathbf{if}\;\lambda_1 - \lambda_2 \leq -5 \cdot 10^{-8} \lor \neg \left(\lambda_1 - \lambda_2 \leq 10^{-25}\right):\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_2 \cdot -0.5\right)}^{2} + t_2}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - t_2}}\right)\\ \mathbf{else}:\\ \;\;\;\;\tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(t_1 \cdot t_1\right), t_0\right)}}{\sqrt{1 - t_0}} \cdot \left(R \cdot 2\right)\\ \end{array} \]
Alternative 13
Error36.5
Cost85257
\[\begin{array}{l} t_0 := {\sin \left(-0.5 \cdot \left(\phi_2 - \phi_1\right)\right)}^{2}\\ t_1 := \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\\ \mathbf{if}\;\lambda_2 \leq -7 \cdot 10^{-21} \lor \neg \left(\lambda_2 \leq 2.1 \cdot 10^{+28}\right):\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_2 \cdot -0.5\right)}^{2} + \cos \phi_2 \cdot {t_1}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)\\ \mathbf{else}:\\ \;\;\;\;\tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(t_1 \cdot t_1\right), t_0\right)}}{\sqrt{1 - t_0}} \cdot \left(R \cdot 2\right)\\ \end{array} \]
Alternative 14
Error36.9
Cost79620
\[\begin{array}{l} t_0 := \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\\ t_1 := {t_0}^{2}\\ t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_3 := t_2 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_2\right)\\ t_4 := {\sin \left(-0.5 \cdot \left(\phi_2 - \phi_1\right)\right)}^{2}\\ \mathbf{if}\;\lambda_1 - \lambda_2 \leq -2 \cdot 10^{+30}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_3 + {\left(\sin \left(\phi_2 \cdot -0.5\right) + 0.5 \cdot \left(\phi_1 \cdot \cos \left(\phi_2 \cdot -0.5\right)\right)\right)}^{2}}}{\sqrt{1 - t_1}}\right)\\ \mathbf{elif}\;\lambda_1 - \lambda_2 \leq 10^{+18}:\\ \;\;\;\;\tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(t_0 \cdot t_0\right), t_4\right)}}{\sqrt{1 - t_4}} \cdot \left(R \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_3 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 + \left(1 + \left(-1 - t_1\right)\right)}}\right)\\ \end{array} \]
Alternative 15
Error36.5
Cost79368
\[\begin{array}{l} t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_1 := \sqrt{t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}\\ t_2 := \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\\ t_3 := {\sin \left(-0.5 \cdot \left(\phi_2 - \phi_1\right)\right)}^{2}\\ \mathbf{if}\;\lambda_1 - \lambda_2 \leq -2 \cdot 10^{-6}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{0.5 + 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)}}\right)\\ \mathbf{elif}\;\lambda_1 - \lambda_2 \leq 10^{+18}:\\ \;\;\;\;\tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(t_2 \cdot t_2\right), t_3\right)}}{\sqrt{1 - t_3}} \cdot \left(R \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{1 + \left(1 + \left(-1 - {t_2}^{2}\right)\right)}}\right)\\ \end{array} \]
Alternative 16
Error36.5
Cost79368
\[\begin{array}{l} t_0 := {\sin \left(-0.5 \cdot \left(\phi_2 - \phi_1\right)\right)}^{2}\\ t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_2 := \sqrt{t_1 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_1\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}\\ t_3 := \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\\ \mathbf{if}\;\lambda_1 - \lambda_2 \leq -2 \cdot 10^{-6}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_2}{\sqrt{\sqrt[3]{{\left(0.5 + 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}^{3}}}}\right)\\ \mathbf{elif}\;\lambda_1 - \lambda_2 \leq 10^{+18}:\\ \;\;\;\;\tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(t_3 \cdot t_3\right), t_0\right)}}{\sqrt{1 - t_0}} \cdot \left(R \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_2}{\sqrt{1 + \left(1 + \left(-1 - {t_3}^{2}\right)\right)}}\right)\\ \end{array} \]
Alternative 17
Error42.3
Cost73352
\[\begin{array}{l} t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_1 := \cos \phi_1 \cdot \cos \phi_2\\ t_2 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\ t_3 := \sqrt{t_0 \cdot \left(t_1 \cdot t_0\right) + t_2}\\ \mathbf{if}\;\lambda_1 - \lambda_2 \leq -5 \cdot 10^{-8}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_3}{\sqrt{0.5 + 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)}}\right)\\ \mathbf{elif}\;\lambda_1 - \lambda_2 \leq 2 \cdot 10^{-12}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}{\sqrt{1 - \left(t_2 + t_0 \cdot \left(t_1 \cdot \left(\sin \left(0.5 \cdot \lambda_1\right) + -0.5 \cdot \left(\lambda_2 \cdot \cos \left(0.5 \cdot \lambda_1\right)\right)\right)\right)\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_3}{\sqrt{1 + \left(1 + \left(-1 - {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right)\right)}}\right)\\ \end{array} \]
Alternative 18
Error42.3
Cost67017
\[\begin{array}{l} t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_1 := \cos \phi_1 \cdot \cos \phi_2\\ t_2 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\ \mathbf{if}\;\lambda_1 - \lambda_2 \leq -5 \cdot 10^{-8} \lor \neg \left(\lambda_1 - \lambda_2 \leq 2 \cdot 10^{-12}\right):\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot \left(t_1 \cdot t_0\right) + t_2}}{\sqrt{0.5 + 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}{\sqrt{1 - \left(t_2 + t_0 \cdot \left(t_1 \cdot \left(\sin \left(0.5 \cdot \lambda_1\right) + -0.5 \cdot \left(\lambda_2 \cdot \cos \left(0.5 \cdot \lambda_1\right)\right)\right)\right)\right)}}\right)\\ \end{array} \]
Alternative 19
Error42.1
Cost66112
\[\begin{array}{l} t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{0.5 + 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)}}\right) \end{array} \]
Alternative 20
Error55.1
Cost59264
\[\begin{array}{l} t_0 := \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\\ R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_0 \cdot \sqrt{\cos \phi_1}}{\sqrt{0.5 + \left(0.5 \cdot \cos \left(-\phi_2\right) - \cos \phi_2 \cdot {t_0}^{2}\right)}}\right) \end{array} \]
Alternative 21
Error55.1
Cost59200
\[R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot \left(0.5 + -0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}}\right) \]
Alternative 22
Error55.2
Cost46016
\[\begin{array}{l} t_0 := \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\\ R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_0 \cdot \sqrt{\cos \phi_1}}{\sqrt{1 - {t_0}^{2}}}\right) \end{array} \]

Error

Reproduce

herbie shell --seed 2022343 
(FPCore (R lambda1 lambda2 phi1 phi2)
  :name "Distance on a great circle"
  :precision binary64
  (* R (* 2.0 (atan2 (sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* (* (* (cos phi1) (cos phi2)) (sin (/ (- lambda1 lambda2) 2.0))) (sin (/ (- lambda1 lambda2) 2.0))))) (sqrt (- 1.0 (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* (* (* (cos phi1) (cos phi2)) (sin (/ (- lambda1 lambda2) 2.0))) (sin (/ (- lambda1 lambda2) 2.0))))))))))