Distance on a great circle

Percentage Accurate: 62.3% → 79.5%
Time: 2.3min
Alternatives: 21
Speedup: 1.1×

Specification

?
\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_1 := {\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\\ R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right) \end{array} \end{array} \]
(FPCore (R lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
        (t_1
         (+
          (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
          (* (* (* (cos phi1) (cos phi2)) t_0) t_0))))
   (* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
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 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
	return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
    real(8), intent (in) :: r
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    real(8) :: t_0
    real(8) :: t_1
    t_0 = sin(((lambda1 - lambda2) / 2.0d0))
    t_1 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0)
    code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
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 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0);
	return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2):
	t_0 = math.sin(((lambda1 - lambda2) / 2.0))
	t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0)
	return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2)
	t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0))
	t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0))
	return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1)))))
end
function tmp = code(R, lambda1, lambda2, phi1, phi2)
	t_0 = sin(((lambda1 - lambda2) / 2.0));
	t_1 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
	tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
end
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[(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] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\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\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)
\end{array}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 21 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 62.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_1 := {\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\\ R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right) \end{array} \end{array} \]
(FPCore (R lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
        (t_1
         (+
          (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
          (* (* (* (cos phi1) (cos phi2)) t_0) t_0))))
   (* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
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 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
	return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
    real(8), intent (in) :: r
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    real(8) :: t_0
    real(8) :: t_1
    t_0 = sin(((lambda1 - lambda2) / 2.0d0))
    t_1 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0)
    code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
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 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0);
	return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2):
	t_0 = math.sin(((lambda1 - lambda2) / 2.0))
	t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0)
	return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2)
	t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0))
	t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0))
	return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1)))))
end
function tmp = code(R, lambda1, lambda2, phi1, phi2)
	t_0 = sin(((lambda1 - lambda2) / 2.0));
	t_1 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
	tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
end
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[(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] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\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\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)
\end{array}
\end{array}

Alternative 1: 79.5% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\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}\\ R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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\_0}}{\sqrt{1 - \left(t\_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\left(\sin \left(\frac{\lambda_1}{2}\right) \cdot \cos \left(\frac{\lambda_2}{2}\right) - \cos \left(\frac{\lambda_1}{2}\right) \cdot \sin \left(\frac{\lambda_2}{2}\right)\right)}^{2}\right)\right)}}\right) \end{array} \end{array} \]
(FPCore (R lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0
         (pow
          (-
           (* (sin (* phi1 0.5)) (cos (* phi2 0.5)))
           (* (cos (* phi1 0.5)) (sin (* phi2 0.5))))
          2.0)))
   (*
    R
    (*
     2.0
     (atan2
      (sqrt
       (+
        (*
         (cos phi1)
         (* (cos phi2) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0)))
        t_0))
      (sqrt
       (-
        1.0
        (+
         t_0
         (*
          (cos phi1)
          (*
           (cos phi2)
           (pow
            (-
             (* (sin (/ lambda1 2.0)) (cos (/ lambda2 2.0)))
             (* (cos (/ lambda1 2.0)) (sin (/ lambda2 2.0))))
            2.0)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = pow(((sin((phi1 * 0.5)) * cos((phi2 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))), 2.0);
	return R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0))) + t_0)), sqrt((1.0 - (t_0 + (cos(phi1) * (cos(phi2) * pow(((sin((lambda1 / 2.0)) * cos((lambda2 / 2.0))) - (cos((lambda1 / 2.0)) * sin((lambda2 / 2.0)))), 2.0))))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
    real(8), intent (in) :: r
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    real(8) :: t_0
    t_0 = ((sin((phi1 * 0.5d0)) * cos((phi2 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((phi2 * 0.5d0)))) ** 2.0d0
    code = r * (2.0d0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0))) + t_0)), sqrt((1.0d0 - (t_0 + (cos(phi1) * (cos(phi2) * (((sin((lambda1 / 2.0d0)) * cos((lambda2 / 2.0d0))) - (cos((lambda1 / 2.0d0)) * sin((lambda2 / 2.0d0)))) ** 2.0d0))))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = Math.pow(((Math.sin((phi1 * 0.5)) * Math.cos((phi2 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((phi2 * 0.5)))), 2.0);
	return R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0))) + t_0)), Math.sqrt((1.0 - (t_0 + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(((Math.sin((lambda1 / 2.0)) * Math.cos((lambda2 / 2.0))) - (Math.cos((lambda1 / 2.0)) * Math.sin((lambda2 / 2.0)))), 2.0))))))));
}
def code(R, lambda1, lambda2, phi1, phi2):
	t_0 = math.pow(((math.sin((phi1 * 0.5)) * math.cos((phi2 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((phi2 * 0.5)))), 2.0)
	return R * (2.0 * math.atan2(math.sqrt(((math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0))) + t_0)), math.sqrt((1.0 - (t_0 + (math.cos(phi1) * (math.cos(phi2) * math.pow(((math.sin((lambda1 / 2.0)) * math.cos((lambda2 / 2.0))) - (math.cos((lambda1 / 2.0)) * math.sin((lambda2 / 2.0)))), 2.0))))))))
function code(R, lambda1, lambda2, phi1, phi2)
	t_0 = Float64(Float64(sin(Float64(phi1 * 0.5)) * cos(Float64(phi2 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(phi2 * 0.5)))) ^ 2.0
	return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0))) + t_0)), sqrt(Float64(1.0 - Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * (Float64(Float64(sin(Float64(lambda1 / 2.0)) * cos(Float64(lambda2 / 2.0))) - Float64(cos(Float64(lambda1 / 2.0)) * sin(Float64(lambda2 / 2.0)))) ^ 2.0)))))))))
end
function tmp = code(R, lambda1, lambda2, phi1, phi2)
	t_0 = ((sin((phi1 * 0.5)) * cos((phi2 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))) ^ 2.0;
	tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0))) + t_0)), sqrt((1.0 - (t_0 + (cos(phi1) * (cos(phi2) * (((sin((lambda1 / 2.0)) * cos((lambda2 / 2.0))) - (cos((lambda1 / 2.0)) * sin((lambda2 / 2.0)))) ^ 2.0))))))));
end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[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$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[(N[(N[Sin[N[(lambda1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(lambda2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(lambda1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(lambda2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\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}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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\_0}}{\sqrt{1 - \left(t\_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\left(\sin \left(\frac{\lambda_1}{2}\right) \cdot \cos \left(\frac{\lambda_2}{2}\right) - \cos \left(\frac{\lambda_1}{2}\right) \cdot \sin \left(\frac{\lambda_2}{2}\right)\right)}^{2}\right)\right)}}\right)
\end{array}
\end{array}
Derivation
  1. Initial program 58.3%

    \[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. Add Preprocessing
  3. Step-by-step derivation
    1. div-sub58.3%

      \[\leadsto 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 \color{blue}{\left(\frac{\phi_1}{2} - \frac{\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. sin-diff59.5%

      \[\leadsto 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({\color{blue}{\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
    3. div-inv59.5%

      \[\leadsto 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({\left(\sin \color{blue}{\left(\phi_1 \cdot \frac{1}{2}\right)} \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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. metadata-eval59.5%

      \[\leadsto 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({\left(\sin \left(\phi_1 \cdot \color{blue}{0.5}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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. div-inv59.5%

      \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \color{blue}{\left(\phi_2 \cdot \frac{1}{2}\right)} - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
    6. metadata-eval59.5%

      \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot \color{blue}{0.5}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
    7. div-inv59.5%

      \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \color{blue}{\left(\phi_1 \cdot \frac{1}{2}\right)} \cdot \sin \left(\frac{\phi_2}{2}\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) \]
    8. metadata-eval59.5%

      \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \left(\phi_1 \cdot \color{blue}{0.5}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
    9. div-inv59.5%

      \[\leadsto 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({\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 \color{blue}{\left(\phi_2 \cdot \frac{1}{2}\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) \]
    10. metadata-eval59.5%

      \[\leadsto 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({\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 \color{blue}{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-rr59.5%

    \[\leadsto 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({\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) \]
  5. Step-by-step derivation
    1. div-sub58.3%

      \[\leadsto 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 \color{blue}{\left(\frac{\phi_1}{2} - \frac{\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. sin-diff59.5%

      \[\leadsto 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({\color{blue}{\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
    3. div-inv59.5%

      \[\leadsto 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({\left(\sin \color{blue}{\left(\phi_1 \cdot \frac{1}{2}\right)} \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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. metadata-eval59.5%

      \[\leadsto 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({\left(\sin \left(\phi_1 \cdot \color{blue}{0.5}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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. div-inv59.5%

      \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \color{blue}{\left(\phi_2 \cdot \frac{1}{2}\right)} - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
    6. metadata-eval59.5%

      \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot \color{blue}{0.5}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
    7. div-inv59.5%

      \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \color{blue}{\left(\phi_1 \cdot \frac{1}{2}\right)} \cdot \sin \left(\frac{\phi_2}{2}\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) \]
    8. metadata-eval59.5%

      \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \left(\phi_1 \cdot \color{blue}{0.5}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
    9. div-inv59.5%

      \[\leadsto 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({\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 \color{blue}{\left(\phi_2 \cdot \frac{1}{2}\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) \]
    10. metadata-eval59.5%

      \[\leadsto 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({\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 \color{blue}{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) \]
  6. Applied egg-rr78.7%

    \[\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({\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) \]
  7. Taylor expanded in phi1 around 0 78.7%

    \[\leadsto R \cdot \color{blue}{\left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right) + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right)} \]
  8. Step-by-step derivation
    1. *-commutative78.7%

      \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \color{blue}{\left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}}^{2}\right) + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right) \]
    2. metadata-eval78.7%

      \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{\frac{1}{2}}\right)}^{2}\right) + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right) \]
    3. div-inv78.7%

      \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \color{blue}{\left(\frac{\lambda_1 - \lambda_2}{2}\right)}}^{2}\right) + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right) \]
    4. div-sub78.7%

      \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \color{blue}{\left(\frac{\lambda_1}{2} - \frac{\lambda_2}{2}\right)}}^{2}\right) + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right) \]
    5. sin-diff79.2%

      \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\color{blue}{\left(\sin \left(\frac{\lambda_1}{2}\right) \cdot \cos \left(\frac{\lambda_2}{2}\right) - \cos \left(\frac{\lambda_1}{2}\right) \cdot \sin \left(\frac{\lambda_2}{2}\right)\right)}}^{2}\right) + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right) \]
  9. Applied egg-rr79.2%

    \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\color{blue}{\left(\sin \left(\frac{\lambda_1}{2}\right) \cdot \cos \left(\frac{\lambda_2}{2}\right) - \cos \left(\frac{\lambda_1}{2}\right) \cdot \sin \left(\frac{\lambda_2}{2}\right)\right)}}^{2}\right) + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right) \]
  10. Final simplification79.2%

    \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\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}}}{\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} + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\left(\sin \left(\frac{\lambda_1}{2}\right) \cdot \cos \left(\frac{\lambda_2}{2}\right) - \cos \left(\frac{\lambda_1}{2}\right) \cdot \sin \left(\frac{\lambda_2}{2}\right)\right)}^{2}\right)\right)}}\right) \]
  11. Add Preprocessing

Alternative 2: 68.4% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\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}\\ t_1 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\ t_2 := \cos \phi_2 \cdot t\_1\\ t_3 := \sqrt{\cos \phi_1 \cdot t\_2 + t\_0}\\ \mathbf{if}\;\phi_1 \leq -0.062 \lor \neg \left(\phi_1 \leq 67000000000\right):\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_3}{\sqrt{1 - \left(t\_0 + \cos \phi_1 \cdot t\_1\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_3}{\sqrt{1 - \left(t\_2 + t\_0\right)}}\right)\\ \end{array} \end{array} \]
(FPCore (R lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0
         (pow
          (-
           (* (sin (* phi1 0.5)) (cos (* phi2 0.5)))
           (* (cos (* phi1 0.5)) (sin (* phi2 0.5))))
          2.0))
        (t_1 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
        (t_2 (* (cos phi2) t_1))
        (t_3 (sqrt (+ (* (cos phi1) t_2) t_0))))
   (if (or (<= phi1 -0.062) (not (<= phi1 67000000000.0)))
     (* R (* 2.0 (atan2 t_3 (sqrt (- 1.0 (+ t_0 (* (cos phi1) t_1)))))))
     (* R (* 2.0 (atan2 t_3 (sqrt (- 1.0 (+ t_2 t_0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = pow(((sin((phi1 * 0.5)) * cos((phi2 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))), 2.0);
	double t_1 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
	double t_2 = cos(phi2) * t_1;
	double t_3 = sqrt(((cos(phi1) * t_2) + t_0));
	double tmp;
	if ((phi1 <= -0.062) || !(phi1 <= 67000000000.0)) {
		tmp = R * (2.0 * atan2(t_3, sqrt((1.0 - (t_0 + (cos(phi1) * t_1))))));
	} else {
		tmp = R * (2.0 * atan2(t_3, sqrt((1.0 - (t_2 + t_0)))));
	}
	return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
    real(8), intent (in) :: r
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: t_3
    real(8) :: tmp
    t_0 = ((sin((phi1 * 0.5d0)) * cos((phi2 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((phi2 * 0.5d0)))) ** 2.0d0
    t_1 = sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
    t_2 = cos(phi2) * t_1
    t_3 = sqrt(((cos(phi1) * t_2) + t_0))
    if ((phi1 <= (-0.062d0)) .or. (.not. (phi1 <= 67000000000.0d0))) then
        tmp = r * (2.0d0 * atan2(t_3, sqrt((1.0d0 - (t_0 + (cos(phi1) * t_1))))))
    else
        tmp = r * (2.0d0 * atan2(t_3, sqrt((1.0d0 - (t_2 + t_0)))))
    end if
    code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = Math.pow(((Math.sin((phi1 * 0.5)) * Math.cos((phi2 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((phi2 * 0.5)))), 2.0);
	double t_1 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
	double t_2 = Math.cos(phi2) * t_1;
	double t_3 = Math.sqrt(((Math.cos(phi1) * t_2) + t_0));
	double tmp;
	if ((phi1 <= -0.062) || !(phi1 <= 67000000000.0)) {
		tmp = R * (2.0 * Math.atan2(t_3, Math.sqrt((1.0 - (t_0 + (Math.cos(phi1) * t_1))))));
	} else {
		tmp = R * (2.0 * Math.atan2(t_3, Math.sqrt((1.0 - (t_2 + t_0)))));
	}
	return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2):
	t_0 = math.pow(((math.sin((phi1 * 0.5)) * math.cos((phi2 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((phi2 * 0.5)))), 2.0)
	t_1 = math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)
	t_2 = math.cos(phi2) * t_1
	t_3 = math.sqrt(((math.cos(phi1) * t_2) + t_0))
	tmp = 0
	if (phi1 <= -0.062) or not (phi1 <= 67000000000.0):
		tmp = R * (2.0 * math.atan2(t_3, math.sqrt((1.0 - (t_0 + (math.cos(phi1) * t_1))))))
	else:
		tmp = R * (2.0 * math.atan2(t_3, math.sqrt((1.0 - (t_2 + t_0)))))
	return tmp
function code(R, lambda1, lambda2, phi1, phi2)
	t_0 = Float64(Float64(sin(Float64(phi1 * 0.5)) * cos(Float64(phi2 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(phi2 * 0.5)))) ^ 2.0
	t_1 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0
	t_2 = Float64(cos(phi2) * t_1)
	t_3 = sqrt(Float64(Float64(cos(phi1) * t_2) + t_0))
	tmp = 0.0
	if ((phi1 <= -0.062) || !(phi1 <= 67000000000.0))
		tmp = Float64(R * Float64(2.0 * atan(t_3, sqrt(Float64(1.0 - Float64(t_0 + Float64(cos(phi1) * t_1)))))));
	else
		tmp = Float64(R * Float64(2.0 * atan(t_3, sqrt(Float64(1.0 - Float64(t_2 + t_0))))));
	end
	return tmp
end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
	t_0 = ((sin((phi1 * 0.5)) * cos((phi2 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))) ^ 2.0;
	t_1 = sin((0.5 * (lambda1 - lambda2))) ^ 2.0;
	t_2 = cos(phi2) * t_1;
	t_3 = sqrt(((cos(phi1) * t_2) + t_0));
	tmp = 0.0;
	if ((phi1 <= -0.062) || ~((phi1 <= 67000000000.0)))
		tmp = R * (2.0 * atan2(t_3, sqrt((1.0 - (t_0 + (cos(phi1) * t_1))))));
	else
		tmp = R * (2.0 * atan2(t_3, sqrt((1.0 - (t_2 + t_0)))));
	end
	tmp_2 = tmp;
end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$2), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -0.062], N[Not[LessEqual[phi1, 67000000000.0]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[t$95$3 / N[Sqrt[N[(1.0 - N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$3 / N[Sqrt[N[(1.0 - N[(t$95$2 + t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\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}\\
t_1 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
t_2 := \cos \phi_2 \cdot t\_1\\
t_3 := \sqrt{\cos \phi_1 \cdot t\_2 + t\_0}\\
\mathbf{if}\;\phi_1 \leq -0.062 \lor \neg \left(\phi_1 \leq 67000000000\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_3}{\sqrt{1 - \left(t\_0 + \cos \phi_1 \cdot t\_1\right)}}\right)\\

\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_3}{\sqrt{1 - \left(t\_2 + t\_0\right)}}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if phi1 < -0.062 or 6.7e10 < phi1

    1. Initial program 41.3%

      \[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. Add Preprocessing
    3. Step-by-step derivation
      1. div-sub41.3%

        \[\leadsto 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 \color{blue}{\left(\frac{\phi_1}{2} - \frac{\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. sin-diff43.5%

        \[\leadsto 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({\color{blue}{\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
      3. div-inv43.5%

        \[\leadsto 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({\left(\sin \color{blue}{\left(\phi_1 \cdot \frac{1}{2}\right)} \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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. metadata-eval43.5%

        \[\leadsto 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({\left(\sin \left(\phi_1 \cdot \color{blue}{0.5}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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. div-inv43.5%

        \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \color{blue}{\left(\phi_2 \cdot \frac{1}{2}\right)} - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
      6. metadata-eval43.5%

        \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot \color{blue}{0.5}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
      7. div-inv43.5%

        \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \color{blue}{\left(\phi_1 \cdot \frac{1}{2}\right)} \cdot \sin \left(\frac{\phi_2}{2}\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) \]
      8. metadata-eval43.5%

        \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \left(\phi_1 \cdot \color{blue}{0.5}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
      9. div-inv43.5%

        \[\leadsto 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({\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 \color{blue}{\left(\phi_2 \cdot \frac{1}{2}\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) \]
      10. metadata-eval43.5%

        \[\leadsto 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({\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 \color{blue}{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-rr43.5%

      \[\leadsto 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({\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) \]
    5. Step-by-step derivation
      1. div-sub41.3%

        \[\leadsto 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 \color{blue}{\left(\frac{\phi_1}{2} - \frac{\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. sin-diff43.5%

        \[\leadsto 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({\color{blue}{\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
      3. div-inv43.5%

        \[\leadsto 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({\left(\sin \color{blue}{\left(\phi_1 \cdot \frac{1}{2}\right)} \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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. metadata-eval43.5%

        \[\leadsto 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({\left(\sin \left(\phi_1 \cdot \color{blue}{0.5}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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. div-inv43.5%

        \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \color{blue}{\left(\phi_2 \cdot \frac{1}{2}\right)} - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
      6. metadata-eval43.5%

        \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot \color{blue}{0.5}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
      7. div-inv43.5%

        \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \color{blue}{\left(\phi_1 \cdot \frac{1}{2}\right)} \cdot \sin \left(\frac{\phi_2}{2}\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) \]
      8. metadata-eval43.5%

        \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \left(\phi_1 \cdot \color{blue}{0.5}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
      9. div-inv43.5%

        \[\leadsto 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({\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 \color{blue}{\left(\phi_2 \cdot \frac{1}{2}\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) \]
      10. metadata-eval43.5%

        \[\leadsto 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({\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 \color{blue}{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) \]
    6. Applied egg-rr78.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({\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) \]
    7. Taylor expanded in phi1 around 0 78.3%

      \[\leadsto R \cdot \color{blue}{\left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right) + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right)} \]
    8. Taylor expanded in phi2 around 0 55.8%

      \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\color{blue}{\cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}} + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right) \]
    9. Step-by-step derivation
      1. *-commutative55.8%

        \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\color{blue}{{\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} \cdot \cos \phi_1} + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right) \]
    10. Simplified55.8%

      \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\color{blue}{{\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} \cdot \cos \phi_1} + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right) \]

    if -0.062 < phi1 < 6.7e10

    1. Initial program 77.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. Add Preprocessing
    3. Step-by-step derivation
      1. div-sub77.9%

        \[\leadsto 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 \color{blue}{\left(\frac{\phi_1}{2} - \frac{\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. sin-diff78.0%

        \[\leadsto 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({\color{blue}{\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
      3. div-inv78.0%

        \[\leadsto 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({\left(\sin \color{blue}{\left(\phi_1 \cdot \frac{1}{2}\right)} \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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. metadata-eval78.0%

        \[\leadsto 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({\left(\sin \left(\phi_1 \cdot \color{blue}{0.5}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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. div-inv78.0%

        \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \color{blue}{\left(\phi_2 \cdot \frac{1}{2}\right)} - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
      6. metadata-eval78.0%

        \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot \color{blue}{0.5}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
      7. div-inv78.0%

        \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \color{blue}{\left(\phi_1 \cdot \frac{1}{2}\right)} \cdot \sin \left(\frac{\phi_2}{2}\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) \]
      8. metadata-eval78.0%

        \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \left(\phi_1 \cdot \color{blue}{0.5}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
      9. div-inv78.0%

        \[\leadsto 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({\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 \color{blue}{\left(\phi_2 \cdot \frac{1}{2}\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) \]
      10. metadata-eval78.0%

        \[\leadsto 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({\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 \color{blue}{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-rr78.0%

      \[\leadsto 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({\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) \]
    5. Step-by-step derivation
      1. div-sub77.9%

        \[\leadsto 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 \color{blue}{\left(\frac{\phi_1}{2} - \frac{\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. sin-diff78.0%

        \[\leadsto 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({\color{blue}{\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
      3. div-inv78.0%

        \[\leadsto 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({\left(\sin \color{blue}{\left(\phi_1 \cdot \frac{1}{2}\right)} \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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. metadata-eval78.0%

        \[\leadsto 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({\left(\sin \left(\phi_1 \cdot \color{blue}{0.5}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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. div-inv78.0%

        \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \color{blue}{\left(\phi_2 \cdot \frac{1}{2}\right)} - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
      6. metadata-eval78.0%

        \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot \color{blue}{0.5}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
      7. div-inv78.0%

        \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \color{blue}{\left(\phi_1 \cdot \frac{1}{2}\right)} \cdot \sin \left(\frac{\phi_2}{2}\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) \]
      8. metadata-eval78.0%

        \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \left(\phi_1 \cdot \color{blue}{0.5}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
      9. div-inv78.0%

        \[\leadsto 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({\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 \color{blue}{\left(\phi_2 \cdot \frac{1}{2}\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) \]
      10. metadata-eval78.0%

        \[\leadsto 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({\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 \color{blue}{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) \]
    6. Applied egg-rr79.1%

      \[\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({\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) \]
    7. Taylor expanded in phi1 around 0 79.1%

      \[\leadsto R \cdot \color{blue}{\left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right) + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right)} \]
    8. Taylor expanded in phi1 around 0 78.6%

      \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\color{blue}{\cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}} + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification66.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\phi_1 \leq -0.062 \lor \neg \left(\phi_1 \leq 67000000000\right):\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\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}}}{\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} + \cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\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}}}{\sqrt{1 - \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} + {\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}\right)}}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 68.7% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \left(\phi_1 \cdot 0.5\right)\\ t_1 := \cos \left(\phi_1 \cdot 0.5\right)\\ t_2 := {\left(t\_0 \cdot \cos \left(\phi_2 \cdot 0.5\right) - t\_1 \cdot \sin \left(\phi_2 \cdot 0.5\right)\right)}^{2}\\ t_3 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\ t_4 := \cos \phi_2 \cdot t\_3\\ t_5 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ \mathbf{if}\;\phi_2 \leq -0.00018 \lor \neg \left(\phi_2 \leq 0.00072\right):\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_1 \cdot t\_4 + t\_2}}{\sqrt{1 - \left(t\_4 + t\_2\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(t\_0 + -0.5 \cdot \left(\phi_2 \cdot t\_1\right)\right)}^{2} + t\_5 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_5\right)}}{\sqrt{\left(1 + \phi_2 \cdot \left(t\_0 \cdot t\_1\right)\right) - \left(\cos \phi_1 \cdot t\_3 + {t\_0}^{2}\right)}}\right)\\ \end{array} \end{array} \]
(FPCore (R lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (sin (* phi1 0.5)))
        (t_1 (cos (* phi1 0.5)))
        (t_2
         (pow (- (* t_0 (cos (* phi2 0.5))) (* t_1 (sin (* phi2 0.5)))) 2.0))
        (t_3 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
        (t_4 (* (cos phi2) t_3))
        (t_5 (sin (/ (- lambda1 lambda2) 2.0))))
   (if (or (<= phi2 -0.00018) (not (<= phi2 0.00072)))
     (*
      R
      (*
       2.0
       (atan2 (sqrt (+ (* (cos phi1) t_4) t_2)) (sqrt (- 1.0 (+ t_4 t_2))))))
     (*
      R
      (*
       2.0
       (atan2
        (sqrt
         (+
          (pow (+ t_0 (* -0.5 (* phi2 t_1))) 2.0)
          (* t_5 (* (* (cos phi1) (cos phi2)) t_5))))
        (sqrt
         (-
          (+ 1.0 (* phi2 (* t_0 t_1)))
          (+ (* (cos phi1) t_3) (pow t_0 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = sin((phi1 * 0.5));
	double t_1 = cos((phi1 * 0.5));
	double t_2 = pow(((t_0 * cos((phi2 * 0.5))) - (t_1 * sin((phi2 * 0.5)))), 2.0);
	double t_3 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
	double t_4 = cos(phi2) * t_3;
	double t_5 = sin(((lambda1 - lambda2) / 2.0));
	double tmp;
	if ((phi2 <= -0.00018) || !(phi2 <= 0.00072)) {
		tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * t_4) + t_2)), sqrt((1.0 - (t_4 + t_2)))));
	} else {
		tmp = R * (2.0 * atan2(sqrt((pow((t_0 + (-0.5 * (phi2 * t_1))), 2.0) + (t_5 * ((cos(phi1) * cos(phi2)) * t_5)))), sqrt(((1.0 + (phi2 * (t_0 * t_1))) - ((cos(phi1) * t_3) + pow(t_0, 2.0))))));
	}
	return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
    real(8), intent (in) :: r
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: t_3
    real(8) :: t_4
    real(8) :: t_5
    real(8) :: tmp
    t_0 = sin((phi1 * 0.5d0))
    t_1 = cos((phi1 * 0.5d0))
    t_2 = ((t_0 * cos((phi2 * 0.5d0))) - (t_1 * sin((phi2 * 0.5d0)))) ** 2.0d0
    t_3 = sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
    t_4 = cos(phi2) * t_3
    t_5 = sin(((lambda1 - lambda2) / 2.0d0))
    if ((phi2 <= (-0.00018d0)) .or. (.not. (phi2 <= 0.00072d0))) then
        tmp = r * (2.0d0 * atan2(sqrt(((cos(phi1) * t_4) + t_2)), sqrt((1.0d0 - (t_4 + t_2)))))
    else
        tmp = r * (2.0d0 * atan2(sqrt((((t_0 + ((-0.5d0) * (phi2 * t_1))) ** 2.0d0) + (t_5 * ((cos(phi1) * cos(phi2)) * t_5)))), sqrt(((1.0d0 + (phi2 * (t_0 * t_1))) - ((cos(phi1) * t_3) + (t_0 ** 2.0d0))))))
    end if
    code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = Math.sin((phi1 * 0.5));
	double t_1 = Math.cos((phi1 * 0.5));
	double t_2 = Math.pow(((t_0 * Math.cos((phi2 * 0.5))) - (t_1 * Math.sin((phi2 * 0.5)))), 2.0);
	double t_3 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
	double t_4 = Math.cos(phi2) * t_3;
	double t_5 = Math.sin(((lambda1 - lambda2) / 2.0));
	double tmp;
	if ((phi2 <= -0.00018) || !(phi2 <= 0.00072)) {
		tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi1) * t_4) + t_2)), Math.sqrt((1.0 - (t_4 + t_2)))));
	} else {
		tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow((t_0 + (-0.5 * (phi2 * t_1))), 2.0) + (t_5 * ((Math.cos(phi1) * Math.cos(phi2)) * t_5)))), Math.sqrt(((1.0 + (phi2 * (t_0 * t_1))) - ((Math.cos(phi1) * t_3) + Math.pow(t_0, 2.0))))));
	}
	return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2):
	t_0 = math.sin((phi1 * 0.5))
	t_1 = math.cos((phi1 * 0.5))
	t_2 = math.pow(((t_0 * math.cos((phi2 * 0.5))) - (t_1 * math.sin((phi2 * 0.5)))), 2.0)
	t_3 = math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)
	t_4 = math.cos(phi2) * t_3
	t_5 = math.sin(((lambda1 - lambda2) / 2.0))
	tmp = 0
	if (phi2 <= -0.00018) or not (phi2 <= 0.00072):
		tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi1) * t_4) + t_2)), math.sqrt((1.0 - (t_4 + t_2)))))
	else:
		tmp = R * (2.0 * math.atan2(math.sqrt((math.pow((t_0 + (-0.5 * (phi2 * t_1))), 2.0) + (t_5 * ((math.cos(phi1) * math.cos(phi2)) * t_5)))), math.sqrt(((1.0 + (phi2 * (t_0 * t_1))) - ((math.cos(phi1) * t_3) + math.pow(t_0, 2.0))))))
	return tmp
function code(R, lambda1, lambda2, phi1, phi2)
	t_0 = sin(Float64(phi1 * 0.5))
	t_1 = cos(Float64(phi1 * 0.5))
	t_2 = Float64(Float64(t_0 * cos(Float64(phi2 * 0.5))) - Float64(t_1 * sin(Float64(phi2 * 0.5)))) ^ 2.0
	t_3 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0
	t_4 = Float64(cos(phi2) * t_3)
	t_5 = sin(Float64(Float64(lambda1 - lambda2) / 2.0))
	tmp = 0.0
	if ((phi2 <= -0.00018) || !(phi2 <= 0.00072))
		tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi1) * t_4) + t_2)), sqrt(Float64(1.0 - Float64(t_4 + t_2))))));
	else
		tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(t_0 + Float64(-0.5 * Float64(phi2 * t_1))) ^ 2.0) + Float64(t_5 * Float64(Float64(cos(phi1) * cos(phi2)) * t_5)))), sqrt(Float64(Float64(1.0 + Float64(phi2 * Float64(t_0 * t_1))) - Float64(Float64(cos(phi1) * t_3) + (t_0 ^ 2.0)))))));
	end
	return tmp
end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
	t_0 = sin((phi1 * 0.5));
	t_1 = cos((phi1 * 0.5));
	t_2 = ((t_0 * cos((phi2 * 0.5))) - (t_1 * sin((phi2 * 0.5)))) ^ 2.0;
	t_3 = sin((0.5 * (lambda1 - lambda2))) ^ 2.0;
	t_4 = cos(phi2) * t_3;
	t_5 = sin(((lambda1 - lambda2) / 2.0));
	tmp = 0.0;
	if ((phi2 <= -0.00018) || ~((phi2 <= 0.00072)))
		tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * t_4) + t_2)), sqrt((1.0 - (t_4 + t_2)))));
	else
		tmp = R * (2.0 * atan2(sqrt((((t_0 + (-0.5 * (phi2 * t_1))) ^ 2.0) + (t_5 * ((cos(phi1) * cos(phi2)) * t_5)))), sqrt(((1.0 + (phi2 * (t_0 * t_1))) - ((cos(phi1) * t_3) + (t_0 ^ 2.0))))));
	end
	tmp_2 = tmp;
end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[(N[(t$95$0 * N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(t$95$1 * N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[(N[Cos[phi2], $MachinePrecision] * t$95$3), $MachinePrecision]}, Block[{t$95$5 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -0.00018], N[Not[LessEqual[phi2, 0.00072]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$4), $MachinePrecision] + t$95$2), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$4 + t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(t$95$0 + N[(-0.5 * N[(phi2 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$5 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 + N[(phi2 * N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$3), $MachinePrecision] + N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin \left(\phi_1 \cdot 0.5\right)\\
t_1 := \cos \left(\phi_1 \cdot 0.5\right)\\
t_2 := {\left(t\_0 \cdot \cos \left(\phi_2 \cdot 0.5\right) - t\_1 \cdot \sin \left(\phi_2 \cdot 0.5\right)\right)}^{2}\\
t_3 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
t_4 := \cos \phi_2 \cdot t\_3\\
t_5 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\phi_2 \leq -0.00018 \lor \neg \left(\phi_2 \leq 0.00072\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_1 \cdot t\_4 + t\_2}}{\sqrt{1 - \left(t\_4 + t\_2\right)}}\right)\\

\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(t\_0 + -0.5 \cdot \left(\phi_2 \cdot t\_1\right)\right)}^{2} + t\_5 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_5\right)}}{\sqrt{\left(1 + \phi_2 \cdot \left(t\_0 \cdot t\_1\right)\right) - \left(\cos \phi_1 \cdot t\_3 + {t\_0}^{2}\right)}}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if phi2 < -1.80000000000000011e-4 or 7.20000000000000045e-4 < phi2

    1. Initial program 45.1%

      \[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. Add Preprocessing
    3. Step-by-step derivation
      1. div-sub45.1%

        \[\leadsto 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 \color{blue}{\left(\frac{\phi_1}{2} - \frac{\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. sin-diff47.2%

        \[\leadsto 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({\color{blue}{\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
      3. div-inv47.2%

        \[\leadsto 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({\left(\sin \color{blue}{\left(\phi_1 \cdot \frac{1}{2}\right)} \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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. metadata-eval47.2%

        \[\leadsto 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({\left(\sin \left(\phi_1 \cdot \color{blue}{0.5}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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. div-inv47.2%

        \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \color{blue}{\left(\phi_2 \cdot \frac{1}{2}\right)} - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
      6. metadata-eval47.2%

        \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot \color{blue}{0.5}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
      7. div-inv47.2%

        \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \color{blue}{\left(\phi_1 \cdot \frac{1}{2}\right)} \cdot \sin \left(\frac{\phi_2}{2}\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) \]
      8. metadata-eval47.2%

        \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \left(\phi_1 \cdot \color{blue}{0.5}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
      9. div-inv47.2%

        \[\leadsto 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({\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 \color{blue}{\left(\phi_2 \cdot \frac{1}{2}\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) \]
      10. metadata-eval47.2%

        \[\leadsto 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({\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 \color{blue}{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-rr47.2%

      \[\leadsto 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({\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) \]
    5. Step-by-step derivation
      1. div-sub45.1%

        \[\leadsto 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 \color{blue}{\left(\frac{\phi_1}{2} - \frac{\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. sin-diff47.2%

        \[\leadsto 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({\color{blue}{\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
      3. div-inv47.2%

        \[\leadsto 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({\left(\sin \color{blue}{\left(\phi_1 \cdot \frac{1}{2}\right)} \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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. metadata-eval47.2%

        \[\leadsto 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({\left(\sin \left(\phi_1 \cdot \color{blue}{0.5}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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. div-inv47.2%

        \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \color{blue}{\left(\phi_2 \cdot \frac{1}{2}\right)} - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
      6. metadata-eval47.2%

        \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot \color{blue}{0.5}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
      7. div-inv47.2%

        \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \color{blue}{\left(\phi_1 \cdot \frac{1}{2}\right)} \cdot \sin \left(\frac{\phi_2}{2}\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) \]
      8. metadata-eval47.2%

        \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \left(\phi_1 \cdot \color{blue}{0.5}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
      9. div-inv47.2%

        \[\leadsto 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({\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 \color{blue}{\left(\phi_2 \cdot \frac{1}{2}\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) \]
      10. metadata-eval47.2%

        \[\leadsto 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({\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 \color{blue}{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) \]
    6. Applied egg-rr79.6%

      \[\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({\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) \]
    7. Taylor expanded in phi1 around 0 79.6%

      \[\leadsto R \cdot \color{blue}{\left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right) + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right)} \]
    8. Taylor expanded in phi1 around 0 57.5%

      \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\color{blue}{\cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}} + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right) \]

    if -1.80000000000000011e-4 < phi2 < 7.20000000000000045e-4

    1. Initial program 76.4%

      \[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. Add Preprocessing
    3. Taylor expanded in phi2 around 0 76.5%

      \[\leadsto 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{\color{blue}{\left(1 + \phi_2 \cdot \left(\cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_1\right)\right)\right) - \left(\cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} + {\sin \left(0.5 \cdot \phi_1\right)}^{2}\right)}}}\right) \]
    4. Taylor expanded in phi2 around 0 77.4%

      \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\color{blue}{\left(\sin \left(0.5 \cdot \phi_1\right) + -0.5 \cdot \left(\phi_2 \cdot \cos \left(0.5 \cdot \phi_1\right)\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{\left(1 + \phi_2 \cdot \left(\cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_1\right)\right)\right) - \left(\cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} + {\sin \left(0.5 \cdot \phi_1\right)}^{2}\right)}}\right) \]
    5. Step-by-step derivation
      1. *-commutative77.4%

        \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\sin \color{blue}{\left(\phi_1 \cdot 0.5\right)} + -0.5 \cdot \left(\phi_2 \cdot \cos \left(0.5 \cdot \phi_1\right)\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{\left(1 + \phi_2 \cdot \left(\cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_1\right)\right)\right) - \left(\cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} + {\sin \left(0.5 \cdot \phi_1\right)}^{2}\right)}}\right) \]
      2. *-commutative77.4%

        \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\sin \left(\phi_1 \cdot 0.5\right) + -0.5 \cdot \left(\phi_2 \cdot \cos \color{blue}{\left(\phi_1 \cdot 0.5\right)}\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{\left(1 + \phi_2 \cdot \left(\cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_1\right)\right)\right) - \left(\cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} + {\sin \left(0.5 \cdot \phi_1\right)}^{2}\right)}}\right) \]
    6. Simplified77.4%

      \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\color{blue}{\left(\sin \left(\phi_1 \cdot 0.5\right) + -0.5 \cdot \left(\phi_2 \cdot \cos \left(\phi_1 \cdot 0.5\right)\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{\left(1 + \phi_2 \cdot \left(\cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_1\right)\right)\right) - \left(\cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} + {\sin \left(0.5 \cdot \phi_1\right)}^{2}\right)}}\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification65.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\phi_2 \leq -0.00018 \lor \neg \left(\phi_2 \leq 0.00072\right):\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\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}}}{\sqrt{1 - \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} + {\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}\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\sin \left(\phi_1 \cdot 0.5\right) + -0.5 \cdot \left(\phi_2 \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)\right)}^{2} + \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)}}{\sqrt{\left(1 + \phi_2 \cdot \left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)\right) - \left(\cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 79.0% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\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}\\ R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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\_0}}{\sqrt{1 + \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(\frac{\cos \left(\lambda_2 - \lambda_1\right)}{2} - 0.5\right)\right) - t\_0\right)}}\right) \end{array} \end{array} \]
(FPCore (R lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0
         (pow
          (-
           (* (sin (* phi1 0.5)) (cos (* phi2 0.5)))
           (* (cos (* phi1 0.5)) (sin (* phi2 0.5))))
          2.0)))
   (*
    R
    (*
     2.0
     (atan2
      (sqrt
       (+
        (*
         (cos phi1)
         (* (cos phi2) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0)))
        t_0))
      (sqrt
       (+
        1.0
        (-
         (*
          (cos phi1)
          (* (cos phi2) (- (/ (cos (- lambda2 lambda1)) 2.0) 0.5)))
         t_0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = pow(((sin((phi1 * 0.5)) * cos((phi2 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))), 2.0);
	return R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0))) + t_0)), sqrt((1.0 + ((cos(phi1) * (cos(phi2) * ((cos((lambda2 - lambda1)) / 2.0) - 0.5))) - t_0)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
    real(8), intent (in) :: r
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    real(8) :: t_0
    t_0 = ((sin((phi1 * 0.5d0)) * cos((phi2 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((phi2 * 0.5d0)))) ** 2.0d0
    code = r * (2.0d0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0))) + t_0)), sqrt((1.0d0 + ((cos(phi1) * (cos(phi2) * ((cos((lambda2 - lambda1)) / 2.0d0) - 0.5d0))) - t_0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = Math.pow(((Math.sin((phi1 * 0.5)) * Math.cos((phi2 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((phi2 * 0.5)))), 2.0);
	return R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0))) + t_0)), Math.sqrt((1.0 + ((Math.cos(phi1) * (Math.cos(phi2) * ((Math.cos((lambda2 - lambda1)) / 2.0) - 0.5))) - t_0)))));
}
def code(R, lambda1, lambda2, phi1, phi2):
	t_0 = math.pow(((math.sin((phi1 * 0.5)) * math.cos((phi2 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((phi2 * 0.5)))), 2.0)
	return R * (2.0 * math.atan2(math.sqrt(((math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0))) + t_0)), math.sqrt((1.0 + ((math.cos(phi1) * (math.cos(phi2) * ((math.cos((lambda2 - lambda1)) / 2.0) - 0.5))) - t_0)))))
function code(R, lambda1, lambda2, phi1, phi2)
	t_0 = Float64(Float64(sin(Float64(phi1 * 0.5)) * cos(Float64(phi2 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(phi2 * 0.5)))) ^ 2.0
	return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0))) + t_0)), sqrt(Float64(1.0 + Float64(Float64(cos(phi1) * Float64(cos(phi2) * Float64(Float64(cos(Float64(lambda2 - lambda1)) / 2.0) - 0.5))) - t_0))))))
end
function tmp = code(R, lambda1, lambda2, phi1, phi2)
	t_0 = ((sin((phi1 * 0.5)) * cos((phi2 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))) ^ 2.0;
	tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0))) + t_0)), sqrt((1.0 + ((cos(phi1) * (cos(phi2) * ((cos((lambda2 - lambda1)) / 2.0) - 0.5))) - t_0)))));
end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[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$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\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}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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\_0}}{\sqrt{1 + \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(\frac{\cos \left(\lambda_2 - \lambda_1\right)}{2} - 0.5\right)\right) - t\_0\right)}}\right)
\end{array}
\end{array}
Derivation
  1. Initial program 58.3%

    \[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. Add Preprocessing
  3. Step-by-step derivation
    1. div-sub58.3%

      \[\leadsto 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 \color{blue}{\left(\frac{\phi_1}{2} - \frac{\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. sin-diff59.5%

      \[\leadsto 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({\color{blue}{\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
    3. div-inv59.5%

      \[\leadsto 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({\left(\sin \color{blue}{\left(\phi_1 \cdot \frac{1}{2}\right)} \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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. metadata-eval59.5%

      \[\leadsto 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({\left(\sin \left(\phi_1 \cdot \color{blue}{0.5}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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. div-inv59.5%

      \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \color{blue}{\left(\phi_2 \cdot \frac{1}{2}\right)} - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
    6. metadata-eval59.5%

      \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot \color{blue}{0.5}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
    7. div-inv59.5%

      \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \color{blue}{\left(\phi_1 \cdot \frac{1}{2}\right)} \cdot \sin \left(\frac{\phi_2}{2}\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) \]
    8. metadata-eval59.5%

      \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \left(\phi_1 \cdot \color{blue}{0.5}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
    9. div-inv59.5%

      \[\leadsto 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({\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 \color{blue}{\left(\phi_2 \cdot \frac{1}{2}\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) \]
    10. metadata-eval59.5%

      \[\leadsto 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({\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 \color{blue}{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-rr59.5%

    \[\leadsto 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({\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) \]
  5. Step-by-step derivation
    1. div-sub58.3%

      \[\leadsto 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 \color{blue}{\left(\frac{\phi_1}{2} - \frac{\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. sin-diff59.5%

      \[\leadsto 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({\color{blue}{\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
    3. div-inv59.5%

      \[\leadsto 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({\left(\sin \color{blue}{\left(\phi_1 \cdot \frac{1}{2}\right)} \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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. metadata-eval59.5%

      \[\leadsto 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({\left(\sin \left(\phi_1 \cdot \color{blue}{0.5}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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. div-inv59.5%

      \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \color{blue}{\left(\phi_2 \cdot \frac{1}{2}\right)} - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
    6. metadata-eval59.5%

      \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot \color{blue}{0.5}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
    7. div-inv59.5%

      \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \color{blue}{\left(\phi_1 \cdot \frac{1}{2}\right)} \cdot \sin \left(\frac{\phi_2}{2}\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) \]
    8. metadata-eval59.5%

      \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \left(\phi_1 \cdot \color{blue}{0.5}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
    9. div-inv59.5%

      \[\leadsto 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({\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 \color{blue}{\left(\phi_2 \cdot \frac{1}{2}\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) \]
    10. metadata-eval59.5%

      \[\leadsto 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({\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 \color{blue}{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) \]
  6. Applied egg-rr78.7%

    \[\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({\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) \]
  7. Taylor expanded in phi1 around 0 78.7%

    \[\leadsto R \cdot \color{blue}{\left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right) + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right)} \]
  8. Step-by-step derivation
    1. *-commutative78.7%

      \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \color{blue}{\left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}}^{2}\right) + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right) \]
    2. metadata-eval78.7%

      \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{\frac{1}{2}}\right)}^{2}\right) + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right) \]
    3. div-inv78.7%

      \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \color{blue}{\left(\frac{\lambda_1 - \lambda_2}{2}\right)}}^{2}\right) + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right) \]
    4. pow278.7%

      \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \color{blue}{\left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}\right) + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right) \]
    5. sin-mult78.7%

      \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \color{blue}{\frac{\cos \left(\frac{\lambda_1 - \lambda_2}{2} - \frac{\lambda_1 - \lambda_2}{2}\right) - \cos \left(\frac{\lambda_1 - \lambda_2}{2} + \frac{\lambda_1 - \lambda_2}{2}\right)}{2}}\right) + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right) \]
  9. Applied egg-rr78.7%

    \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \color{blue}{\frac{\cos \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right) - 0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) - \cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)}{2}}\right) + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right) \]
  10. Step-by-step derivation
    1. div-sub78.7%

      \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \color{blue}{\left(\frac{\cos \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right) - 0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}{2} - \frac{\cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)}{2}\right)}\right) + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right) \]
    2. +-inverses78.7%

      \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(\frac{\cos \color{blue}{0}}{2} - \frac{\cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)}{2}\right)\right) + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right) \]
    3. +-inverses78.7%

      \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(\frac{\cos \color{blue}{\left(0.5 \cdot \left(-\phi_2\right) - 0.5 \cdot \left(-\phi_2\right)\right)}}{2} - \frac{\cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)}{2}\right)\right) + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right) \]
    4. +-inverses78.7%

      \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(\frac{\cos \color{blue}{0}}{2} - \frac{\cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)}{2}\right)\right) + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right) \]
    5. cos-078.7%

      \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(\frac{\color{blue}{1}}{2} - \frac{\cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)}{2}\right)\right) + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right) \]
    6. metadata-eval78.7%

      \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(\color{blue}{0.5} - \frac{\cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)}{2}\right)\right) + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right) \]
    7. associate-*r*78.7%

      \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(0.5 - \frac{\cos \color{blue}{\left(\left(2 \cdot 0.5\right) \cdot \left(\lambda_1 - \lambda_2\right)\right)}}{2}\right)\right) + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right) \]
    8. metadata-eval78.7%

      \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(0.5 - \frac{\cos \left(\color{blue}{1} \cdot \left(\lambda_1 - \lambda_2\right)\right)}{2}\right)\right) + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right) \]
    9. *-lft-identity78.7%

      \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(0.5 - \frac{\cos \color{blue}{\left(\lambda_1 - \lambda_2\right)}}{2}\right)\right) + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right) \]
    10. sub-neg78.7%

      \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(0.5 - \frac{\cos \color{blue}{\left(\lambda_1 + \left(-\lambda_2\right)\right)}}{2}\right)\right) + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right) \]
    11. remove-double-neg78.7%

      \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(0.5 - \frac{\cos \left(\color{blue}{\left(-\left(-\lambda_1\right)\right)} + \left(-\lambda_2\right)\right)}{2}\right)\right) + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right) \]
    12. mul-1-neg78.7%

      \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(0.5 - \frac{\cos \left(\left(-\color{blue}{-1 \cdot \lambda_1}\right) + \left(-\lambda_2\right)\right)}{2}\right)\right) + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right) \]
    13. distribute-neg-in78.7%

      \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(0.5 - \frac{\cos \color{blue}{\left(-\left(-1 \cdot \lambda_1 + \lambda_2\right)\right)}}{2}\right)\right) + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right) \]
    14. +-commutative78.7%

      \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(0.5 - \frac{\cos \left(-\color{blue}{\left(\lambda_2 + -1 \cdot \lambda_1\right)}\right)}{2}\right)\right) + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right) \]
    15. cos-neg78.7%

      \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(0.5 - \frac{\color{blue}{\cos \left(\lambda_2 + -1 \cdot \lambda_1\right)}}{2}\right)\right) + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right) \]
    16. mul-1-neg78.7%

      \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(0.5 - \frac{\cos \left(\lambda_2 + \color{blue}{\left(-\lambda_1\right)}\right)}{2}\right)\right) + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right) \]
    17. unsub-neg78.7%

      \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(0.5 - \frac{\cos \color{blue}{\left(\lambda_2 - \lambda_1\right)}}{2}\right)\right) + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right) \]
  11. Simplified78.7%

    \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \color{blue}{\left(0.5 - \frac{\cos \left(\lambda_2 - \lambda_1\right)}{2}\right)}\right) + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right) \]
  12. Final simplification78.7%

    \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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(\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}}}{\sqrt{1 + \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(\frac{\cos \left(\lambda_2 - \lambda_1\right)}{2} - 0.5\right)\right) - {\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}\right)}}\right) \]
  13. Add Preprocessing

Alternative 5: 63.3% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \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({\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} + t\_1\right)}}\right) \end{array} \end{array} \]
(FPCore (R lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
        (t_1 (* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
   (*
    R
    (*
     2.0
     (atan2
      (sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
      (sqrt
       (-
        1.0
        (+
         (pow
          (-
           (* (sin (* phi1 0.5)) (cos (* phi2 0.5)))
           (* (cos (* phi1 0.5)) (sin (* phi2 0.5))))
          2.0)
         t_1))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = sin(((lambda1 - lambda2) / 2.0));
	double t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
	return R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - (pow(((sin((phi1 * 0.5)) * cos((phi2 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))), 2.0) + t_1)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
    real(8), intent (in) :: r
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    real(8) :: t_0
    real(8) :: t_1
    t_0 = sin(((lambda1 - lambda2) / 2.0d0))
    t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0)
    code = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - ((((sin((phi1 * 0.5d0)) * cos((phi2 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((phi2 * 0.5d0)))) ** 2.0d0) + t_1)))))
end function
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 = t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0);
	return R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 - (Math.pow(((Math.sin((phi1 * 0.5)) * Math.cos((phi2 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((phi2 * 0.5)))), 2.0) + t_1)))));
}
def code(R, lambda1, lambda2, phi1, phi2):
	t_0 = math.sin(((lambda1 - lambda2) / 2.0))
	t_1 = t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)
	return R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 - (math.pow(((math.sin((phi1 * 0.5)) * math.cos((phi2 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((phi2 * 0.5)))), 2.0) + t_1)))))
function code(R, lambda1, lambda2, phi1, phi2)
	t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0))
	t_1 = Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0))
	return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - Float64((Float64(Float64(sin(Float64(phi1 * 0.5)) * cos(Float64(phi2 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(phi2 * 0.5)))) ^ 2.0) + t_1))))))
end
function tmp = code(R, lambda1, lambda2, phi1, phi2)
	t_0 = sin(((lambda1 - lambda2) / 2.0));
	t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
	tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 - ((((sin((phi1 * 0.5)) * cos((phi2 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))) ^ 2.0) + t_1)))));
end
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[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\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({\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} + t\_1\right)}}\right)
\end{array}
\end{array}
Derivation
  1. Initial program 58.3%

    \[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. Add Preprocessing
  3. Step-by-step derivation
    1. div-sub58.3%

      \[\leadsto 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 \color{blue}{\left(\frac{\phi_1}{2} - \frac{\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. sin-diff59.5%

      \[\leadsto 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({\color{blue}{\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
    3. div-inv59.5%

      \[\leadsto 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({\left(\sin \color{blue}{\left(\phi_1 \cdot \frac{1}{2}\right)} \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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. metadata-eval59.5%

      \[\leadsto 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({\left(\sin \left(\phi_1 \cdot \color{blue}{0.5}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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. div-inv59.5%

      \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \color{blue}{\left(\phi_2 \cdot \frac{1}{2}\right)} - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
    6. metadata-eval59.5%

      \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot \color{blue}{0.5}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
    7. div-inv59.5%

      \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \color{blue}{\left(\phi_1 \cdot \frac{1}{2}\right)} \cdot \sin \left(\frac{\phi_2}{2}\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) \]
    8. metadata-eval59.5%

      \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \left(\phi_1 \cdot \color{blue}{0.5}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
    9. div-inv59.5%

      \[\leadsto 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({\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 \color{blue}{\left(\phi_2 \cdot \frac{1}{2}\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) \]
    10. metadata-eval59.5%

      \[\leadsto 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({\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 \color{blue}{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-rr59.5%

    \[\leadsto 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({\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) \]
  5. Final simplification59.5%

    \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\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) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\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} + \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)\right)}}\right) \]
  6. Add Preprocessing

Alternative 6: 63.3% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \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{{\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} + t\_1}}{\sqrt{1 + \left(\left(\frac{\cos \left(\phi_1 - \phi_2\right)}{2} - 0.5\right) - t\_1\right)}}\right) \end{array} \end{array} \]
(FPCore (R lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
        (t_1 (* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
   (*
    R
    (*
     2.0
     (atan2
      (sqrt
       (+
        (pow
         (-
          (* (sin (* phi1 0.5)) (cos (* phi2 0.5)))
          (* (cos (* phi1 0.5)) (sin (* phi2 0.5))))
         2.0)
        t_1))
      (sqrt (+ 1.0 (- (- (/ (cos (- phi1 phi2)) 2.0) 0.5) t_1))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = sin(((lambda1 - lambda2) / 2.0));
	double t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
	return R * (2.0 * atan2(sqrt((pow(((sin((phi1 * 0.5)) * cos((phi2 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))), 2.0) + t_1)), sqrt((1.0 + (((cos((phi1 - phi2)) / 2.0) - 0.5) - t_1)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
    real(8), intent (in) :: r
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    real(8) :: t_0
    real(8) :: t_1
    t_0 = sin(((lambda1 - lambda2) / 2.0d0))
    t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0)
    code = r * (2.0d0 * atan2(sqrt(((((sin((phi1 * 0.5d0)) * cos((phi2 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((phi2 * 0.5d0)))) ** 2.0d0) + t_1)), sqrt((1.0d0 + (((cos((phi1 - phi2)) / 2.0d0) - 0.5d0) - t_1)))))
end function
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 = t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0);
	return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(((Math.sin((phi1 * 0.5)) * Math.cos((phi2 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((phi2 * 0.5)))), 2.0) + t_1)), Math.sqrt((1.0 + (((Math.cos((phi1 - phi2)) / 2.0) - 0.5) - t_1)))));
}
def code(R, lambda1, lambda2, phi1, phi2):
	t_0 = math.sin(((lambda1 - lambda2) / 2.0))
	t_1 = t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)
	return R * (2.0 * math.atan2(math.sqrt((math.pow(((math.sin((phi1 * 0.5)) * math.cos((phi2 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((phi2 * 0.5)))), 2.0) + t_1)), math.sqrt((1.0 + (((math.cos((phi1 - phi2)) / 2.0) - 0.5) - t_1)))))
function code(R, lambda1, lambda2, phi1, phi2)
	t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0))
	t_1 = Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0))
	return Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(Float64(sin(Float64(phi1 * 0.5)) * cos(Float64(phi2 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(phi2 * 0.5)))) ^ 2.0) + t_1)), sqrt(Float64(1.0 + Float64(Float64(Float64(cos(Float64(phi1 - phi2)) / 2.0) - 0.5) - t_1))))))
end
function tmp = code(R, lambda1, lambda2, phi1, phi2)
	t_0 = sin(((lambda1 - lambda2) / 2.0));
	t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
	tmp = R * (2.0 * atan2(sqrt(((((sin((phi1 * 0.5)) * cos((phi2 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))) ^ 2.0) + t_1)), sqrt((1.0 + (((cos((phi1 - phi2)) / 2.0) - 0.5) - t_1)))));
end
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[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 + N[(N[(N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision] - t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\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{{\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} + t\_1}}{\sqrt{1 + \left(\left(\frac{\cos \left(\phi_1 - \phi_2\right)}{2} - 0.5\right) - t\_1\right)}}\right)
\end{array}
\end{array}
Derivation
  1. Initial program 58.3%

    \[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. Add Preprocessing
  3. Step-by-step derivation
    1. div-sub58.3%

      \[\leadsto 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 \color{blue}{\left(\frac{\phi_1}{2} - \frac{\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. sin-diff59.5%

      \[\leadsto 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({\color{blue}{\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
    3. div-inv59.5%

      \[\leadsto 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({\left(\sin \color{blue}{\left(\phi_1 \cdot \frac{1}{2}\right)} \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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. metadata-eval59.5%

      \[\leadsto 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({\left(\sin \left(\phi_1 \cdot \color{blue}{0.5}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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. div-inv59.5%

      \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \color{blue}{\left(\phi_2 \cdot \frac{1}{2}\right)} - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
    6. metadata-eval59.5%

      \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot \color{blue}{0.5}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
    7. div-inv59.5%

      \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \color{blue}{\left(\phi_1 \cdot \frac{1}{2}\right)} \cdot \sin \left(\frac{\phi_2}{2}\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) \]
    8. metadata-eval59.5%

      \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \left(\phi_1 \cdot \color{blue}{0.5}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
    9. div-inv59.5%

      \[\leadsto 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({\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 \color{blue}{\left(\phi_2 \cdot \frac{1}{2}\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) \]
    10. metadata-eval59.5%

      \[\leadsto 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({\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 \color{blue}{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-rr59.5%

    \[\leadsto 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({\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) \]
  5. Step-by-step derivation
    1. div-sub58.3%

      \[\leadsto 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 \color{blue}{\left(\frac{\phi_1}{2} - \frac{\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. sin-diff59.5%

      \[\leadsto 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({\color{blue}{\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
    3. div-inv59.5%

      \[\leadsto 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({\left(\sin \color{blue}{\left(\phi_1 \cdot \frac{1}{2}\right)} \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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. metadata-eval59.5%

      \[\leadsto 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({\left(\sin \left(\phi_1 \cdot \color{blue}{0.5}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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. div-inv59.5%

      \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \color{blue}{\left(\phi_2 \cdot \frac{1}{2}\right)} - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
    6. metadata-eval59.5%

      \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot \color{blue}{0.5}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
    7. div-inv59.5%

      \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \color{blue}{\left(\phi_1 \cdot \frac{1}{2}\right)} \cdot \sin \left(\frac{\phi_2}{2}\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) \]
    8. metadata-eval59.5%

      \[\leadsto 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({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \left(\phi_1 \cdot \color{blue}{0.5}\right) \cdot \sin \left(\frac{\phi_2}{2}\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) \]
    9. div-inv59.5%

      \[\leadsto 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({\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 \color{blue}{\left(\phi_2 \cdot \frac{1}{2}\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) \]
    10. metadata-eval59.5%

      \[\leadsto 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({\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 \color{blue}{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) \]
  6. Applied egg-rr78.7%

    \[\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({\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) \]
  7. Step-by-step derivation
    1. sin-diff59.4%

      \[\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}{\sin \left(\phi_1 \cdot 0.5 - \phi_2 \cdot 0.5\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. metadata-eval59.4%

      \[\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({\sin \left(\phi_1 \cdot \color{blue}{\frac{1}{2}} - \phi_2 \cdot 0.5\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. div-inv59.4%

      \[\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({\sin \left(\color{blue}{\frac{\phi_1}{2}} - \phi_2 \cdot 0.5\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. metadata-eval59.4%

      \[\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({\sin \left(\frac{\phi_1}{2} - \phi_2 \cdot \color{blue}{\frac{1}{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) \]
    5. div-inv59.4%

      \[\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({\sin \left(\frac{\phi_1}{2} - \color{blue}{\frac{\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) \]
    6. div-sub59.4%

      \[\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({\sin \color{blue}{\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) \]
    7. div-inv59.4%

      \[\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({\sin \color{blue}{\left(\left(\phi_1 - \phi_2\right) \cdot \frac{1}{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) \]
    8. metadata-eval59.4%

      \[\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({\sin \left(\left(\phi_1 - \phi_2\right) \cdot \color{blue}{0.5}\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) \]
    9. *-commutative59.4%

      \[\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({\sin \color{blue}{\left(0.5 \cdot \left(\phi_1 - \phi_2\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) \]
    10. *-commutative59.4%

      \[\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({\sin \color{blue}{\left(\left(\phi_1 - \phi_2\right) \cdot 0.5\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) \]
    11. metadata-eval59.4%

      \[\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({\sin \left(\left(\phi_1 - \phi_2\right) \cdot \color{blue}{\frac{1}{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) \]
    12. div-inv59.4%

      \[\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({\sin \color{blue}{\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) \]
    13. unpow259.4%

      \[\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}{\sin \left(\frac{\phi_1 - \phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1 - \phi_2}{2}\right)} + \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) \]
    14. sin-mult59.5%

      \[\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}{\frac{\cos \left(\frac{\phi_1 - \phi_2}{2} - \frac{\phi_1 - \phi_2}{2}\right) - \cos \left(\frac{\phi_1 - \phi_2}{2} + \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) \]
  8. Applied egg-rr59.5%

    \[\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}{\frac{\cos \left(0.5 \cdot \left(\phi_1 - \phi_2\right) - 0.5 \cdot \left(\phi_1 - \phi_2\right)\right) - \cos \left(0.5 \cdot \left(\phi_1 - \phi_2\right) + 0.5 \cdot \left(\phi_1 - \phi_2\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) \]
  9. Step-by-step derivation
    1. div-sub59.5%

      \[\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(\frac{\cos \left(0.5 \cdot \left(\phi_1 - \phi_2\right) - 0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}{2} - \frac{\cos \left(0.5 \cdot \left(\phi_1 - \phi_2\right) + 0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}{2}\right)} + \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. +-inverses59.5%

      \[\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(\left(\frac{\cos \color{blue}{0}}{2} - \frac{\cos \left(0.5 \cdot \left(\phi_1 - \phi_2\right) + 0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}{2}\right) + \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. cos-059.5%

      \[\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(\left(\frac{\color{blue}{1}}{2} - \frac{\cos \left(0.5 \cdot \left(\phi_1 - \phi_2\right) + 0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}{2}\right) + \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. metadata-eval59.5%

      \[\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(\left(\color{blue}{0.5} - \frac{\cos \left(0.5 \cdot \left(\phi_1 - \phi_2\right) + 0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}{2}\right) + \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. distribute-rgt-out59.5%

      \[\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(\left(0.5 - \frac{\cos \color{blue}{\left(\left(\phi_1 - \phi_2\right) \cdot \left(0.5 + 0.5\right)\right)}}{2}\right) + \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) \]
    6. metadata-eval59.5%

      \[\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(\left(0.5 - \frac{\cos \left(\left(\phi_1 - \phi_2\right) \cdot \color{blue}{1}\right)}{2}\right) + \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) \]
    7. *-rgt-identity59.5%

      \[\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(\left(0.5 - \frac{\cos \color{blue}{\left(\phi_1 - \phi_2\right)}}{2}\right) + \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) \]
  10. Simplified59.5%

    \[\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(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)} + \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) \]
  11. Final simplification59.5%

    \[\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} + \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)}}{\sqrt{1 + \left(\left(\frac{\cos \left(\phi_1 - \phi_2\right)}{2} - 0.5\right) - \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)\right)}}\right) \]
  12. Add Preprocessing

Alternative 7: 63.3% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \tan^{-1}_* \frac{\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(\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}}}{\sqrt{1 + \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right) - 0.5\right)\right) - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}} \cdot \left(R \cdot 2\right) \end{array} \]
(FPCore (R lambda1 lambda2 phi1 phi2)
 :precision binary64
 (*
  (atan2
   (sqrt
    (+
     (* (cos phi1) (* (cos phi2) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0)))
     (pow
      (-
       (* (sin (* phi1 0.5)) (cos (* phi2 0.5)))
       (* (cos (* phi1 0.5)) (sin (* phi2 0.5))))
      2.0)))
   (sqrt
    (+
     1.0
     (-
      (* (cos phi1) (* (cos phi2) (- (* 0.5 (cos (- lambda1 lambda2))) 0.5)))
      (pow (sin (* 0.5 (- phi1 phi2))) 2.0)))))
  (* R 2.0)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	return atan2(sqrt(((cos(phi1) * (cos(phi2) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0))) + pow(((sin((phi1 * 0.5)) * cos((phi2 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))), 2.0))), sqrt((1.0 + ((cos(phi1) * (cos(phi2) * ((0.5 * cos((lambda1 - lambda2))) - 0.5))) - pow(sin((0.5 * (phi1 - phi2))), 2.0))))) * (R * 2.0);
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
    real(8), intent (in) :: r
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    code = atan2(sqrt(((cos(phi1) * (cos(phi2) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0))) + (((sin((phi1 * 0.5d0)) * cos((phi2 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((phi2 * 0.5d0)))) ** 2.0d0))), sqrt((1.0d0 + ((cos(phi1) * (cos(phi2) * ((0.5d0 * cos((lambda1 - lambda2))) - 0.5d0))) - (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0))))) * (r * 2.0d0)
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	return Math.atan2(Math.sqrt(((Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0))) + Math.pow(((Math.sin((phi1 * 0.5)) * Math.cos((phi2 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((phi2 * 0.5)))), 2.0))), Math.sqrt((1.0 + ((Math.cos(phi1) * (Math.cos(phi2) * ((0.5 * Math.cos((lambda1 - lambda2))) - 0.5))) - Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0))))) * (R * 2.0);
}
def code(R, lambda1, lambda2, phi1, phi2):
	return math.atan2(math.sqrt(((math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0))) + math.pow(((math.sin((phi1 * 0.5)) * math.cos((phi2 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((phi2 * 0.5)))), 2.0))), math.sqrt((1.0 + ((math.cos(phi1) * (math.cos(phi2) * ((0.5 * math.cos((lambda1 - lambda2))) - 0.5))) - math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0))))) * (R * 2.0)
function code(R, lambda1, lambda2, phi1, phi2)
	return Float64(atan(sqrt(Float64(Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0))) + (Float64(Float64(sin(Float64(phi1 * 0.5)) * cos(Float64(phi2 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(phi2 * 0.5)))) ^ 2.0))), sqrt(Float64(1.0 + Float64(Float64(cos(phi1) * Float64(cos(phi2) * Float64(Float64(0.5 * cos(Float64(lambda1 - lambda2))) - 0.5))) - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0))))) * Float64(R * 2.0))
end
function tmp = code(R, lambda1, lambda2, phi1, phi2)
	tmp = atan2(sqrt(((cos(phi1) * (cos(phi2) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0))) + (((sin((phi1 * 0.5)) * cos((phi2 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))) ^ 2.0))), sqrt((1.0 + ((cos(phi1) * (cos(phi2) * ((0.5 * cos((lambda1 - lambda2))) - 0.5))) - (sin((0.5 * (phi1 - phi2))) ^ 2.0))))) * (R * 2.0);
end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcTan[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] + N[Power[N[(N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(R * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\tan^{-1}_* \frac{\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(\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}}}{\sqrt{1 + \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right) - 0.5\right)\right) - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}} \cdot \left(R \cdot 2\right)
\end{array}
Derivation
  1. Initial program 58.3%

    \[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. Step-by-step derivation
    1. Simplified58.3%

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

      \[\leadsto \color{blue}{{\left(\tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right), \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}\right)}} \cdot \left(2 \cdot R\right)\right)}^{1}} \]
    4. Step-by-step derivation
      1. unpow143.0%

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

      \[\leadsto \color{blue}{\tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right), \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}} \cdot \left(2 \cdot R\right)} \]
    6. Step-by-step derivation
      1. *-commutative43.0%

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

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

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

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

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

      \[\leadsto \tan^{-1}_* \frac{\mathsf{hypot}\left(\color{blue}{\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)}, \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}} \cdot \left(2 \cdot R\right) \]
    8. Step-by-step derivation
      1. fma-neg43.3%

        \[\leadsto \tan^{-1}_* \frac{\mathsf{hypot}\left(\color{blue}{\mathsf{fma}\left(\sin \left(\frac{\phi_1}{2}\right), \cos \left(\frac{\phi_2}{2}\right), -\cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}, \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}} \cdot \left(2 \cdot R\right) \]
      2. distribute-rgt-neg-in43.3%

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

      \[\leadsto \tan^{-1}_* \frac{\mathsf{hypot}\left(\color{blue}{\mathsf{fma}\left(\sin \left(\frac{\phi_1}{2}\right), \cos \left(\frac{\phi_2}{2}\right), \cos \left(\frac{\phi_1}{2}\right) \cdot \left(-\sin \left(\frac{\phi_2}{2}\right)\right)\right)}, \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}} \cdot \left(2 \cdot R\right) \]
    10. Taylor expanded in phi1 around 0 59.4%

      \[\leadsto \color{blue}{\tan^{-1}_* \frac{\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(-1 \cdot \left(\cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right) + \cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right) + {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}}} \cdot \left(2 \cdot R\right) \]
    11. Final simplification59.4%

      \[\leadsto \tan^{-1}_* \frac{\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(\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}}}{\sqrt{1 + \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right) - 0.5\right)\right) - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}} \cdot \left(R \cdot 2\right) \]
    12. Add Preprocessing

    Alternative 8: 62.9% accurate, 0.9× speedup?

    \[\begin{array}{l} \\ \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{t\_1 \cdot \left(t\_0 \cdot t\_1\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\left|-1 + \mathsf{fma}\left(t\_0, 0.5 + -0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)\right|}}\right) \end{array} \end{array} \]
    (FPCore (R lambda1 lambda2 phi1 phi2)
     :precision binary64
     (let* ((t_0 (* (cos phi1) (cos phi2)))
            (t_1 (sin (/ (- lambda1 lambda2) 2.0))))
       (*
        R
        (*
         2.0
         (atan2
          (sqrt (+ (* t_1 (* t_0 t_1)) (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
          (sqrt
           (fabs
            (+
             -1.0
             (fma
              t_0
              (+ 0.5 (* -0.5 (cos (- lambda1 lambda2))))
              (pow (sin (* 0.5 (- phi1 phi2))) 2.0))))))))))
    double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
    	double t_0 = cos(phi1) * cos(phi2);
    	double t_1 = sin(((lambda1 - lambda2) / 2.0));
    	return R * (2.0 * atan2(sqrt(((t_1 * (t_0 * t_1)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(fabs((-1.0 + fma(t_0, (0.5 + (-0.5 * cos((lambda1 - lambda2)))), pow(sin((0.5 * (phi1 - phi2))), 2.0)))))));
    }
    
    function code(R, lambda1, lambda2, phi1, phi2)
    	t_0 = Float64(cos(phi1) * cos(phi2))
    	t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0))
    	return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(t_0 * t_1)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(abs(Float64(-1.0 + fma(t_0, Float64(0.5 + Float64(-0.5 * cos(Float64(lambda1 - lambda2)))), (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0))))))))
    end
    
    code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Abs[N[(-1.0 + N[(t$95$0 * N[(0.5 + N[(-0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
    
    \begin{array}{l}
    
    \\
    \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{t\_1 \cdot \left(t\_0 \cdot t\_1\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\left|-1 + \mathsf{fma}\left(t\_0, 0.5 + -0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)\right|}}\right)
    \end{array}
    \end{array}
    
    Derivation
    1. Initial program 58.3%

      \[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. Add Preprocessing
    3. Applied egg-rr58.9%

      \[\leadsto 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{\color{blue}{{\left({\left(1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}\right)\right)}^{2}\right)}^{0.5}}}}\right) \]
    4. Step-by-step derivation
      1. unpow1/258.9%

        \[\leadsto 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{\color{blue}{\sqrt{{\left(1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}\right)\right)}^{2}}}}}\right) \]
      2. unpow258.9%

        \[\leadsto 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{\sqrt{\color{blue}{\left(1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}\right)\right) \cdot \left(1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}\right)\right)}}}}\right) \]
      3. rem-sqrt-square58.9%

        \[\leadsto 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{\color{blue}{\left|1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}\right)\right|}}}\right) \]
      4. fma-define58.9%

        \[\leadsto 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{\left|1 - \color{blue}{\left(\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right) + {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}\right)}\right|}}\right) \]
      5. *-commutative58.9%

        \[\leadsto 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{\left|1 - \left(\color{blue}{\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)} + {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}\right)\right|}}\right) \]
      6. fma-define58.9%

        \[\leadsto 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{\left|1 - \color{blue}{\mathsf{fma}\left(\cos \phi_1 \cdot \cos \phi_2, 0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}\right)}\right|}}\right) \]
    5. Simplified58.9%

      \[\leadsto 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{\color{blue}{\left|1 - \mathsf{fma}\left(\cos \phi_1 \cdot \cos \phi_2, 0.5 + -0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)\right|}}}\right) \]
    6. Final simplification58.9%

      \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\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) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\left|-1 + \mathsf{fma}\left(\cos \phi_1 \cdot \cos \phi_2, 0.5 + -0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)\right|}}\right) \]
    7. Add Preprocessing

    Alternative 9: 62.0% accurate, 1.1× speedup?

    \[\begin{array}{l} \\ \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\_1 \cdot \left(t\_0 \cdot t\_0\right)\\ t_3 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\ \mathbf{if}\;\phi_1 \leq -3.1 \cdot 10^{+22} \lor \neg \left(\phi_1 \leq 1.05 \cdot 10^{-5}\right):\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 \cdot \left(t\_1 \cdot t\_0\right) + t\_3}}{\sqrt{1 - \left(\cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3 + t\_2}}{\sqrt{\left(1 + \left(\frac{\cos \left(-\phi_2\right)}{2} - 0.5\right)\right) - t\_2}}\right)\\ \end{array} \end{array} \]
    (FPCore (R lambda1 lambda2 phi1 phi2)
     :precision binary64
     (let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
            (t_1 (* (cos phi1) (cos phi2)))
            (t_2 (* t_1 (* t_0 t_0)))
            (t_3 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
       (if (or (<= phi1 -3.1e+22) (not (<= phi1 1.05e-5)))
         (*
          R
          (*
           2.0
           (atan2
            (sqrt (+ (* t_0 (* t_1 t_0)) t_3))
            (sqrt
             (-
              1.0
              (+
               (* (cos phi1) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
               (pow (sin (* phi1 0.5)) 2.0)))))))
         (*
          R
          (*
           2.0
           (atan2
            (sqrt (+ t_3 t_2))
            (sqrt (- (+ 1.0 (- (/ (cos (- phi2)) 2.0) 0.5)) t_2))))))))
    double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
    	double t_0 = sin(((lambda1 - lambda2) / 2.0));
    	double t_1 = cos(phi1) * cos(phi2);
    	double t_2 = t_1 * (t_0 * t_0);
    	double t_3 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
    	double tmp;
    	if ((phi1 <= -3.1e+22) || !(phi1 <= 1.05e-5)) {
    		tmp = R * (2.0 * atan2(sqrt(((t_0 * (t_1 * t_0)) + t_3)), sqrt((1.0 - ((cos(phi1) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)) + pow(sin((phi1 * 0.5)), 2.0))))));
    	} else {
    		tmp = R * (2.0 * atan2(sqrt((t_3 + t_2)), sqrt(((1.0 + ((cos(-phi2) / 2.0) - 0.5)) - t_2))));
    	}
    	return tmp;
    }
    
    real(8) function code(r, lambda1, lambda2, phi1, phi2)
        real(8), intent (in) :: r
        real(8), intent (in) :: lambda1
        real(8), intent (in) :: lambda2
        real(8), intent (in) :: phi1
        real(8), intent (in) :: phi2
        real(8) :: t_0
        real(8) :: t_1
        real(8) :: t_2
        real(8) :: t_3
        real(8) :: tmp
        t_0 = sin(((lambda1 - lambda2) / 2.0d0))
        t_1 = cos(phi1) * cos(phi2)
        t_2 = t_1 * (t_0 * t_0)
        t_3 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
        if ((phi1 <= (-3.1d+22)) .or. (.not. (phi1 <= 1.05d-5))) then
            tmp = r * (2.0d0 * atan2(sqrt(((t_0 * (t_1 * t_0)) + t_3)), sqrt((1.0d0 - ((cos(phi1) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
        else
            tmp = r * (2.0d0 * atan2(sqrt((t_3 + t_2)), sqrt(((1.0d0 + ((cos(-phi2) / 2.0d0) - 0.5d0)) - t_2))))
        end if
        code = tmp
    end function
    
    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.cos(phi1) * Math.cos(phi2);
    	double t_2 = t_1 * (t_0 * t_0);
    	double t_3 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
    	double tmp;
    	if ((phi1 <= -3.1e+22) || !(phi1 <= 1.05e-5)) {
    		tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_0 * (t_1 * t_0)) + t_3)), Math.sqrt((1.0 - ((Math.cos(phi1) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
    	} else {
    		tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + t_2)), Math.sqrt(((1.0 + ((Math.cos(-phi2) / 2.0) - 0.5)) - t_2))));
    	}
    	return tmp;
    }
    
    def code(R, lambda1, lambda2, phi1, phi2):
    	t_0 = math.sin(((lambda1 - lambda2) / 2.0))
    	t_1 = math.cos(phi1) * math.cos(phi2)
    	t_2 = t_1 * (t_0 * t_0)
    	t_3 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)
    	tmp = 0
    	if (phi1 <= -3.1e+22) or not (phi1 <= 1.05e-5):
    		tmp = R * (2.0 * math.atan2(math.sqrt(((t_0 * (t_1 * t_0)) + t_3)), math.sqrt((1.0 - ((math.cos(phi1) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)) + math.pow(math.sin((phi1 * 0.5)), 2.0))))))
    	else:
    		tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + t_2)), math.sqrt(((1.0 + ((math.cos(-phi2) / 2.0) - 0.5)) - t_2))))
    	return tmp
    
    function code(R, lambda1, lambda2, phi1, phi2)
    	t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0))
    	t_1 = Float64(cos(phi1) * cos(phi2))
    	t_2 = Float64(t_1 * Float64(t_0 * t_0))
    	t_3 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0
    	tmp = 0.0
    	if ((phi1 <= -3.1e+22) || !(phi1 <= 1.05e-5))
    		tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(t_1 * t_0)) + t_3)), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)) + (sin(Float64(phi1 * 0.5)) ^ 2.0)))))));
    	else
    		tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + t_2)), sqrt(Float64(Float64(1.0 + Float64(Float64(cos(Float64(-phi2)) / 2.0) - 0.5)) - t_2)))));
    	end
    	return tmp
    end
    
    function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
    	t_0 = sin(((lambda1 - lambda2) / 2.0));
    	t_1 = cos(phi1) * cos(phi2);
    	t_2 = t_1 * (t_0 * t_0);
    	t_3 = sin(((phi1 - phi2) / 2.0)) ^ 2.0;
    	tmp = 0.0;
    	if ((phi1 <= -3.1e+22) || ~((phi1 <= 1.05e-5)))
    		tmp = R * (2.0 * atan2(sqrt(((t_0 * (t_1 * t_0)) + t_3)), sqrt((1.0 - ((cos(phi1) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0)) + (sin((phi1 * 0.5)) ^ 2.0))))));
    	else
    		tmp = R * (2.0 * atan2(sqrt((t_3 + t_2)), sqrt(((1.0 + ((cos(-phi2) / 2.0) - 0.5)) - t_2))));
    	end
    	tmp_2 = tmp;
    end
    
    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[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[phi1, -3.1e+22], N[Not[LessEqual[phi1, 1.05e-5]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(t$95$1 * t$95$0), $MachinePrecision]), $MachinePrecision] + t$95$3), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + t$95$2), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 + N[(N[(N[Cos[(-phi2)], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
    
    \begin{array}{l}
    
    \\
    \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\_1 \cdot \left(t\_0 \cdot t\_0\right)\\
    t_3 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
    \mathbf{if}\;\phi_1 \leq -3.1 \cdot 10^{+22} \lor \neg \left(\phi_1 \leq 1.05 \cdot 10^{-5}\right):\\
    \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 \cdot \left(t\_1 \cdot t\_0\right) + t\_3}}{\sqrt{1 - \left(\cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3 + t\_2}}{\sqrt{\left(1 + \left(\frac{\cos \left(-\phi_2\right)}{2} - 0.5\right)\right) - t\_2}}\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if phi1 < -3.1000000000000002e22 or 1.04999999999999994e-5 < phi1

      1. Initial program 42.6%

        \[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. Add Preprocessing
      3. Taylor expanded in phi2 around 0 43.7%

        \[\leadsto 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{\color{blue}{1 - \left(\cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} + {\sin \left(0.5 \cdot \phi_1\right)}^{2}\right)}}}\right) \]

      if -3.1000000000000002e22 < phi1 < 1.04999999999999994e-5

      1. Initial program 75.8%

        \[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. Step-by-step derivation
        1. associate-*l*75.8%

          \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \color{blue}{\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\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. Simplified75.8%

        \[\leadsto \color{blue}{R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}{\sqrt{\left(1 - {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right) - \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right)} \]
      4. Add Preprocessing
      5. Step-by-step derivation
        1. expm1-log1p-u75.8%

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

          \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}{\sqrt{\left(1 - \color{blue}{\left(e^{\mathsf{log1p}\left({\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)} - 1\right)}\right) - \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right) \]
        3. log1p-undefine75.8%

          \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}{\sqrt{\left(1 - \left(e^{\color{blue}{\log \left(1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}} - 1\right)\right) - \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right) \]
        4. add-exp-log75.8%

          \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}{\sqrt{\left(1 - \left(\color{blue}{\left(1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)} - 1\right)\right) - \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right) \]
        5. div-inv75.8%

          \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}{\sqrt{\left(1 - \left(\left(1 + {\sin \color{blue}{\left(\left(\phi_1 - \phi_2\right) \cdot \frac{1}{2}\right)}}^{2}\right) - 1\right)\right) - \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right) \]
        6. metadata-eval75.8%

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

        \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}{\sqrt{\left(1 - \color{blue}{\left(\left(1 + {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}\right) - 1\right)}\right) - \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right) \]
      7. Taylor expanded in phi1 around 0 75.8%

        \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}{\sqrt{\left(1 - \left(\left(1 + {\sin \left(\color{blue}{\left(-1 \cdot \phi_2\right)} \cdot 0.5\right)}^{2}\right) - 1\right)\right) - \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right) \]
      8. Step-by-step derivation
        1. neg-mul-175.8%

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

        \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}{\sqrt{\left(1 - \left(\left(1 + {\sin \left(\color{blue}{\left(-\phi_2\right)} \cdot 0.5\right)}^{2}\right) - 1\right)\right) - \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right) \]
      10. Step-by-step derivation
        1. add-exp-log75.8%

          \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}{\sqrt{\left(1 - \left(\color{blue}{e^{\log \left(1 + {\sin \left(\left(-\phi_2\right) \cdot 0.5\right)}^{2}\right)}} - 1\right)\right) - \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right) \]
        2. expm1-define75.8%

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

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

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

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

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

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

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

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

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

        \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}{\sqrt{\left(1 - \color{blue}{\frac{\cos \left(0.5 \cdot \left(-\phi_2\right) - 0.5 \cdot \left(-\phi_2\right)\right) - \cos \left(0.5 \cdot \left(-\phi_2\right) + 0.5 \cdot \left(-\phi_2\right)\right)}{2}}\right) - \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right) \]
      12. Step-by-step derivation
        1. div-sub75.9%

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

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

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

          \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}{\sqrt{\left(1 - \left(\color{blue}{0.5} - \frac{\cos \left(0.5 \cdot \left(-\phi_2\right) + 0.5 \cdot \left(-\phi_2\right)\right)}{2}\right)\right) - \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right) \]
        5. distribute-rgt-out75.9%

          \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}{\sqrt{\left(1 - \left(0.5 - \frac{\cos \color{blue}{\left(\left(-\phi_2\right) \cdot \left(0.5 + 0.5\right)\right)}}{2}\right)\right) - \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right) \]
        6. metadata-eval75.9%

          \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}{\sqrt{\left(1 - \left(0.5 - \frac{\cos \left(\left(-\phi_2\right) \cdot \color{blue}{1}\right)}{2}\right)\right) - \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right) \]
        7. *-rgt-identity75.9%

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

        \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}{\sqrt{\left(1 - \color{blue}{\left(0.5 - \frac{\cos \left(-\phi_2\right)}{2}\right)}\right) - \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right) \]
    3. Recombined 2 regimes into one program.
    4. Final simplification58.9%

      \[\leadsto \begin{array}{l} \mathbf{if}\;\phi_1 \leq -3.1 \cdot 10^{+22} \lor \neg \left(\phi_1 \leq 1.05 \cdot 10^{-5}\right):\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\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) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}{\sqrt{\left(1 + \left(\frac{\cos \left(-\phi_2\right)}{2} - 0.5\right)\right) - \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right)\\ \end{array} \]
    5. Add Preprocessing

    Alternative 10: 62.7% accurate, 1.1× speedup?

    \[\begin{array}{l} \\ \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)}^{2}\\ \mathbf{if}\;\phi_1 \leq -9.5 \cdot 10^{-6} \lor \neg \left(\phi_1 \leq 6.5 \cdot 10^{-6}\right):\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_1}{\sqrt{1 - \left(\cos \phi_1 \cdot t\_2 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_1}{\sqrt{1 - \left(\cos \phi_2 \cdot t\_2 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}\right)\\ \end{array} \end{array} \]
    (FPCore (R lambda1 lambda2 phi1 phi2)
     :precision binary64
     (let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
            (t_1
             (sqrt
              (+
               (* t_0 (* (* (cos phi1) (cos phi2)) t_0))
               (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))))
            (t_2 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0)))
       (if (or (<= phi1 -9.5e-6) (not (<= phi1 6.5e-6)))
         (*
          R
          (*
           2.0
           (atan2
            t_1
            (sqrt (- 1.0 (+ (* (cos phi1) t_2) (pow (sin (* phi1 0.5)) 2.0)))))))
         (*
          R
          (*
           2.0
           (atan2
            t_1
            (sqrt
             (- 1.0 (+ (* (cos phi2) t_2) (pow (sin (* phi2 -0.5)) 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 = sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0)));
    	double t_2 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
    	double tmp;
    	if ((phi1 <= -9.5e-6) || !(phi1 <= 6.5e-6)) {
    		tmp = R * (2.0 * atan2(t_1, sqrt((1.0 - ((cos(phi1) * t_2) + pow(sin((phi1 * 0.5)), 2.0))))));
    	} else {
    		tmp = R * (2.0 * atan2(t_1, sqrt((1.0 - ((cos(phi2) * t_2) + pow(sin((phi2 * -0.5)), 2.0))))));
    	}
    	return tmp;
    }
    
    real(8) function code(r, lambda1, lambda2, phi1, phi2)
        real(8), intent (in) :: r
        real(8), intent (in) :: lambda1
        real(8), intent (in) :: lambda2
        real(8), intent (in) :: phi1
        real(8), intent (in) :: phi2
        real(8) :: t_0
        real(8) :: t_1
        real(8) :: t_2
        real(8) :: tmp
        t_0 = sin(((lambda1 - lambda2) / 2.0d0))
        t_1 = sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)))
        t_2 = sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
        if ((phi1 <= (-9.5d-6)) .or. (.not. (phi1 <= 6.5d-6))) then
            tmp = r * (2.0d0 * atan2(t_1, sqrt((1.0d0 - ((cos(phi1) * t_2) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
        else
            tmp = r * (2.0d0 * atan2(t_1, sqrt((1.0d0 - ((cos(phi2) * t_2) + (sin((phi2 * (-0.5d0))) ** 2.0d0))))))
        end if
        code = tmp
    end function
    
    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.sqrt(((t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)));
    	double t_2 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
    	double tmp;
    	if ((phi1 <= -9.5e-6) || !(phi1 <= 6.5e-6)) {
    		tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt((1.0 - ((Math.cos(phi1) * t_2) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
    	} else {
    		tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt((1.0 - ((Math.cos(phi2) * t_2) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))))));
    	}
    	return tmp;
    }
    
    def code(R, lambda1, lambda2, phi1, phi2):
    	t_0 = math.sin(((lambda1 - lambda2) / 2.0))
    	t_1 = math.sqrt(((t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)))
    	t_2 = math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)
    	tmp = 0
    	if (phi1 <= -9.5e-6) or not (phi1 <= 6.5e-6):
    		tmp = R * (2.0 * math.atan2(t_1, math.sqrt((1.0 - ((math.cos(phi1) * t_2) + math.pow(math.sin((phi1 * 0.5)), 2.0))))))
    	else:
    		tmp = R * (2.0 * math.atan2(t_1, math.sqrt((1.0 - ((math.cos(phi2) * t_2) + math.pow(math.sin((phi2 * -0.5)), 2.0))))))
    	return tmp
    
    function code(R, lambda1, lambda2, phi1, phi2)
    	t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0))
    	t_1 = sqrt(Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)))
    	t_2 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0
    	tmp = 0.0
    	if ((phi1 <= -9.5e-6) || !(phi1 <= 6.5e-6))
    		tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_2) + (sin(Float64(phi1 * 0.5)) ^ 2.0)))))));
    	else
    		tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64(1.0 - Float64(Float64(cos(phi2) * t_2) + (sin(Float64(phi2 * -0.5)) ^ 2.0)))))));
    	end
    	return tmp
    end
    
    function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
    	t_0 = sin(((lambda1 - lambda2) / 2.0));
    	t_1 = sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0)));
    	t_2 = sin((0.5 * (lambda1 - lambda2))) ^ 2.0;
    	tmp = 0.0;
    	if ((phi1 <= -9.5e-6) || ~((phi1 <= 6.5e-6)))
    		tmp = R * (2.0 * atan2(t_1, sqrt((1.0 - ((cos(phi1) * t_2) + (sin((phi1 * 0.5)) ^ 2.0))))));
    	else
    		tmp = R * (2.0 * atan2(t_1, sqrt((1.0 - ((cos(phi2) * t_2) + (sin((phi2 * -0.5)) ^ 2.0))))));
    	end
    	tmp_2 = tmp;
    end
    
    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[Sqrt[N[(N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[phi1, -9.5e-6], N[Not[LessEqual[phi1, 6.5e-6]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$2), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
    
    \begin{array}{l}
    
    \\
    \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)}^{2}\\
    \mathbf{if}\;\phi_1 \leq -9.5 \cdot 10^{-6} \lor \neg \left(\phi_1 \leq 6.5 \cdot 10^{-6}\right):\\
    \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_1}{\sqrt{1 - \left(\cos \phi_1 \cdot t\_2 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_1}{\sqrt{1 - \left(\cos \phi_2 \cdot t\_2 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if phi1 < -9.5000000000000005e-6 or 6.4999999999999996e-6 < phi1

      1. Initial program 41.3%

        \[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. Add Preprocessing
      3. Taylor expanded in phi2 around 0 42.3%

        \[\leadsto 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{\color{blue}{1 - \left(\cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} + {\sin \left(0.5 \cdot \phi_1\right)}^{2}\right)}}}\right) \]

      if -9.5000000000000005e-6 < phi1 < 6.4999999999999996e-6

      1. Initial program 79.5%

        \[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. Add Preprocessing
      3. Taylor expanded in phi1 around 0 79.5%

        \[\leadsto 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{\color{blue}{1 - \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} + {\sin \left(-0.5 \cdot \phi_2\right)}^{2}\right)}}}\right) \]
    3. Recombined 2 regimes into one program.
    4. Final simplification58.9%

      \[\leadsto \begin{array}{l} \mathbf{if}\;\phi_1 \leq -9.5 \cdot 10^{-6} \lor \neg \left(\phi_1 \leq 6.5 \cdot 10^{-6}\right):\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\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) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\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) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}\right)\\ \end{array} \]
    5. Add Preprocessing

    Alternative 11: 62.7% accurate, 1.1× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\ t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_2 := 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}\\ \mathbf{if}\;\phi_2 \leq -2 \cdot 10^{-5} \lor \neg \left(\phi_2 \leq 8.5 \cdot 10^{-6}\right):\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot t\_0 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{1 - t\_2}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2}}{\sqrt{1 - \left(\cos \phi_1 \cdot t\_0 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\ \end{array} \end{array} \]
    (FPCore (R lambda1 lambda2 phi1 phi2)
     :precision binary64
     (let* ((t_0 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
            (t_1 (sin (/ (- lambda1 lambda2) 2.0)))
            (t_2
             (+
              (* t_1 (* (* (cos phi1) (cos phi2)) t_1))
              (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))))
       (if (or (<= phi2 -2e-5) (not (<= phi2 8.5e-6)))
         (*
          R
          (*
           2.0
           (atan2
            (sqrt (+ (* (cos phi2) t_0) (pow (sin (* phi2 -0.5)) 2.0)))
            (sqrt (- 1.0 t_2)))))
         (*
          R
          (*
           2.0
           (atan2
            (sqrt t_2)
            (sqrt
             (- 1.0 (+ (* (cos phi1) t_0) (pow (sin (* phi1 0.5)) 2.0))))))))))
    double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
    	double t_0 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
    	double t_1 = sin(((lambda1 - lambda2) / 2.0));
    	double t_2 = (t_1 * ((cos(phi1) * cos(phi2)) * t_1)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0);
    	double tmp;
    	if ((phi2 <= -2e-5) || !(phi2 <= 8.5e-6)) {
    		tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * t_0) + pow(sin((phi2 * -0.5)), 2.0))), sqrt((1.0 - t_2))));
    	} else {
    		tmp = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 - ((cos(phi1) * t_0) + pow(sin((phi1 * 0.5)), 2.0))))));
    	}
    	return tmp;
    }
    
    real(8) function code(r, lambda1, lambda2, phi1, phi2)
        real(8), intent (in) :: r
        real(8), intent (in) :: lambda1
        real(8), intent (in) :: lambda2
        real(8), intent (in) :: phi1
        real(8), intent (in) :: phi2
        real(8) :: t_0
        real(8) :: t_1
        real(8) :: t_2
        real(8) :: tmp
        t_0 = sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
        t_1 = sin(((lambda1 - lambda2) / 2.0d0))
        t_2 = (t_1 * ((cos(phi1) * cos(phi2)) * t_1)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)
        if ((phi2 <= (-2d-5)) .or. (.not. (phi2 <= 8.5d-6))) then
            tmp = r * (2.0d0 * atan2(sqrt(((cos(phi2) * t_0) + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt((1.0d0 - t_2))))
        else
            tmp = r * (2.0d0 * atan2(sqrt(t_2), sqrt((1.0d0 - ((cos(phi1) * t_0) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
        end if
        code = tmp
    end function
    
    public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
    	double t_0 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
    	double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
    	double t_2 = (t_1 * ((Math.cos(phi1) * Math.cos(phi2)) * t_1)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
    	double tmp;
    	if ((phi2 <= -2e-5) || !(phi2 <= 8.5e-6)) {
    		tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi2) * t_0) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt((1.0 - t_2))));
    	} else {
    		tmp = R * (2.0 * Math.atan2(Math.sqrt(t_2), Math.sqrt((1.0 - ((Math.cos(phi1) * t_0) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
    	}
    	return tmp;
    }
    
    def code(R, lambda1, lambda2, phi1, phi2):
    	t_0 = math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)
    	t_1 = math.sin(((lambda1 - lambda2) / 2.0))
    	t_2 = (t_1 * ((math.cos(phi1) * math.cos(phi2)) * t_1)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)
    	tmp = 0
    	if (phi2 <= -2e-5) or not (phi2 <= 8.5e-6):
    		tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi2) * t_0) + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt((1.0 - t_2))))
    	else:
    		tmp = R * (2.0 * math.atan2(math.sqrt(t_2), math.sqrt((1.0 - ((math.cos(phi1) * t_0) + math.pow(math.sin((phi1 * 0.5)), 2.0))))))
    	return tmp
    
    function code(R, lambda1, lambda2, phi1, phi2)
    	t_0 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0
    	t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0))
    	t_2 = Float64(Float64(t_1 * Float64(Float64(cos(phi1) * cos(phi2)) * t_1)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))
    	tmp = 0.0
    	if ((phi2 <= -2e-5) || !(phi2 <= 8.5e-6))
    		tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi2) * t_0) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64(1.0 - t_2)))));
    	else
    		tmp = Float64(R * Float64(2.0 * atan(sqrt(t_2), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_0) + (sin(Float64(phi1 * 0.5)) ^ 2.0)))))));
    	end
    	return tmp
    end
    
    function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
    	t_0 = sin((0.5 * (lambda1 - lambda2))) ^ 2.0;
    	t_1 = sin(((lambda1 - lambda2) / 2.0));
    	t_2 = (t_1 * ((cos(phi1) * cos(phi2)) * t_1)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0);
    	tmp = 0.0;
    	if ((phi2 <= -2e-5) || ~((phi2 <= 8.5e-6)))
    		tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * t_0) + (sin((phi2 * -0.5)) ^ 2.0))), sqrt((1.0 - t_2))));
    	else
    		tmp = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 - ((cos(phi1) * t_0) + (sin((phi1 * 0.5)) ^ 2.0))))));
    	end
    	tmp_2 = tmp;
    end
    
    code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$1 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -2e-5], N[Not[LessEqual[phi2, 8.5e-6]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$2], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
    t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
    t_2 := 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}\\
    \mathbf{if}\;\phi_2 \leq -2 \cdot 10^{-5} \lor \neg \left(\phi_2 \leq 8.5 \cdot 10^{-6}\right):\\
    \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot t\_0 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{1 - t\_2}}\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2}}{\sqrt{1 - \left(\cos \phi_1 \cdot t\_0 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if phi2 < -2.00000000000000016e-5 or 8.4999999999999999e-6 < phi2

      1. Initial program 45.1%

        \[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. Add Preprocessing
      3. Step-by-step derivation
        1. expm1-log1p-u45.1%

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

          \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}{\sqrt{\left(1 - \color{blue}{\left(e^{\mathsf{log1p}\left({\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)} - 1\right)}\right) - \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right) \]
        3. log1p-undefine45.1%

          \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}{\sqrt{\left(1 - \left(e^{\color{blue}{\log \left(1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}} - 1\right)\right) - \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right) \]
        4. add-exp-log45.1%

          \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}{\sqrt{\left(1 - \left(\color{blue}{\left(1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)} - 1\right)\right) - \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right) \]
        5. div-inv45.1%

          \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}{\sqrt{\left(1 - \left(\left(1 + {\sin \color{blue}{\left(\left(\phi_1 - \phi_2\right) \cdot \frac{1}{2}\right)}}^{2}\right) - 1\right)\right) - \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right) \]
        6. metadata-eval45.1%

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

        \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\color{blue}{\left(\left(1 + {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}\right) - 1\right)} + \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) \]
      5. Taylor expanded in phi1 around 0 45.7%

        \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\color{blue}{\sqrt{\cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} + {\sin \left(-0.5 \cdot \phi_2\right)}^{2}}}}{\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) \]

      if -2.00000000000000016e-5 < phi2 < 8.4999999999999999e-6

      1. Initial program 76.4%

        \[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. Add Preprocessing
      3. Taylor expanded in phi2 around 0 76.4%

        \[\leadsto 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{\color{blue}{1 - \left(\cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} + {\sin \left(0.5 \cdot \phi_1\right)}^{2}\right)}}}\right) \]
    3. Recombined 2 regimes into one program.
    4. Final simplification58.6%

      \[\leadsto \begin{array}{l} \mathbf{if}\;\phi_2 \leq -2 \cdot 10^{-5} \lor \neg \left(\phi_2 \leq 8.5 \cdot 10^{-6}\right):\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\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) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\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) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\ \end{array} \]
    5. Add Preprocessing

    Alternative 12: 53.4% accurate, 1.1× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\\ 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)\\ t_3 := \cos \phi_1 \cdot \cos \phi_2\\ \mathbf{if}\;\phi_2 \leq -2.9 \cdot 10^{-15} \lor \neg \left(\phi_2 \leq 1.36\right):\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot {t\_2}^{2} + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{1 - \left(t\_1 \cdot \left(t\_3 \cdot t\_1\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(t\_0, t\_2 \cdot \sqrt{t\_3}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), t\_3, {t\_0}^{2}\right)}}\\ \end{array} \end{array} \]
    (FPCore (R lambda1 lambda2 phi1 phi2)
     :precision binary64
     (let* ((t_0 (sin (* 0.5 (- phi1 phi2))))
            (t_1 (sin (/ (- lambda1 lambda2) 2.0)))
            (t_2 (sin (* 0.5 (- lambda1 lambda2))))
            (t_3 (* (cos phi1) (cos phi2))))
       (if (or (<= phi2 -2.9e-15) (not (<= phi2 1.36)))
         (*
          R
          (*
           2.0
           (atan2
            (sqrt (+ (* (cos phi2) (pow t_2 2.0)) (pow (sin (* phi2 -0.5)) 2.0)))
            (sqrt
             (-
              1.0
              (+ (* t_1 (* t_3 t_1)) (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))))))
         (*
          (* R 2.0)
          (atan2
           (hypot t_0 (* t_2 (sqrt t_3)))
           (sqrt
            (-
             1.0
             (fma
              (- 0.5 (* 0.5 (cos (- lambda1 lambda2))))
              t_3
              (pow t_0 2.0)))))))))
    double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
    	double t_0 = sin((0.5 * (phi1 - phi2)));
    	double t_1 = sin(((lambda1 - lambda2) / 2.0));
    	double t_2 = sin((0.5 * (lambda1 - lambda2)));
    	double t_3 = cos(phi1) * cos(phi2);
    	double tmp;
    	if ((phi2 <= -2.9e-15) || !(phi2 <= 1.36)) {
    		tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * pow(t_2, 2.0)) + pow(sin((phi2 * -0.5)), 2.0))), sqrt((1.0 - ((t_1 * (t_3 * t_1)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))))));
    	} else {
    		tmp = (R * 2.0) * atan2(hypot(t_0, (t_2 * sqrt(t_3))), sqrt((1.0 - fma((0.5 - (0.5 * cos((lambda1 - lambda2)))), t_3, pow(t_0, 2.0)))));
    	}
    	return tmp;
    }
    
    function code(R, lambda1, lambda2, phi1, phi2)
    	t_0 = sin(Float64(0.5 * Float64(phi1 - phi2)))
    	t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0))
    	t_2 = sin(Float64(0.5 * Float64(lambda1 - lambda2)))
    	t_3 = Float64(cos(phi1) * cos(phi2))
    	tmp = 0.0
    	if ((phi2 <= -2.9e-15) || !(phi2 <= 1.36))
    		tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi2) * (t_2 ^ 2.0)) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64(1.0 - Float64(Float64(t_1 * Float64(t_3 * t_1)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)))))));
    	else
    		tmp = Float64(Float64(R * 2.0) * atan(hypot(t_0, Float64(t_2 * sqrt(t_3))), sqrt(Float64(1.0 - fma(Float64(0.5 - Float64(0.5 * cos(Float64(lambda1 - lambda2)))), t_3, (t_0 ^ 2.0))))));
    	end
    	return tmp
    end
    
    code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -2.9e-15], N[Not[LessEqual[phi2, 1.36]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi2], $MachinePrecision] * N[Power[t$95$2, 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(t$95$1 * N[(t$95$3 * t$95$1), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[t$95$0 ^ 2 + N[(t$95$2 * N[Sqrt[t$95$3], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(0.5 - N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$3 + N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\\
    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)\\
    t_3 := \cos \phi_1 \cdot \cos \phi_2\\
    \mathbf{if}\;\phi_2 \leq -2.9 \cdot 10^{-15} \lor \neg \left(\phi_2 \leq 1.36\right):\\
    \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot {t\_2}^{2} + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{1 - \left(t\_1 \cdot \left(t\_3 \cdot t\_1\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(t\_0, t\_2 \cdot \sqrt{t\_3}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), t\_3, {t\_0}^{2}\right)}}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if phi2 < -2.90000000000000019e-15 or 1.3600000000000001 < phi2

      1. Initial program 46.1%

        \[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. Add Preprocessing
      3. Step-by-step derivation
        1. expm1-log1p-u46.1%

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

          \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}{\sqrt{\left(1 - \color{blue}{\left(e^{\mathsf{log1p}\left({\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)} - 1\right)}\right) - \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right) \]
        3. log1p-undefine46.1%

          \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}{\sqrt{\left(1 - \left(e^{\color{blue}{\log \left(1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}} - 1\right)\right) - \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right) \]
        4. add-exp-log46.1%

          \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}{\sqrt{\left(1 - \left(\color{blue}{\left(1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)} - 1\right)\right) - \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right) \]
        5. div-inv46.1%

          \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}{\sqrt{\left(1 - \left(\left(1 + {\sin \color{blue}{\left(\left(\phi_1 - \phi_2\right) \cdot \frac{1}{2}\right)}}^{2}\right) - 1\right)\right) - \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right) \]
        6. metadata-eval46.1%

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

        \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\color{blue}{\left(\left(1 + {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}\right) - 1\right)} + \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) \]
      5. Taylor expanded in phi1 around 0 46.4%

        \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\color{blue}{\sqrt{\cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} + {\sin \left(-0.5 \cdot \phi_2\right)}^{2}}}}{\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) \]

      if -2.90000000000000019e-15 < phi2 < 1.3600000000000001

      1. Initial program 75.5%

        \[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. Step-by-step derivation
        1. Simplified75.5%

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

          \[\leadsto \color{blue}{{\left(\tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right), \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}\right)}} \cdot \left(2 \cdot R\right)\right)}^{1}} \]
        4. Step-by-step derivation
          1. unpow162.3%

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

          \[\leadsto \color{blue}{\tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right), \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}} \cdot \left(2 \cdot R\right)} \]
      3. Recombined 2 regimes into one program.
      4. Final simplification53.0%

        \[\leadsto \begin{array}{l} \mathbf{if}\;\phi_2 \leq -2.9 \cdot 10^{-15} \lor \neg \left(\phi_2 \leq 1.36\right):\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\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) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right), \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}}\\ \end{array} \]
      5. Add Preprocessing

      Alternative 13: 62.4% accurate, 1.1× speedup?

      \[\begin{array}{l} \\ \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(\left(\frac{\cos \left(\phi_1 - \phi_2\right)}{2} - 0.5\right) - t\_1\right)}}\right) \end{array} \end{array} \]
      (FPCore (R lambda1 lambda2 phi1 phi2)
       :precision binary64
       (let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
              (t_1 (* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
         (*
          R
          (*
           2.0
           (atan2
            (sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
            (sqrt (+ 1.0 (- (- (/ (cos (- phi1 phi2)) 2.0) 0.5) t_1))))))))
      double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
      	double t_0 = sin(((lambda1 - lambda2) / 2.0));
      	double t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
      	return R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 + (((cos((phi1 - phi2)) / 2.0) - 0.5) - t_1)))));
      }
      
      real(8) function code(r, lambda1, lambda2, phi1, phi2)
          real(8), intent (in) :: r
          real(8), intent (in) :: lambda1
          real(8), intent (in) :: lambda2
          real(8), intent (in) :: phi1
          real(8), intent (in) :: phi2
          real(8) :: t_0
          real(8) :: t_1
          t_0 = sin(((lambda1 - lambda2) / 2.0d0))
          t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0)
          code = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 + (((cos((phi1 - phi2)) / 2.0d0) - 0.5d0) - t_1)))))
      end function
      
      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 = t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0);
      	return R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 + (((Math.cos((phi1 - phi2)) / 2.0) - 0.5) - t_1)))));
      }
      
      def code(R, lambda1, lambda2, phi1, phi2):
      	t_0 = math.sin(((lambda1 - lambda2) / 2.0))
      	t_1 = t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)
      	return R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 + (((math.cos((phi1 - phi2)) / 2.0) - 0.5) - t_1)))))
      
      function code(R, lambda1, lambda2, phi1, phi2)
      	t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0))
      	t_1 = Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0))
      	return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 + Float64(Float64(Float64(cos(Float64(phi1 - phi2)) / 2.0) - 0.5) - t_1))))))
      end
      
      function tmp = code(R, lambda1, lambda2, phi1, phi2)
      	t_0 = sin(((lambda1 - lambda2) / 2.0));
      	t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
      	tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 + (((cos((phi1 - phi2)) / 2.0) - 0.5) - t_1)))));
      end
      
      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[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 + N[(N[(N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision] - t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
      
      \begin{array}{l}
      
      \\
      \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(\left(\frac{\cos \left(\phi_1 - \phi_2\right)}{2} - 0.5\right) - t\_1\right)}}\right)
      \end{array}
      \end{array}
      
      Derivation
      1. Initial program 58.3%

        \[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. Add Preprocessing
      3. Step-by-step derivation
        1. unpow258.3%

          \[\leadsto 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(\color{blue}{\sin \left(\frac{\phi_1 - \phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1 - \phi_2}{2}\right)} + \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. sin-mult58.4%

          \[\leadsto 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(\color{blue}{\frac{\cos \left(\frac{\phi_1 - \phi_2}{2} - \frac{\phi_1 - \phi_2}{2}\right) - \cos \left(\frac{\phi_1 - \phi_2}{2} + \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. div-inv58.4%

          \[\leadsto 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(\frac{\cos \left(\color{blue}{\left(\phi_1 - \phi_2\right) \cdot \frac{1}{2}} - \frac{\phi_1 - \phi_2}{2}\right) - \cos \left(\frac{\phi_1 - \phi_2}{2} + \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) \]
        4. metadata-eval58.4%

          \[\leadsto 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(\frac{\cos \left(\left(\phi_1 - \phi_2\right) \cdot \color{blue}{0.5} - \frac{\phi_1 - \phi_2}{2}\right) - \cos \left(\frac{\phi_1 - \phi_2}{2} + \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) \]
        5. div-inv58.4%

          \[\leadsto 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(\frac{\cos \left(\left(\phi_1 - \phi_2\right) \cdot 0.5 - \color{blue}{\left(\phi_1 - \phi_2\right) \cdot \frac{1}{2}}\right) - \cos \left(\frac{\phi_1 - \phi_2}{2} + \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) \]
        6. metadata-eval58.4%

          \[\leadsto 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(\frac{\cos \left(\left(\phi_1 - \phi_2\right) \cdot 0.5 - \left(\phi_1 - \phi_2\right) \cdot \color{blue}{0.5}\right) - \cos \left(\frac{\phi_1 - \phi_2}{2} + \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) \]
        7. div-inv58.4%

          \[\leadsto 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(\frac{\cos \left(\left(\phi_1 - \phi_2\right) \cdot 0.5 - \left(\phi_1 - \phi_2\right) \cdot 0.5\right) - \cos \left(\color{blue}{\left(\phi_1 - \phi_2\right) \cdot \frac{1}{2}} + \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) \]
        8. metadata-eval58.4%

          \[\leadsto 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(\frac{\cos \left(\left(\phi_1 - \phi_2\right) \cdot 0.5 - \left(\phi_1 - \phi_2\right) \cdot 0.5\right) - \cos \left(\left(\phi_1 - \phi_2\right) \cdot \color{blue}{0.5} + \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) \]
        9. div-inv58.4%

          \[\leadsto 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(\frac{\cos \left(\left(\phi_1 - \phi_2\right) \cdot 0.5 - \left(\phi_1 - \phi_2\right) \cdot 0.5\right) - \cos \left(\left(\phi_1 - \phi_2\right) \cdot 0.5 + \color{blue}{\left(\phi_1 - \phi_2\right) \cdot \frac{1}{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) \]
        10. metadata-eval58.4%

          \[\leadsto 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(\frac{\cos \left(\left(\phi_1 - \phi_2\right) \cdot 0.5 - \left(\phi_1 - \phi_2\right) \cdot 0.5\right) - \cos \left(\left(\phi_1 - \phi_2\right) \cdot 0.5 + \left(\phi_1 - \phi_2\right) \cdot \color{blue}{0.5}\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-rr58.4%

        \[\leadsto 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(\color{blue}{\frac{\cos \left(\left(\phi_1 - \phi_2\right) \cdot 0.5 - \left(\phi_1 - \phi_2\right) \cdot 0.5\right) - \cos \left(\left(\phi_1 - \phi_2\right) \cdot 0.5 + \left(\phi_1 - \phi_2\right) \cdot 0.5\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. Step-by-step derivation
        1. div-sub58.4%

          \[\leadsto 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(\color{blue}{\left(\frac{\cos \left(\left(\phi_1 - \phi_2\right) \cdot 0.5 - \left(\phi_1 - \phi_2\right) \cdot 0.5\right)}{2} - \frac{\cos \left(\left(\phi_1 - \phi_2\right) \cdot 0.5 + \left(\phi_1 - \phi_2\right) \cdot 0.5\right)}{2}\right)} + \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. +-inverses58.4%

          \[\leadsto 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(\left(\frac{\cos \color{blue}{0}}{2} - \frac{\cos \left(\left(\phi_1 - \phi_2\right) \cdot 0.5 + \left(\phi_1 - \phi_2\right) \cdot 0.5\right)}{2}\right) + \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. cos-058.4%

          \[\leadsto 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(\left(\frac{\color{blue}{1}}{2} - \frac{\cos \left(\left(\phi_1 - \phi_2\right) \cdot 0.5 + \left(\phi_1 - \phi_2\right) \cdot 0.5\right)}{2}\right) + \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. metadata-eval58.4%

          \[\leadsto 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(\left(\color{blue}{0.5} - \frac{\cos \left(\left(\phi_1 - \phi_2\right) \cdot 0.5 + \left(\phi_1 - \phi_2\right) \cdot 0.5\right)}{2}\right) + \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. distribute-lft-out58.4%

          \[\leadsto 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(\left(0.5 - \frac{\cos \color{blue}{\left(\left(\phi_1 - \phi_2\right) \cdot \left(0.5 + 0.5\right)\right)}}{2}\right) + \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) \]
        6. metadata-eval58.4%

          \[\leadsto 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(\left(0.5 - \frac{\cos \left(\left(\phi_1 - \phi_2\right) \cdot \color{blue}{1}\right)}{2}\right) + \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) \]
        7. *-rgt-identity58.4%

          \[\leadsto 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(\left(0.5 - \frac{\cos \color{blue}{\left(\phi_1 - \phi_2\right)}}{2}\right) + \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) \]
      6. Simplified58.4%

        \[\leadsto 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(\color{blue}{\left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)} + \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) \]
      7. Final simplification58.4%

        \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\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) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 + \left(\left(\frac{\cos \left(\phi_1 - \phi_2\right)}{2} - 0.5\right) - \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)\right)}}\right) \]
      8. Add Preprocessing

      Alternative 14: 41.5% accurate, 1.1× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\\ t_1 := \cos \phi_1 \cdot \cos \phi_2\\ t_2 := \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\\ t_3 := \sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\\ \mathbf{if}\;\phi_1 \leq -3.1 \cdot 10^{-7} \lor \neg \left(\phi_1 \leq 3.1 \cdot 10^{-12}\right):\\ \;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(\phi_1 \cdot 0.5\right), t\_2 \cdot \sqrt{\cos \phi_1}\right)}{\sqrt{1 - \mathsf{fma}\left(t\_0, t\_1, {t\_3}^{2}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(t\_3, t\_2 \cdot \sqrt{t\_1}\right)}{\sqrt{1 - \mathsf{fma}\left(t\_0, t\_1, {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}\\ \end{array} \end{array} \]
      (FPCore (R lambda1 lambda2 phi1 phi2)
       :precision binary64
       (let* ((t_0 (- 0.5 (* 0.5 (cos (- lambda1 lambda2)))))
              (t_1 (* (cos phi1) (cos phi2)))
              (t_2 (sin (* 0.5 (- lambda1 lambda2))))
              (t_3 (sin (* 0.5 (- phi1 phi2)))))
         (if (or (<= phi1 -3.1e-7) (not (<= phi1 3.1e-12)))
           (*
            (* R 2.0)
            (atan2
             (hypot (sin (* phi1 0.5)) (* t_2 (sqrt (cos phi1))))
             (sqrt (- 1.0 (fma t_0 t_1 (pow t_3 2.0))))))
           (*
            (* R 2.0)
            (atan2
             (hypot t_3 (* t_2 (sqrt t_1)))
             (sqrt (- 1.0 (fma t_0 t_1 (pow (sin (* phi2 -0.5)) 2.0)))))))))
      double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
      	double t_0 = 0.5 - (0.5 * cos((lambda1 - lambda2)));
      	double t_1 = cos(phi1) * cos(phi2);
      	double t_2 = sin((0.5 * (lambda1 - lambda2)));
      	double t_3 = sin((0.5 * (phi1 - phi2)));
      	double tmp;
      	if ((phi1 <= -3.1e-7) || !(phi1 <= 3.1e-12)) {
      		tmp = (R * 2.0) * atan2(hypot(sin((phi1 * 0.5)), (t_2 * sqrt(cos(phi1)))), sqrt((1.0 - fma(t_0, t_1, pow(t_3, 2.0)))));
      	} else {
      		tmp = (R * 2.0) * atan2(hypot(t_3, (t_2 * sqrt(t_1))), sqrt((1.0 - fma(t_0, t_1, pow(sin((phi2 * -0.5)), 2.0)))));
      	}
      	return tmp;
      }
      
      function code(R, lambda1, lambda2, phi1, phi2)
      	t_0 = Float64(0.5 - Float64(0.5 * cos(Float64(lambda1 - lambda2))))
      	t_1 = Float64(cos(phi1) * cos(phi2))
      	t_2 = sin(Float64(0.5 * Float64(lambda1 - lambda2)))
      	t_3 = sin(Float64(0.5 * Float64(phi1 - phi2)))
      	tmp = 0.0
      	if ((phi1 <= -3.1e-7) || !(phi1 <= 3.1e-12))
      		tmp = Float64(Float64(R * 2.0) * atan(hypot(sin(Float64(phi1 * 0.5)), Float64(t_2 * sqrt(cos(phi1)))), sqrt(Float64(1.0 - fma(t_0, t_1, (t_3 ^ 2.0))))));
      	else
      		tmp = Float64(Float64(R * 2.0) * atan(hypot(t_3, Float64(t_2 * sqrt(t_1))), sqrt(Float64(1.0 - fma(t_0, t_1, (sin(Float64(phi2 * -0.5)) ^ 2.0))))));
      	end
      	return tmp
      end
      
      code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(0.5 - N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -3.1e-7], N[Not[LessEqual[phi1, 3.1e-12]], $MachinePrecision]], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] ^ 2 + N[(t$95$2 * N[Sqrt[N[Cos[phi1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$0 * t$95$1 + N[Power[t$95$3, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[t$95$3 ^ 2 + N[(t$95$2 * N[Sqrt[t$95$1], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$0 * t$95$1 + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := 0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
      t_1 := \cos \phi_1 \cdot \cos \phi_2\\
      t_2 := \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\\
      t_3 := \sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\\
      \mathbf{if}\;\phi_1 \leq -3.1 \cdot 10^{-7} \lor \neg \left(\phi_1 \leq 3.1 \cdot 10^{-12}\right):\\
      \;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(\phi_1 \cdot 0.5\right), t\_2 \cdot \sqrt{\cos \phi_1}\right)}{\sqrt{1 - \mathsf{fma}\left(t\_0, t\_1, {t\_3}^{2}\right)}}\\
      
      \mathbf{else}:\\
      \;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(t\_3, t\_2 \cdot \sqrt{t\_1}\right)}{\sqrt{1 - \mathsf{fma}\left(t\_0, t\_1, {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if phi1 < -3.1e-7 or 3.1000000000000001e-12 < phi1

        1. Initial program 41.6%

          \[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. Step-by-step derivation
          1. Simplified41.6%

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

            \[\leadsto \color{blue}{{\left(\tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right), \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}\right)}} \cdot \left(2 \cdot R\right)\right)}^{1}} \]
          4. Step-by-step derivation
            1. unpow125.4%

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

            \[\leadsto \color{blue}{\tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right), \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}} \cdot \left(2 \cdot R\right)} \]
          6. Taylor expanded in phi2 around 0 25.1%

            \[\leadsto \tan^{-1}_* \frac{\mathsf{hypot}\left(\color{blue}{\sin \left(0.5 \cdot \phi_1\right)}, \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}} \cdot \left(2 \cdot R\right) \]
          7. Taylor expanded in phi2 around 0 26.4%

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

          if -3.1e-7 < phi1 < 3.1000000000000001e-12

          1. Initial program 79.5%

            \[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. Step-by-step derivation
            1. Simplified79.5%

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

              \[\leadsto \color{blue}{{\left(\tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right), \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}\right)}} \cdot \left(2 \cdot R\right)\right)}^{1}} \]
            4. Step-by-step derivation
              1. unpow165.2%

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

              \[\leadsto \color{blue}{\tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right), \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}} \cdot \left(2 \cdot R\right)} \]
            6. Taylor expanded in phi1 around 0 65.2%

              \[\leadsto \tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right), \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\color{blue}{\sin \left(-0.5 \cdot \phi_2\right)}}^{2}\right)}} \cdot \left(2 \cdot R\right) \]
            7. Step-by-step derivation
              1. *-commutative65.2%

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

              \[\leadsto \tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right), \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\color{blue}{\sin \left(\phi_2 \cdot -0.5\right)}}^{2}\right)}} \cdot \left(2 \cdot R\right) \]
          3. Recombined 2 regimes into one program.
          4. Final simplification43.5%

            \[\leadsto \begin{array}{l} \mathbf{if}\;\phi_1 \leq -3.1 \cdot 10^{-7} \lor \neg \left(\phi_1 \leq 3.1 \cdot 10^{-12}\right):\\ \;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(\phi_1 \cdot 0.5\right), \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right), \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}\\ \end{array} \]
          5. Add Preprocessing

          Alternative 15: 40.9% accurate, 1.1× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\\ t_1 := {t\_0}^{2}\\ t_2 := \cos \phi_1 \cdot \cos \phi_2\\ t_3 := \mathsf{hypot}\left(t\_0, \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{t\_2}\right)\\ \mathbf{if}\;\lambda_2 \leq -0.00018 \lor \neg \left(\lambda_2 \leq 5 \cdot 10^{-6}\right):\\ \;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{t\_3}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \lambda_2, t\_2, t\_1\right)}}\\ \mathbf{else}:\\ \;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{t\_3}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \lambda_1, t\_2, t\_1\right)}}\\ \end{array} \end{array} \]
          (FPCore (R lambda1 lambda2 phi1 phi2)
           :precision binary64
           (let* ((t_0 (sin (* 0.5 (- phi1 phi2))))
                  (t_1 (pow t_0 2.0))
                  (t_2 (* (cos phi1) (cos phi2)))
                  (t_3 (hypot t_0 (* (sin (* 0.5 (- lambda1 lambda2))) (sqrt t_2)))))
             (if (or (<= lambda2 -0.00018) (not (<= lambda2 5e-6)))
               (*
                (* R 2.0)
                (atan2 t_3 (sqrt (- 1.0 (fma (- 0.5 (* 0.5 (cos lambda2))) t_2 t_1)))))
               (*
                (* R 2.0)
                (atan2
                 t_3
                 (sqrt (- 1.0 (fma (- 0.5 (* 0.5 (cos lambda1))) t_2 t_1))))))))
          double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
          	double t_0 = sin((0.5 * (phi1 - phi2)));
          	double t_1 = pow(t_0, 2.0);
          	double t_2 = cos(phi1) * cos(phi2);
          	double t_3 = hypot(t_0, (sin((0.5 * (lambda1 - lambda2))) * sqrt(t_2)));
          	double tmp;
          	if ((lambda2 <= -0.00018) || !(lambda2 <= 5e-6)) {
          		tmp = (R * 2.0) * atan2(t_3, sqrt((1.0 - fma((0.5 - (0.5 * cos(lambda2))), t_2, t_1))));
          	} else {
          		tmp = (R * 2.0) * atan2(t_3, sqrt((1.0 - fma((0.5 - (0.5 * cos(lambda1))), t_2, t_1))));
          	}
          	return tmp;
          }
          
          function code(R, lambda1, lambda2, phi1, phi2)
          	t_0 = sin(Float64(0.5 * Float64(phi1 - phi2)))
          	t_1 = t_0 ^ 2.0
          	t_2 = Float64(cos(phi1) * cos(phi2))
          	t_3 = hypot(t_0, Float64(sin(Float64(0.5 * Float64(lambda1 - lambda2))) * sqrt(t_2)))
          	tmp = 0.0
          	if ((lambda2 <= -0.00018) || !(lambda2 <= 5e-6))
          		tmp = Float64(Float64(R * 2.0) * atan(t_3, sqrt(Float64(1.0 - fma(Float64(0.5 - Float64(0.5 * cos(lambda2))), t_2, t_1)))));
          	else
          		tmp = Float64(Float64(R * 2.0) * atan(t_3, sqrt(Float64(1.0 - fma(Float64(0.5 - Float64(0.5 * cos(lambda1))), t_2, t_1)))));
          	end
          	return tmp
          end
          
          code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[t$95$0, 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[t$95$0 ^ 2 + N[(N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[t$95$2], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]}, If[Or[LessEqual[lambda2, -0.00018], N[Not[LessEqual[lambda2, 5e-6]], $MachinePrecision]], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[t$95$3 / N[Sqrt[N[(1.0 - N[(N[(0.5 - N[(0.5 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$2 + t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[t$95$3 / N[Sqrt[N[(1.0 - N[(N[(0.5 - N[(0.5 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$2 + t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_0 := \sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\\
          t_1 := {t\_0}^{2}\\
          t_2 := \cos \phi_1 \cdot \cos \phi_2\\
          t_3 := \mathsf{hypot}\left(t\_0, \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{t\_2}\right)\\
          \mathbf{if}\;\lambda_2 \leq -0.00018 \lor \neg \left(\lambda_2 \leq 5 \cdot 10^{-6}\right):\\
          \;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{t\_3}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \lambda_2, t\_2, t\_1\right)}}\\
          
          \mathbf{else}:\\
          \;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{t\_3}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \lambda_1, t\_2, t\_1\right)}}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if lambda2 < -1.80000000000000011e-4 or 5.00000000000000041e-6 < lambda2

            1. Initial program 45.7%

              \[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. Step-by-step derivation
              1. Simplified45.7%

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

                \[\leadsto \color{blue}{{\left(\tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right), \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}\right)}} \cdot \left(2 \cdot R\right)\right)}^{1}} \]
              4. Step-by-step derivation
                1. unpow135.1%

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

                \[\leadsto \color{blue}{\tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right), \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}} \cdot \left(2 \cdot R\right)} \]
              6. Taylor expanded in lambda1 around 0 35.6%

                \[\leadsto \tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right), \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(\color{blue}{0.5 - 0.5 \cdot \cos \left(-\lambda_2\right)}, \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}} \cdot \left(2 \cdot R\right) \]
              7. Step-by-step derivation
                1. cos-neg35.6%

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

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

              if -1.80000000000000011e-4 < lambda2 < 5.00000000000000041e-6

              1. Initial program 71.3%

                \[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. Step-by-step derivation
                1. Simplified71.3%

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

                  \[\leadsto \color{blue}{{\left(\tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right), \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}\right)}} \cdot \left(2 \cdot R\right)\right)}^{1}} \]
                4. Step-by-step derivation
                  1. unpow151.1%

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

                  \[\leadsto \color{blue}{\tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right), \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}} \cdot \left(2 \cdot R\right)} \]
                6. Taylor expanded in lambda2 around 0 51.1%

                  \[\leadsto \tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right), \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(\color{blue}{0.5 - 0.5 \cdot \cos \lambda_1}, \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}} \cdot \left(2 \cdot R\right) \]
              3. Recombined 2 regimes into one program.
              4. Final simplification43.2%

                \[\leadsto \begin{array}{l} \mathbf{if}\;\lambda_2 \leq -0.00018 \lor \neg \left(\lambda_2 \leq 5 \cdot 10^{-6}\right):\\ \;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right), \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \lambda_2, \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right), \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \lambda_1, \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}}\\ \end{array} \]
              5. Add Preprocessing

              Alternative 16: 40.2% accurate, 1.1× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \phi_1 \cdot \cos \phi_2\\ t_1 := \sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\\ t_2 := \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\\ t_3 := {t\_1}^{2}\\ \mathbf{if}\;\lambda_2 \leq -2.85 \cdot 10^{-7} \lor \neg \left(\lambda_2 \leq 0.00012\right):\\ \;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(\phi_1 \cdot 0.5\right), t\_2 \cdot \sqrt{\cos \phi_1}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), t\_0, t\_3\right)}}\\ \mathbf{else}:\\ \;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(t\_1, t\_2 \cdot \sqrt{t\_0}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \lambda_1, t\_0, t\_3\right)}}\\ \end{array} \end{array} \]
              (FPCore (R lambda1 lambda2 phi1 phi2)
               :precision binary64
               (let* ((t_0 (* (cos phi1) (cos phi2)))
                      (t_1 (sin (* 0.5 (- phi1 phi2))))
                      (t_2 (sin (* 0.5 (- lambda1 lambda2))))
                      (t_3 (pow t_1 2.0)))
                 (if (or (<= lambda2 -2.85e-7) (not (<= lambda2 0.00012)))
                   (*
                    (* R 2.0)
                    (atan2
                     (hypot (sin (* phi1 0.5)) (* t_2 (sqrt (cos phi1))))
                     (sqrt (- 1.0 (fma (- 0.5 (* 0.5 (cos (- lambda1 lambda2)))) t_0 t_3)))))
                   (*
                    (* R 2.0)
                    (atan2
                     (hypot t_1 (* t_2 (sqrt t_0)))
                     (sqrt (- 1.0 (fma (- 0.5 (* 0.5 (cos lambda1))) t_0 t_3))))))))
              double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
              	double t_0 = cos(phi1) * cos(phi2);
              	double t_1 = sin((0.5 * (phi1 - phi2)));
              	double t_2 = sin((0.5 * (lambda1 - lambda2)));
              	double t_3 = pow(t_1, 2.0);
              	double tmp;
              	if ((lambda2 <= -2.85e-7) || !(lambda2 <= 0.00012)) {
              		tmp = (R * 2.0) * atan2(hypot(sin((phi1 * 0.5)), (t_2 * sqrt(cos(phi1)))), sqrt((1.0 - fma((0.5 - (0.5 * cos((lambda1 - lambda2)))), t_0, t_3))));
              	} else {
              		tmp = (R * 2.0) * atan2(hypot(t_1, (t_2 * sqrt(t_0))), sqrt((1.0 - fma((0.5 - (0.5 * cos(lambda1))), t_0, t_3))));
              	}
              	return tmp;
              }
              
              function code(R, lambda1, lambda2, phi1, phi2)
              	t_0 = Float64(cos(phi1) * cos(phi2))
              	t_1 = sin(Float64(0.5 * Float64(phi1 - phi2)))
              	t_2 = sin(Float64(0.5 * Float64(lambda1 - lambda2)))
              	t_3 = t_1 ^ 2.0
              	tmp = 0.0
              	if ((lambda2 <= -2.85e-7) || !(lambda2 <= 0.00012))
              		tmp = Float64(Float64(R * 2.0) * atan(hypot(sin(Float64(phi1 * 0.5)), Float64(t_2 * sqrt(cos(phi1)))), sqrt(Float64(1.0 - fma(Float64(0.5 - Float64(0.5 * cos(Float64(lambda1 - lambda2)))), t_0, t_3)))));
              	else
              		tmp = Float64(Float64(R * 2.0) * atan(hypot(t_1, Float64(t_2 * sqrt(t_0))), sqrt(Float64(1.0 - fma(Float64(0.5 - Float64(0.5 * cos(lambda1))), t_0, t_3)))));
              	end
              	return tmp
              end
              
              code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Power[t$95$1, 2.0], $MachinePrecision]}, If[Or[LessEqual[lambda2, -2.85e-7], N[Not[LessEqual[lambda2, 0.00012]], $MachinePrecision]], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] ^ 2 + N[(t$95$2 * N[Sqrt[N[Cos[phi1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(0.5 - N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0 + t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[t$95$1 ^ 2 + N[(t$95$2 * N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(0.5 - N[(0.5 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0 + t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              t_0 := \cos \phi_1 \cdot \cos \phi_2\\
              t_1 := \sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\\
              t_2 := \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\\
              t_3 := {t\_1}^{2}\\
              \mathbf{if}\;\lambda_2 \leq -2.85 \cdot 10^{-7} \lor \neg \left(\lambda_2 \leq 0.00012\right):\\
              \;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(\phi_1 \cdot 0.5\right), t\_2 \cdot \sqrt{\cos \phi_1}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), t\_0, t\_3\right)}}\\
              
              \mathbf{else}:\\
              \;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(t\_1, t\_2 \cdot \sqrt{t\_0}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \lambda_1, t\_0, t\_3\right)}}\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if lambda2 < -2.8500000000000002e-7 or 1.20000000000000003e-4 < lambda2

                1. Initial program 45.4%

                  \[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. Step-by-step derivation
                  1. Simplified45.4%

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

                    \[\leadsto \color{blue}{{\left(\tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right), \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}\right)}} \cdot \left(2 \cdot R\right)\right)}^{1}} \]
                  4. Step-by-step derivation
                    1. unpow134.8%

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

                    \[\leadsto \color{blue}{\tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right), \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}} \cdot \left(2 \cdot R\right)} \]
                  6. Taylor expanded in phi2 around 0 29.0%

                    \[\leadsto \tan^{-1}_* \frac{\mathsf{hypot}\left(\color{blue}{\sin \left(0.5 \cdot \phi_1\right)}, \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}} \cdot \left(2 \cdot R\right) \]
                  7. Taylor expanded in phi2 around 0 31.3%

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

                  if -2.8500000000000002e-7 < lambda2 < 1.20000000000000003e-4

                  1. Initial program 71.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. Step-by-step derivation
                    1. Simplified71.9%

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

                      \[\leadsto \color{blue}{{\left(\tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right), \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}\right)}} \cdot \left(2 \cdot R\right)\right)}^{1}} \]
                    4. Step-by-step derivation
                      1. unpow151.5%

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

                      \[\leadsto \color{blue}{\tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right), \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}} \cdot \left(2 \cdot R\right)} \]
                    6. Taylor expanded in lambda2 around 0 51.5%

                      \[\leadsto \tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right), \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(\color{blue}{0.5 - 0.5 \cdot \cos \lambda_1}, \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}} \cdot \left(2 \cdot R\right) \]
                  3. Recombined 2 regimes into one program.
                  4. Final simplification41.2%

                    \[\leadsto \begin{array}{l} \mathbf{if}\;\lambda_2 \leq -2.85 \cdot 10^{-7} \lor \neg \left(\lambda_2 \leq 0.00012\right):\\ \;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(\phi_1 \cdot 0.5\right), \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right), \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \lambda_1, \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}}\\ \end{array} \]
                  5. Add Preprocessing

                  Alternative 17: 39.0% accurate, 1.1× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \phi_1 \cdot \cos \phi_2\\ t_1 := \sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\\ t_2 := \sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), t\_0, {t\_1}^{2}\right)}\\ \mathbf{if}\;\lambda_2 \leq -5 \cdot 10^{-8} \lor \neg \left(\lambda_2 \leq 1.1 \cdot 10^{-13}\right):\\ \;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(\phi_1 \cdot 0.5\right), \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1}\right)}{t\_2}\\ \mathbf{else}:\\ \;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(t\_1, \sqrt{t\_0} \cdot \sin \left(0.5 \cdot \lambda_1\right)\right)}{t\_2}\\ \end{array} \end{array} \]
                  (FPCore (R lambda1 lambda2 phi1 phi2)
                   :precision binary64
                   (let* ((t_0 (* (cos phi1) (cos phi2)))
                          (t_1 (sin (* 0.5 (- phi1 phi2))))
                          (t_2
                           (sqrt
                            (-
                             1.0
                             (fma
                              (- 0.5 (* 0.5 (cos (- lambda1 lambda2))))
                              t_0
                              (pow t_1 2.0))))))
                     (if (or (<= lambda2 -5e-8) (not (<= lambda2 1.1e-13)))
                       (*
                        (* R 2.0)
                        (atan2
                         (hypot
                          (sin (* phi1 0.5))
                          (* (sin (* 0.5 (- lambda1 lambda2))) (sqrt (cos phi1))))
                         t_2))
                       (*
                        (* R 2.0)
                        (atan2 (hypot t_1 (* (sqrt t_0) (sin (* 0.5 lambda1)))) t_2)))))
                  double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
                  	double t_0 = cos(phi1) * cos(phi2);
                  	double t_1 = sin((0.5 * (phi1 - phi2)));
                  	double t_2 = sqrt((1.0 - fma((0.5 - (0.5 * cos((lambda1 - lambda2)))), t_0, pow(t_1, 2.0))));
                  	double tmp;
                  	if ((lambda2 <= -5e-8) || !(lambda2 <= 1.1e-13)) {
                  		tmp = (R * 2.0) * atan2(hypot(sin((phi1 * 0.5)), (sin((0.5 * (lambda1 - lambda2))) * sqrt(cos(phi1)))), t_2);
                  	} else {
                  		tmp = (R * 2.0) * atan2(hypot(t_1, (sqrt(t_0) * sin((0.5 * lambda1)))), t_2);
                  	}
                  	return tmp;
                  }
                  
                  function code(R, lambda1, lambda2, phi1, phi2)
                  	t_0 = Float64(cos(phi1) * cos(phi2))
                  	t_1 = sin(Float64(0.5 * Float64(phi1 - phi2)))
                  	t_2 = sqrt(Float64(1.0 - fma(Float64(0.5 - Float64(0.5 * cos(Float64(lambda1 - lambda2)))), t_0, (t_1 ^ 2.0))))
                  	tmp = 0.0
                  	if ((lambda2 <= -5e-8) || !(lambda2 <= 1.1e-13))
                  		tmp = Float64(Float64(R * 2.0) * atan(hypot(sin(Float64(phi1 * 0.5)), Float64(sin(Float64(0.5 * Float64(lambda1 - lambda2))) * sqrt(cos(phi1)))), t_2));
                  	else
                  		tmp = Float64(Float64(R * 2.0) * atan(hypot(t_1, Float64(sqrt(t_0) * sin(Float64(0.5 * lambda1)))), t_2));
                  	end
                  	return tmp
                  end
                  
                  code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(1.0 - N[(N[(0.5 - N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0 + N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[lambda2, -5e-8], N[Not[LessEqual[lambda2, 1.1e-13]], $MachinePrecision]], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] ^ 2 + N[(N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[Cos[phi1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] / t$95$2], $MachinePrecision]), $MachinePrecision], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[t$95$1 ^ 2 + N[(N[Sqrt[t$95$0], $MachinePrecision] * N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] / t$95$2], $MachinePrecision]), $MachinePrecision]]]]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  t_0 := \cos \phi_1 \cdot \cos \phi_2\\
                  t_1 := \sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\\
                  t_2 := \sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), t\_0, {t\_1}^{2}\right)}\\
                  \mathbf{if}\;\lambda_2 \leq -5 \cdot 10^{-8} \lor \neg \left(\lambda_2 \leq 1.1 \cdot 10^{-13}\right):\\
                  \;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(\phi_1 \cdot 0.5\right), \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1}\right)}{t\_2}\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(t\_1, \sqrt{t\_0} \cdot \sin \left(0.5 \cdot \lambda_1\right)\right)}{t\_2}\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if lambda2 < -4.9999999999999998e-8 or 1.09999999999999998e-13 < lambda2

                    1. Initial program 45.8%

                      \[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. Step-by-step derivation
                      1. Simplified45.8%

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

                        \[\leadsto \color{blue}{{\left(\tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right), \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}\right)}} \cdot \left(2 \cdot R\right)\right)}^{1}} \]
                      4. Step-by-step derivation
                        1. unpow134.6%

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

                        \[\leadsto \color{blue}{\tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right), \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}} \cdot \left(2 \cdot R\right)} \]
                      6. Taylor expanded in phi2 around 0 28.7%

                        \[\leadsto \tan^{-1}_* \frac{\mathsf{hypot}\left(\color{blue}{\sin \left(0.5 \cdot \phi_1\right)}, \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}} \cdot \left(2 \cdot R\right) \]
                      7. Taylor expanded in phi2 around 0 31.1%

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

                      if -4.9999999999999998e-8 < lambda2 < 1.09999999999999998e-13

                      1. Initial program 72.7%

                        \[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. Step-by-step derivation
                        1. Simplified72.7%

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

                          \[\leadsto \color{blue}{{\left(\tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right), \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}\right)}} \cdot \left(2 \cdot R\right)\right)}^{1}} \]
                        4. Step-by-step derivation
                          1. unpow152.6%

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

                          \[\leadsto \color{blue}{\tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right), \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}} \cdot \left(2 \cdot R\right)} \]
                        6. Taylor expanded in lambda2 around 0 50.3%

                          \[\leadsto \tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right), \color{blue}{\sin \left(0.5 \cdot \lambda_1\right)} \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}} \cdot \left(2 \cdot R\right) \]
                      3. Recombined 2 regimes into one program.
                      4. Final simplification40.0%

                        \[\leadsto \begin{array}{l} \mathbf{if}\;\lambda_2 \leq -5 \cdot 10^{-8} \lor \neg \left(\lambda_2 \leq 1.1 \cdot 10^{-13}\right):\\ \;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(\phi_1 \cdot 0.5\right), \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right), \sqrt{\cos \phi_1 \cdot \cos \phi_2} \cdot \sin \left(0.5 \cdot \lambda_1\right)\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}}\\ \end{array} \]
                      5. Add Preprocessing

                      Alternative 18: 41.0% accurate, 1.1× speedup?

                      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \phi_1 \cdot \cos \phi_2\\ t_1 := \sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\\ \left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(t\_1, \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{t\_0}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), t\_0, {t\_1}^{2}\right)}} \end{array} \end{array} \]
                      (FPCore (R lambda1 lambda2 phi1 phi2)
                       :precision binary64
                       (let* ((t_0 (* (cos phi1) (cos phi2))) (t_1 (sin (* 0.5 (- phi1 phi2)))))
                         (*
                          (* R 2.0)
                          (atan2
                           (hypot t_1 (* (sin (* 0.5 (- lambda1 lambda2))) (sqrt t_0)))
                           (sqrt
                            (-
                             1.0
                             (fma (- 0.5 (* 0.5 (cos (- lambda1 lambda2)))) t_0 (pow t_1 2.0))))))))
                      double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
                      	double t_0 = cos(phi1) * cos(phi2);
                      	double t_1 = sin((0.5 * (phi1 - phi2)));
                      	return (R * 2.0) * atan2(hypot(t_1, (sin((0.5 * (lambda1 - lambda2))) * sqrt(t_0))), sqrt((1.0 - fma((0.5 - (0.5 * cos((lambda1 - lambda2)))), t_0, pow(t_1, 2.0)))));
                      }
                      
                      function code(R, lambda1, lambda2, phi1, phi2)
                      	t_0 = Float64(cos(phi1) * cos(phi2))
                      	t_1 = sin(Float64(0.5 * Float64(phi1 - phi2)))
                      	return Float64(Float64(R * 2.0) * atan(hypot(t_1, Float64(sin(Float64(0.5 * Float64(lambda1 - lambda2))) * sqrt(t_0))), sqrt(Float64(1.0 - fma(Float64(0.5 - Float64(0.5 * cos(Float64(lambda1 - lambda2)))), t_0, (t_1 ^ 2.0))))))
                      end
                      
                      code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[t$95$1 ^ 2 + N[(N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(0.5 - N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0 + N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
                      
                      \begin{array}{l}
                      
                      \\
                      \begin{array}{l}
                      t_0 := \cos \phi_1 \cdot \cos \phi_2\\
                      t_1 := \sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\\
                      \left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(t\_1, \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{t\_0}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), t\_0, {t\_1}^{2}\right)}}
                      \end{array}
                      \end{array}
                      
                      Derivation
                      1. Initial program 58.3%

                        \[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. Step-by-step derivation
                        1. Simplified58.3%

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

                          \[\leadsto \color{blue}{{\left(\tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right), \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}\right)}} \cdot \left(2 \cdot R\right)\right)}^{1}} \]
                        4. Step-by-step derivation
                          1. unpow143.0%

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

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

                          \[\leadsto \left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right), \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}} \]
                        7. Add Preprocessing

                        Alternative 19: 34.9% accurate, 1.2× speedup?

                        \[\begin{array}{l} \\ \left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(\phi_1 \cdot 0.5\right), \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}} \end{array} \]
                        (FPCore (R lambda1 lambda2 phi1 phi2)
                         :precision binary64
                         (*
                          (* R 2.0)
                          (atan2
                           (hypot
                            (sin (* phi1 0.5))
                            (* (sin (* 0.5 (- lambda1 lambda2))) (sqrt (cos phi1))))
                           (sqrt
                            (-
                             1.0
                             (fma
                              (- 0.5 (* 0.5 (cos (- lambda1 lambda2))))
                              (* (cos phi1) (cos phi2))
                              (pow (sin (* 0.5 (- phi1 phi2))) 2.0)))))))
                        double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
                        	return (R * 2.0) * atan2(hypot(sin((phi1 * 0.5)), (sin((0.5 * (lambda1 - lambda2))) * sqrt(cos(phi1)))), sqrt((1.0 - fma((0.5 - (0.5 * cos((lambda1 - lambda2)))), (cos(phi1) * cos(phi2)), pow(sin((0.5 * (phi1 - phi2))), 2.0)))));
                        }
                        
                        function code(R, lambda1, lambda2, phi1, phi2)
                        	return Float64(Float64(R * 2.0) * atan(hypot(sin(Float64(phi1 * 0.5)), Float64(sin(Float64(0.5 * Float64(lambda1 - lambda2))) * sqrt(cos(phi1)))), sqrt(Float64(1.0 - fma(Float64(0.5 - Float64(0.5 * cos(Float64(lambda1 - lambda2)))), Float64(cos(phi1) * cos(phi2)), (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0))))))
                        end
                        
                        code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] ^ 2 + N[(N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[Cos[phi1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(0.5 - N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
                        
                        \begin{array}{l}
                        
                        \\
                        \left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(\phi_1 \cdot 0.5\right), \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}}
                        \end{array}
                        
                        Derivation
                        1. Initial program 58.3%

                          \[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. Step-by-step derivation
                          1. Simplified58.3%

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

                            \[\leadsto \color{blue}{{\left(\tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right), \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}\right)}} \cdot \left(2 \cdot R\right)\right)}^{1}} \]
                          4. Step-by-step derivation
                            1. unpow143.0%

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

                            \[\leadsto \color{blue}{\tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right), \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}} \cdot \left(2 \cdot R\right)} \]
                          6. Taylor expanded in phi2 around 0 30.5%

                            \[\leadsto \tan^{-1}_* \frac{\mathsf{hypot}\left(\color{blue}{\sin \left(0.5 \cdot \phi_1\right)}, \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}} \cdot \left(2 \cdot R\right) \]
                          7. Taylor expanded in phi2 around 0 32.7%

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

                            \[\leadsto \left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(\phi_1 \cdot 0.5\right), \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}} \]
                          9. Add Preprocessing

                          Alternative 20: 16.5% accurate, 1.3× speedup?

                          \[\begin{array}{l} \\ \left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{1 + {\phi_2}^{2} \cdot \left({\phi_2}^{2} \cdot 0.041666666666666664 - 0.5\right)}}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}} \end{array} \]
                          (FPCore (R lambda1 lambda2 phi1 phi2)
                           :precision binary64
                           (*
                            (* R 2.0)
                            (atan2
                             (*
                              (sin (* 0.5 (- lambda1 lambda2)))
                              (sqrt
                               (+
                                1.0
                                (* (pow phi2 2.0) (- (* (pow phi2 2.0) 0.041666666666666664) 0.5)))))
                             (sqrt
                              (-
                               1.0
                               (fma
                                (- 0.5 (* 0.5 (cos (- lambda1 lambda2))))
                                (* (cos phi1) (cos phi2))
                                (pow (sin (* 0.5 (- phi1 phi2))) 2.0)))))))
                          double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
                          	return (R * 2.0) * atan2((sin((0.5 * (lambda1 - lambda2))) * sqrt((1.0 + (pow(phi2, 2.0) * ((pow(phi2, 2.0) * 0.041666666666666664) - 0.5))))), sqrt((1.0 - fma((0.5 - (0.5 * cos((lambda1 - lambda2)))), (cos(phi1) * cos(phi2)), pow(sin((0.5 * (phi1 - phi2))), 2.0)))));
                          }
                          
                          function code(R, lambda1, lambda2, phi1, phi2)
                          	return Float64(Float64(R * 2.0) * atan(Float64(sin(Float64(0.5 * Float64(lambda1 - lambda2))) * sqrt(Float64(1.0 + Float64((phi2 ^ 2.0) * Float64(Float64((phi2 ^ 2.0) * 0.041666666666666664) - 0.5))))), sqrt(Float64(1.0 - fma(Float64(0.5 - Float64(0.5 * cos(Float64(lambda1 - lambda2)))), Float64(cos(phi1) * cos(phi2)), (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0))))))
                          end
                          
                          code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[(N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(1.0 + N[(N[Power[phi2, 2.0], $MachinePrecision] * N[(N[(N[Power[phi2, 2.0], $MachinePrecision] * 0.041666666666666664), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(0.5 - N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
                          
                          \begin{array}{l}
                          
                          \\
                          \left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{1 + {\phi_2}^{2} \cdot \left({\phi_2}^{2} \cdot 0.041666666666666664 - 0.5\right)}}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}}
                          \end{array}
                          
                          Derivation
                          1. Initial program 58.3%

                            \[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. Step-by-step derivation
                            1. Simplified58.3%

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

                              \[\leadsto \color{blue}{{\left(\tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right), \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}\right)}} \cdot \left(2 \cdot R\right)\right)}^{1}} \]
                            4. Step-by-step derivation
                              1. unpow143.0%

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

                              \[\leadsto \color{blue}{\tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right), \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}} \cdot \left(2 \cdot R\right)} \]
                            6. Taylor expanded in phi2 around 0 30.5%

                              \[\leadsto \tan^{-1}_* \frac{\mathsf{hypot}\left(\color{blue}{\sin \left(0.5 \cdot \phi_1\right)}, \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}} \cdot \left(2 \cdot R\right) \]
                            7. Taylor expanded in phi1 around 0 12.8%

                              \[\leadsto \tan^{-1}_* \frac{\color{blue}{\sqrt{\cos \phi_2} \cdot \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}} \cdot \left(2 \cdot R\right) \]
                            8. Taylor expanded in phi2 around 0 15.1%

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

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

                            Alternative 21: 16.3% accurate, 1.7× speedup?

                            \[\begin{array}{l} \\ \left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}} \end{array} \]
                            (FPCore (R lambda1 lambda2 phi1 phi2)
                             :precision binary64
                             (*
                              (* R 2.0)
                              (atan2
                               (sin (* 0.5 (- lambda1 lambda2)))
                               (sqrt
                                (-
                                 1.0
                                 (fma
                                  (- 0.5 (* 0.5 (cos (- lambda1 lambda2))))
                                  (* (cos phi1) (cos phi2))
                                  (pow (sin (* 0.5 (- phi1 phi2))) 2.0)))))))
                            double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
                            	return (R * 2.0) * atan2(sin((0.5 * (lambda1 - lambda2))), sqrt((1.0 - fma((0.5 - (0.5 * cos((lambda1 - lambda2)))), (cos(phi1) * cos(phi2)), pow(sin((0.5 * (phi1 - phi2))), 2.0)))));
                            }
                            
                            function code(R, lambda1, lambda2, phi1, phi2)
                            	return Float64(Float64(R * 2.0) * atan(sin(Float64(0.5 * Float64(lambda1 - lambda2))), sqrt(Float64(1.0 - fma(Float64(0.5 - Float64(0.5 * cos(Float64(lambda1 - lambda2)))), Float64(cos(phi1) * cos(phi2)), (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0))))))
                            end
                            
                            code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(0.5 - N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
                            
                            \begin{array}{l}
                            
                            \\
                            \left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}}
                            \end{array}
                            
                            Derivation
                            1. Initial program 58.3%

                              \[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. Step-by-step derivation
                              1. Simplified58.3%

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

                                \[\leadsto \color{blue}{{\left(\tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right), \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}\right)}} \cdot \left(2 \cdot R\right)\right)}^{1}} \]
                              4. Step-by-step derivation
                                1. unpow143.0%

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

                                \[\leadsto \color{blue}{\tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right), \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}} \cdot \left(2 \cdot R\right)} \]
                              6. Taylor expanded in phi2 around 0 30.5%

                                \[\leadsto \tan^{-1}_* \frac{\mathsf{hypot}\left(\color{blue}{\sin \left(0.5 \cdot \phi_1\right)}, \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}} \cdot \left(2 \cdot R\right) \]
                              7. Taylor expanded in phi1 around 0 12.8%

                                \[\leadsto \tan^{-1}_* \frac{\color{blue}{\sqrt{\cos \phi_2} \cdot \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1 \cdot \cos \phi_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}} \cdot \left(2 \cdot R\right) \]
                              8. Taylor expanded in phi2 around 0 15.0%

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

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

                              Reproduce

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