Average Error: 23.9 → 0.7
Time: 1.5min
Precision: binary64
Cost: 184576
\[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(-0.5 \cdot \phi_2\right)\\ t_1 := -\phi_1 \cdot -0.5\\ t_2 := \cos t_1\\ t_3 := -\lambda_2 \cdot 0.5\\ t_4 := {\left(\sin \left(0.5 \cdot \lambda_1\right) \cdot \cos t_3 + \cos \left(0.5 \cdot \lambda_1\right) \cdot \sin t_3\right)}^{2}\\ t_5 := \cos \left(-0.5 \cdot \phi_2\right)\\ t_6 := \sin t_1\\ \left(R + R\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1 \cdot \cos \phi_2, t_4, {\left(t_0 \cdot t_2 + t_5 \cdot t_6\right)}^{2}\right)}}{\sqrt{{\left(t_5 \cdot t_2 - t_0 \cdot t_6\right)}^{2} - \cos \phi_2 \cdot \left(\cos \phi_1 \cdot t_4\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 (* -0.5 phi2)))
        (t_1 (- (* phi1 -0.5)))
        (t_2 (cos t_1))
        (t_3 (- (* lambda2 0.5)))
        (t_4
         (pow
          (+
           (* (sin (* 0.5 lambda1)) (cos t_3))
           (* (cos (* 0.5 lambda1)) (sin t_3)))
          2.0))
        (t_5 (cos (* -0.5 phi2)))
        (t_6 (sin t_1)))
   (*
    (+ R R)
    (atan2
     (sqrt
      (fma
       (* (cos phi1) (cos phi2))
       t_4
       (pow (+ (* t_0 t_2) (* t_5 t_6)) 2.0)))
     (sqrt
      (-
       (pow (- (* t_5 t_2) (* t_0 t_6)) 2.0)
       (* (cos phi2) (* (cos phi1) t_4))))))))
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((-0.5 * phi2));
	double t_1 = -(phi1 * -0.5);
	double t_2 = cos(t_1);
	double t_3 = -(lambda2 * 0.5);
	double t_4 = pow(((sin((0.5 * lambda1)) * cos(t_3)) + (cos((0.5 * lambda1)) * sin(t_3))), 2.0);
	double t_5 = cos((-0.5 * phi2));
	double t_6 = sin(t_1);
	return (R + R) * atan2(sqrt(fma((cos(phi1) * cos(phi2)), t_4, pow(((t_0 * t_2) + (t_5 * t_6)), 2.0))), sqrt((pow(((t_5 * t_2) - (t_0 * t_6)), 2.0) - (cos(phi2) * (cos(phi1) * t_4)))));
}
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(-0.5 * phi2))
	t_1 = Float64(-Float64(phi1 * -0.5))
	t_2 = cos(t_1)
	t_3 = Float64(-Float64(lambda2 * 0.5))
	t_4 = Float64(Float64(sin(Float64(0.5 * lambda1)) * cos(t_3)) + Float64(cos(Float64(0.5 * lambda1)) * sin(t_3))) ^ 2.0
	t_5 = cos(Float64(-0.5 * phi2))
	t_6 = sin(t_1)
	return Float64(Float64(R + R) * atan(sqrt(fma(Float64(cos(phi1) * cos(phi2)), t_4, (Float64(Float64(t_0 * t_2) + Float64(t_5 * t_6)) ^ 2.0))), sqrt(Float64((Float64(Float64(t_5 * t_2) - Float64(t_0 * t_6)) ^ 2.0) - Float64(cos(phi2) * Float64(cos(phi1) * t_4))))))
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[(-0.5 * phi2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = (-N[(phi1 * -0.5), $MachinePrecision])}, Block[{t$95$2 = N[Cos[t$95$1], $MachinePrecision]}, Block[{t$95$3 = (-N[(lambda2 * 0.5), $MachinePrecision])}, Block[{t$95$4 = N[Power[N[(N[(N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision] * N[Cos[t$95$3], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[t$95$3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$5 = N[Cos[N[(-0.5 * phi2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$6 = N[Sin[t$95$1], $MachinePrecision]}, N[(N[(R + R), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$4 + N[Power[N[(N[(t$95$0 * t$95$2), $MachinePrecision] + N[(t$95$5 * t$95$6), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[(N[(t$95$5 * t$95$2), $MachinePrecision] - N[(t$95$0 * t$95$6), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * t$95$4), $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(-0.5 \cdot \phi_2\right)\\
t_1 := -\phi_1 \cdot -0.5\\
t_2 := \cos t_1\\
t_3 := -\lambda_2 \cdot 0.5\\
t_4 := {\left(\sin \left(0.5 \cdot \lambda_1\right) \cdot \cos t_3 + \cos \left(0.5 \cdot \lambda_1\right) \cdot \sin t_3\right)}^{2}\\
t_5 := \cos \left(-0.5 \cdot \phi_2\right)\\
t_6 := \sin t_1\\
\left(R + R\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1 \cdot \cos \phi_2, t_4, {\left(t_0 \cdot t_2 + t_5 \cdot t_6\right)}^{2}\right)}}{\sqrt{{\left(t_5 \cdot t_2 - t_0 \cdot t_6\right)}^{2} - \cos \phi_2 \cdot \left(\cos \phi_1 \cdot t_4\right)}}
\end{array}

Error

Derivation

  1. Initial program 23.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. Simplified23.9

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

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

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

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

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

Alternatives

Alternative 1
Error13.0
Cost158208
\[\begin{array}{l} t_0 := -\phi_1 \cdot -0.5\\ t_1 := \sin \left(-0.5 \cdot \phi_2\right)\\ t_2 := \cos \left(-0.5 \cdot \phi_2\right)\\ t_3 := -0.5 \cdot \lambda_2\\ \left(R + R\right) \cdot \tan^{-1}_* \frac{\sqrt{{\left(t_2 \cdot \sin \left(0.5 \cdot \phi_1\right) + \cos \left(0.5 \cdot \phi_1\right) \cdot t_1\right)}^{2} + {\left(\cos t_3 \cdot \sin \left(0.5 \cdot \lambda_1\right) + \cos \left(0.5 \cdot \lambda_1\right) \cdot \sin t_3\right)}^{2} \cdot \left(\cos \phi_2 \cdot \cos \phi_1\right)}}{\sqrt{{\left(t_2 \cdot \cos t_0 - t_1 \cdot \sin t_0\right)}^{2} - \cos \phi_2 \cdot \left(\cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\right)}} \end{array} \]
Alternative 2
Error19.6
Cost138440
\[\begin{array}{l} t_0 := -\phi_1 \cdot -0.5\\ t_1 := \cos t_0\\ t_2 := \cos \phi_1 \cdot \cos \phi_2\\ t_3 := \cos \left(-0.5 \cdot \phi_2\right)\\ t_4 := \sin \left(-0.5 \cdot \phi_2\right)\\ t_5 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\ t_6 := -\phi_2 \cdot 0.5\\ t_7 := \sin t_0\\ t_8 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_9 := \sqrt{{\left(t_3 \cdot t_1 - t_4 \cdot t_7\right)}^{2} - \cos \phi_2 \cdot \left(\cos \phi_1 \cdot t_5\right)}\\ \mathbf{if}\;\lambda_2 \leq -14500000:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(t_2 \cdot t_8\right) \cdot t_8}}{\sqrt{1 - \left({\left(\sin \left(0.5 \cdot \phi_1\right) \cdot \cos t_6 + \cos \left(0.5 \cdot \phi_1\right) \cdot \sin t_6\right)}^{2} + \cos \phi_2 \cdot \left(\cos \phi_1 \cdot {\sin \left(-0.5 \cdot \lambda_2\right)}^{2}\right)\right)}}\right)\\ \mathbf{elif}\;\lambda_2 \leq 1.26 \cdot 10^{-131}:\\ \;\;\;\;\left(R + R\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(t_2, \frac{1 - \cos \lambda_1}{2}, {\left(t_4 \cdot t_1 + t_3 \cdot t_7\right)}^{2}\right)}}{t_9}\\ \mathbf{else}:\\ \;\;\;\;\left(R + R\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(t_2, t_5, {\sin \left(\left(\phi_2 - \phi_1\right) \cdot -0.5\right)}^{2}\right)}}{t_9}\\ \end{array} \]
Alternative 3
Error13.4
Cost138240
\[\begin{array}{l} t_0 := \sin \left(-0.5 \cdot \phi_2\right)\\ t_1 := -\phi_1 \cdot -0.5\\ t_2 := \cos \left(-0.5 \cdot \phi_2\right)\\ \left(R + R\right) \cdot \tan^{-1}_* \frac{\sqrt{{\left(t_2 \cdot \sin \left(0.5 \cdot \phi_1\right) + \cos \left(0.5 \cdot \phi_1\right) \cdot t_0\right)}^{2} + \cos \phi_2 \cdot \left(\cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right)}}{\sqrt{{\left(t_2 \cdot \cos t_1 - t_0 \cdot \sin t_1\right)}^{2} - \cos \phi_2 \cdot \left(\cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\right)}} \end{array} \]
Alternative 4
Error23.3
Cost118592
\[\begin{array}{l} t_0 := -\phi_1 \cdot -0.5\\ \left(R + R\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1 \cdot \cos \phi_2, {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}, {\left(\sin \left(-0.5 \cdot \phi_2\right) \cdot \cos t_0 + \cos \left(-0.5 \cdot \phi_2\right) \cdot \sin t_0\right)}^{2}\right)}}{\sqrt{{\cos \left(\left(\phi_2 - \phi_1\right) \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot \left(\cos \phi_1 \cdot \frac{1 - \cos \left(\left(\lambda_1 - \lambda_2\right) \cdot \left(0.5 + 0.5\right)\right)}{2}\right)}} \end{array} \]
Alternative 5
Error35.6
Cost99528
\[\begin{array}{l} t_0 := -\phi_1 \cdot -0.5\\ t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_2 := \left(R + R\right) \cdot \tan^{-1}_* \frac{\left|\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)\right|}{\sqrt{{\left(\cos \left(-0.5 \cdot \phi_2\right) \cdot \cos t_0 - \sin \left(-0.5 \cdot \phi_2\right) \cdot \sin t_0\right)}^{2} - \cos \phi_2 \cdot \left(\cos \phi_1 \cdot \frac{1 - \cos \left(\left(\lambda_1 - \lambda_2\right) \cdot \left(0.5 + 0.5\right)\right)}{2}\right)}}\\ \mathbf{if}\;t_1 \leq -0.04:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 0.08:\\ \;\;\;\;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 \left(\sin \left(\lambda_1 \cdot 0.5\right) \cdot \cos \left(\lambda_2 \cdot 0.5\right) - \cos \left(\lambda_1 \cdot 0.5\right) \cdot \sin \left(\lambda_2 \cdot 0.5\right)\right)\right) \cdot t_1}}{\sqrt{0.5 + 0.5 \cdot \cos \left(\phi_1 - \phi_2\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 6
Error23.9
Cost98752
\[\begin{array}{l} t_0 := \cos \phi_1 \cdot \cos \phi_2\\ t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(t_0 \cdot t_1\right) \cdot t_1}}{\sqrt{{\cos \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2} - t_0 \cdot {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot -0.5\right)}^{2}}}\right) \end{array} \]
Alternative 7
Error23.7
Cost98312
\[\begin{array}{l} t_0 := \cos \phi_2 \cdot \left(\cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\right)\\ 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 := {\sin \left(-0.5 \cdot \phi_2\right)}^{2}\\ \mathbf{if}\;\phi_2 \leq -0.0115:\\ \;\;\;\;\left(R + R\right) \cdot \tan^{-1}_* \frac{\sqrt{t_3 + \cos \phi_2 \cdot t_1}}{\sqrt{{\cos \left(-0.5 \cdot \phi_2\right)}^{2} - t_0}}\\ \mathbf{elif}\;\phi_2 \leq 0.00085:\\ \;\;\;\;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 t_2\right) \cdot t_2}}{\sqrt{1 - \left({\sin \left(0.5 \cdot \phi_1\right)}^{2} + \cos \phi_1 \cdot t_1\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(R + R\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_2, t_1, t_3\right)}}{\sqrt{{\cos \left(\left(\phi_2 - \phi_1\right) \cdot -0.5\right)}^{2} - t_0}}\\ \end{array} \]
Alternative 8
Error35.6
Cost93128
\[\begin{array}{l} t_0 := -\phi_1 \cdot -0.5\\ t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_2 := \left(R + R\right) \cdot \tan^{-1}_* \frac{\left|\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)\right|}{\sqrt{{\left(\cos \left(-0.5 \cdot \phi_2\right) \cdot \cos t_0 - \sin \left(-0.5 \cdot \phi_2\right) \cdot \sin t_0\right)}^{2} - \cos \phi_2 \cdot \left(\cos \phi_1 \cdot \frac{1 - \cos \left(\left(\lambda_1 - \lambda_2\right) \cdot \left(0.5 + 0.5\right)\right)}{2}\right)}}\\ \mathbf{if}\;t_1 \leq -0.04:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 0.08:\\ \;\;\;\;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 t_1\right) \cdot t_1}}{\sqrt{1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}}}\right)\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 9
Error24.0
Cost92488
\[\begin{array}{l} t_0 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\ t_1 := \left(R + R\right) \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(0.5 \cdot \phi_1\right)}^{2} + \cos \phi_1 \cdot t_0}}{\sqrt{{\cos \left(\left(\phi_2 - \phi_1\right) \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot \left(\cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\right)}}\\ t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ \mathbf{if}\;\phi_1 \leq -1350000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\phi_1 \leq 3.4 \cdot 10^{-19}:\\ \;\;\;\;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 t_2\right) \cdot t_2}}{\sqrt{1 - \left({\sin \left(-0.5 \cdot \phi_2\right)}^{2} + \cos \phi_2 \cdot t_0\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error23.7
Cost92488
\[\begin{array}{l} t_0 := \cos \phi_2 \cdot \left(\cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\right)\\ 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 := \sqrt{{\sin \left(-0.5 \cdot \phi_2\right)}^{2} + \cos \phi_2 \cdot t_1}\\ \mathbf{if}\;\phi_2 \leq -7.8 \cdot 10^{-6}:\\ \;\;\;\;\left(R + R\right) \cdot \tan^{-1}_* \frac{t_3}{\sqrt{{\cos \left(-0.5 \cdot \phi_2\right)}^{2} - t_0}}\\ \mathbf{elif}\;\phi_2 \leq 0.00072:\\ \;\;\;\;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 t_2\right) \cdot t_2}}{\sqrt{1 - \left({\sin \left(0.5 \cdot \phi_1\right)}^{2} + \cos \phi_1 \cdot t_1\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(R + R\right) \cdot \tan^{-1}_* \frac{t_3}{\sqrt{{\cos \left(\left(\phi_2 - \phi_1\right) \cdot -0.5\right)}^{2} - t_0}}\\ \end{array} \]
Alternative 11
Error35.9
Cost92360
\[\begin{array}{l} t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_1 := \left(R + R\right) \cdot \tan^{-1}_* \frac{\left|\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)\right|}{\sqrt{{\cos \left(\left(\phi_2 - \phi_1\right) \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot \left(\cos \phi_1 \cdot \frac{\left(1 - \cos \lambda_1 \cdot \cos \lambda_2\right) - \sin \lambda_1 \cdot \sin \lambda_2}{2}\right)}}\\ \mathbf{if}\;t_0 \leq -0.04:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_0 \leq 0.08:\\ \;\;\;\;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 t_0\right) \cdot t_0}}{\sqrt{1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}}}\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 12
Error30.1
Cost92168
\[\begin{array}{l} t_0 := \left(R + R\right) \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(-0.5 \cdot \phi_2\right)}^{2} + \cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}}{\sqrt{{\cos \left(-0.5 \cdot \phi_2\right)}^{2} - \cos \phi_2 \cdot \left(\cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\right)}}\\ \mathbf{if}\;\lambda_1 - \lambda_2 \leq -2 \cdot 10^{-6}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\lambda_1 - \lambda_2 \leq 10^{-33}:\\ \;\;\;\;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 \left(\sin \left(\lambda_1 \cdot 0.5\right) \cdot \cos \left(\lambda_2 \cdot 0.5\right) - \cos \left(\lambda_1 \cdot 0.5\right) \cdot \sin \left(\lambda_2 \cdot 0.5\right)\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}}{\sqrt{0.5 + 0.5 \cdot \cos \left(\phi_1 - \phi_2\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 13
Error28.2
Cost92040
\[\begin{array}{l} t_0 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\ t_1 := R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(0.5 \cdot \phi_1\right)}^{2} + \cos \phi_1 \cdot t_0}}{\sqrt{1 - \left({\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2} + \cos \phi_2 \cdot \left(\cos \phi_1 \cdot {\sin \left(-0.5 \cdot \lambda_2\right)}^{2}\right)\right)}}\right)\\ \mathbf{if}\;\phi_1 \leq -1.15 \cdot 10^{-8}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\phi_1 \leq 5.5 \cdot 10^{-65}:\\ \;\;\;\;\left(R + R\right) \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(-0.5 \cdot \phi_2\right)}^{2} + \cos \phi_2 \cdot t_0}}{\sqrt{{\cos \left(-0.5 \cdot \phi_2\right)}^{2} - \cos \phi_2 \cdot \left(\cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\right)}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 14
Error25.4
Cost92040
\[\begin{array}{l} t_0 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\ t_1 := \sqrt{{\cos \left(\left(\phi_2 - \phi_1\right) \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot \left(\cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\right)}\\ t_2 := \left(R + R\right) \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(0.5 \cdot \phi_1\right)}^{2} + \cos \phi_1 \cdot t_0}}{t_1}\\ \mathbf{if}\;\phi_1 \leq -1350000000:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\phi_1 \leq 5.5 \cdot 10^{-65}:\\ \;\;\;\;\left(R + R\right) \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(-0.5 \cdot \phi_2\right)}^{2} + \cos \phi_2 \cdot t_0}}{t_1}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 15
Error36.2
Cost86152
\[\begin{array}{l} t_0 := \left|\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)\right|\\ t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ \mathbf{if}\;t_1 \leq -0.04:\\ \;\;\;\;\left(R + R\right) \cdot \tan^{-1}_* \frac{t_0}{\sqrt{{\cos \left(\left(\phi_2 - \phi_1\right) \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot \left(\cos \phi_1 \cdot \left(1 - {\cos \left(\left(\lambda_2 - \lambda_1\right) \cdot -0.5\right)}^{2}\right)\right)}}\\ \mathbf{elif}\;t_1 \leq 0.08:\\ \;\;\;\;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 t_1\right) \cdot t_1}}{\sqrt{1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}}}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(R + R\right) \cdot \tan^{-1}_* \frac{t_0}{\sqrt{{\cos \left(-0.5 \cdot \phi_2\right)}^{2} - \cos \phi_2 \cdot \left(\cos \phi_1 \cdot \frac{1 - \cos \left(\left(\lambda_1 - \lambda_2\right) \cdot \left(0.5 + 0.5\right)\right)}{2}\right)}}\\ \end{array} \]
Alternative 16
Error45.1
Cost65792
\[\left(R + R\right) \cdot \tan^{-1}_* \frac{\left|\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)\right|}{\sqrt{{\cos \left(\left(\phi_2 - \phi_1\right) \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot \left(\cos \phi_1 \cdot \left(1 - {\cos \left(\left(\lambda_2 - \lambda_1\right) \cdot -0.5\right)}^{2}\right)\right)}} \]
Alternative 17
Error45.1
Cost59584
\[\left(R + R\right) \cdot \tan^{-1}_* \frac{\left|\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)\right|}{\sqrt{{\cos \left(\left(\phi_2 - \phi_1\right) \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot \left(\cos \phi_1 \cdot \frac{1 - \cos \left(\left(\lambda_1 - \lambda_2\right) \cdot \left(0.5 + 0.5\right)\right)}{2}\right)}} \]
Alternative 18
Error45.2
Cost59464
\[\begin{array}{l} t_0 := {\cos \left(\left(\phi_2 - \phi_1\right) \cdot -0.5\right)}^{2}\\ t_1 := \left|\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)\right|\\ t_2 := \left(R + R\right) \cdot \tan^{-1}_* \frac{t_1}{\sqrt{t_0 - \cos \phi_2 \cdot \left(\cos \phi_1 \cdot \frac{1 - \cos \lambda_2}{2}\right)}}\\ \mathbf{if}\;\lambda_2 \leq -5.5 \cdot 10^{-5}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\lambda_2 \leq 3.3 \cdot 10^{+21}:\\ \;\;\;\;\left(R + R\right) \cdot \tan^{-1}_* \frac{t_1}{\sqrt{t_0 - \cos \phi_2 \cdot \left(\cos \phi_1 \cdot \frac{1 - \cos \lambda_1}{2}\right)}}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 19
Error45.3
Cost59456
\[\left(R + R\right) \cdot \tan^{-1}_* \frac{\left|\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)\right|}{\sqrt{{\cos \left(-0.5 \cdot \phi_2\right)}^{2} - \cos \phi_2 \cdot \left(\cos \phi_1 \cdot \frac{1 - \cos \left(\left(\lambda_1 - \lambda_2\right) \cdot \left(0.5 + 0.5\right)\right)}{2}\right)}} \]
Alternative 20
Error48.2
Cost59200
\[\left(R + R\right) \cdot \tan^{-1}_* \frac{\left|\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)\right|}{\sqrt{{\cos \left(\left(\phi_2 - \phi_1\right) \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot \left(\cos \phi_1 \cdot \frac{1 - \cos \lambda_1}{2}\right)}} \]

Error

Reproduce

herbie shell --seed 2023010 
(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))))))))))