Distance on a great circle

Percentage Accurate: 63.3% → 79.8%
Time: 2.5min
Alternatives: 26
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 26 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: 63.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.8% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(t_0 \cdot t_0\right), {\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}\right)}}{\sqrt{{\left({\left(1 - \mathsf{fma}\left(\cos \phi_1, \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}, {\left(\mathsf{fma}\left(\sin \left(\phi_2 \cdot 0.5\right), \cos \left(\phi_1 \cdot 0.5\right), \sin \left(\phi_1 \cdot 0.5\right) \cdot \left(-\cos \left(\phi_2 \cdot 0.5\right)\right)\right)\right)}^{2}\right)\right)}^{3}\right)}^{0.3333333333333333}}}\right)
\end{array}
\end{array}
Derivation
  1. Initial program 64.2%

    \[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. Simplified64.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_2 - \phi_1}{2}\right)}^{2}\right)}}\right)} \]
  3. Step-by-step derivation
    1. div-sub64.3%

      \[\leadsto 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 \color{blue}{\left(\frac{\phi_1}{2} - \frac{\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_2 - \phi_1}{2}\right)}^{2}\right)}}\right) \]
    2. sin-diff65.2%

      \[\leadsto 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), {\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}\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_2 - \phi_1}{2}\right)}^{2}\right)}}\right) \]
  4. Applied egg-rr65.2%

    \[\leadsto 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), {\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}\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_2 - \phi_1}{2}\right)}^{2}\right)}}\right) \]
  5. Step-by-step derivation
    1. div-sub65.2%

      \[\leadsto 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), {\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}\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 \color{blue}{\left(\frac{\phi_2}{2} - \frac{\phi_1}{2}\right)}}^{2}\right)}}\right) \]
    2. sin-diff80.6%

      \[\leadsto 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), {\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}\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), {\color{blue}{\left(\sin \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right) - \cos \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right)\right)}}^{2}\right)}}\right) \]
  6. Applied egg-rr80.6%

    \[\leadsto 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), {\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}\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), {\color{blue}{\left(\sin \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right) - \cos \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right)\right)}}^{2}\right)}}\right) \]
  7. Step-by-step derivation
    1. fma-neg80.6%

      \[\leadsto 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), {\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}\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), {\color{blue}{\left(\mathsf{fma}\left(\sin \left(\frac{\phi_2}{2}\right), \cos \left(\frac{\phi_1}{2}\right), -\cos \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right)\right)\right)}}^{2}\right)}}\right) \]
    2. distribute-rgt-neg-in80.6%

      \[\leadsto 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), {\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}\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), {\left(\mathsf{fma}\left(\sin \left(\frac{\phi_2}{2}\right), \cos \left(\frac{\phi_1}{2}\right), \color{blue}{\cos \left(\frac{\phi_2}{2}\right) \cdot \left(-\sin \left(\frac{\phi_1}{2}\right)\right)}\right)\right)}^{2}\right)}}\right) \]
  8. Simplified80.6%

    \[\leadsto 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), {\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}\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), {\color{blue}{\left(\mathsf{fma}\left(\sin \left(\frac{\phi_2}{2}\right), \cos \left(\frac{\phi_1}{2}\right), \cos \left(\frac{\phi_2}{2}\right) \cdot \left(-\sin \left(\frac{\phi_1}{2}\right)\right)\right)\right)}}^{2}\right)}}\right) \]
  9. Applied egg-rr80.6%

    \[\leadsto 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), {\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}\right)}}{\sqrt{\color{blue}{{\left({\left(1 - \mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}, {\left(\mathsf{fma}\left(\sin \left(\phi_2 \cdot 0.5\right), \cos \left(\phi_1 \cdot 0.5\right), \cos \left(\phi_2 \cdot 0.5\right) \cdot \left(-\sin \left(\phi_1 \cdot 0.5\right)\right)\right)\right)}^{2}\right)\right)}^{3}\right)}^{0.3333333333333333}}}}\right) \]
  10. Step-by-step derivation
    1. metadata-eval80.6%

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

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

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

      \[\leadsto 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), {\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}\right)}}{\sqrt{{\left({\left(1 - \mathsf{fma}\left(\cos \phi_1, \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}, {\left(\mathsf{fma}\left(\sin \left(\phi_2 \cdot 0.5\right), \cos \left(\phi_1 \cdot 0.5\right), \cos \left(\phi_2 \cdot 0.5\right) \cdot \left(-\sin \left(\phi_1 \cdot 0.5\right)\right)\right)\right)}^{2}\right)\right)}^{3}\right)}^{0.3333333333333333}}}\right) \]
  11. Applied egg-rr81.1%

    \[\leadsto 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), {\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}\right)}}{\sqrt{{\left({\left(1 - \mathsf{fma}\left(\cos \phi_1, \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}, {\left(\mathsf{fma}\left(\sin \left(\phi_2 \cdot 0.5\right), \cos \left(\phi_1 \cdot 0.5\right), \cos \left(\phi_2 \cdot 0.5\right) \cdot \left(-\sin \left(\phi_1 \cdot 0.5\right)\right)\right)\right)}^{2}\right)\right)}^{3}\right)}^{0.3333333333333333}}}\right) \]
  12. Final simplification81.1%

    \[\leadsto 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), {\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}\right)}}{\sqrt{{\left({\left(1 - \mathsf{fma}\left(\cos \phi_1, \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}, {\left(\mathsf{fma}\left(\sin \left(\phi_2 \cdot 0.5\right), \cos \left(\phi_1 \cdot 0.5\right), \sin \left(\phi_1 \cdot 0.5\right) \cdot \left(-\cos \left(\phi_2 \cdot 0.5\right)\right)\right)\right)}^{2}\right)\right)}^{3}\right)}^{0.3333333333333333}}}\right) \]

Alternative 2: 79.3% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(t_0 \cdot t_0\right), {\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}\right)}}{\sqrt{{\left({\left(1 - \mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}, {\left(\mathsf{fma}\left(\sin \left(\phi_2 \cdot 0.5\right), \cos \left(\phi_1 \cdot 0.5\right), \sin \left(\phi_1 \cdot 0.5\right) \cdot \left(-\cos \left(\phi_2 \cdot 0.5\right)\right)\right)\right)}^{2}\right)\right)}^{3}\right)}^{0.3333333333333333}}}\right)
\end{array}
\end{array}
Derivation
  1. Initial program 64.2%

    \[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. Simplified64.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_2 - \phi_1}{2}\right)}^{2}\right)}}\right)} \]
  3. Step-by-step derivation
    1. div-sub64.3%

      \[\leadsto 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 \color{blue}{\left(\frac{\phi_1}{2} - \frac{\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_2 - \phi_1}{2}\right)}^{2}\right)}}\right) \]
    2. sin-diff65.2%

      \[\leadsto 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), {\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}\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_2 - \phi_1}{2}\right)}^{2}\right)}}\right) \]
  4. Applied egg-rr65.2%

    \[\leadsto 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), {\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}\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_2 - \phi_1}{2}\right)}^{2}\right)}}\right) \]
  5. Step-by-step derivation
    1. div-sub65.2%

      \[\leadsto 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), {\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}\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 \color{blue}{\left(\frac{\phi_2}{2} - \frac{\phi_1}{2}\right)}}^{2}\right)}}\right) \]
    2. sin-diff80.6%

      \[\leadsto 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), {\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}\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), {\color{blue}{\left(\sin \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right) - \cos \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right)\right)}}^{2}\right)}}\right) \]
  6. Applied egg-rr80.6%

    \[\leadsto 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), {\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}\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), {\color{blue}{\left(\sin \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right) - \cos \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right)\right)}}^{2}\right)}}\right) \]
  7. Step-by-step derivation
    1. fma-neg80.6%

      \[\leadsto 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), {\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}\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), {\color{blue}{\left(\mathsf{fma}\left(\sin \left(\frac{\phi_2}{2}\right), \cos \left(\frac{\phi_1}{2}\right), -\cos \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right)\right)\right)}}^{2}\right)}}\right) \]
    2. distribute-rgt-neg-in80.6%

      \[\leadsto 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), {\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}\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), {\left(\mathsf{fma}\left(\sin \left(\frac{\phi_2}{2}\right), \cos \left(\frac{\phi_1}{2}\right), \color{blue}{\cos \left(\frac{\phi_2}{2}\right) \cdot \left(-\sin \left(\frac{\phi_1}{2}\right)\right)}\right)\right)}^{2}\right)}}\right) \]
  8. Simplified80.6%

    \[\leadsto 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), {\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}\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), {\color{blue}{\left(\mathsf{fma}\left(\sin \left(\frac{\phi_2}{2}\right), \cos \left(\frac{\phi_1}{2}\right), \cos \left(\frac{\phi_2}{2}\right) \cdot \left(-\sin \left(\frac{\phi_1}{2}\right)\right)\right)\right)}}^{2}\right)}}\right) \]
  9. Applied egg-rr80.6%

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

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

Alternative 3: 79.3% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(t_0 \cdot t_0\right), {\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}\right)}}{\sqrt{e^{\mathsf{log1p}\left(-\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}, {\left(\mathsf{fma}\left(\sin \left(\phi_2 \cdot 0.5\right), \cos \left(\phi_1 \cdot 0.5\right), \sin \left(\phi_1 \cdot 0.5\right) \cdot \left(-\cos \left(\phi_2 \cdot 0.5\right)\right)\right)\right)}^{2}\right)\right)}}}\right) \end{array} \end{array} \]
(FPCore (R lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
   (*
    R
    (*
     2.0
     (atan2
      (sqrt
       (fma
        (cos phi1)
        (* (cos phi2) (* t_0 t_0))
        (pow
         (-
          (* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
          (* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
         2.0)))
      (sqrt
       (exp
        (log1p
         (-
          (fma
           (cos phi1)
           (* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
           (pow
            (fma
             (sin (* phi2 0.5))
             (cos (* phi1 0.5))
             (* (sin (* phi1 0.5)) (- (cos (* 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));
	return R * (2.0 * atan2(sqrt(fma(cos(phi1), (cos(phi2) * (t_0 * t_0)), pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0))), sqrt(exp(log1p(-fma(cos(phi1), (cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)), pow(fma(sin((phi2 * 0.5)), cos((phi1 * 0.5)), (sin((phi1 * 0.5)) * -cos((phi2 * 0.5)))), 2.0)))))));
}
function code(R, lambda1, lambda2, phi1, phi2)
	t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0))
	return Float64(R * Float64(2.0 * atan(sqrt(fma(cos(phi1), Float64(cos(phi2) * Float64(t_0 * t_0)), (Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0))), sqrt(exp(log1p(Float64(-fma(cos(phi1), Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)), (fma(sin(Float64(phi2 * 0.5)), cos(Float64(phi1 * 0.5)), Float64(sin(Float64(phi1 * 0.5)) * Float64(-cos(Float64(phi2 * 0.5))))) ^ 2.0)))))))))
end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Exp[N[Log[1 + (-N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] + N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * (-N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision])], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(t_0 \cdot t_0\right), {\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}\right)}}{\sqrt{e^{\mathsf{log1p}\left(-\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}, {\left(\mathsf{fma}\left(\sin \left(\phi_2 \cdot 0.5\right), \cos \left(\phi_1 \cdot 0.5\right), \sin \left(\phi_1 \cdot 0.5\right) \cdot \left(-\cos \left(\phi_2 \cdot 0.5\right)\right)\right)\right)}^{2}\right)\right)}}}\right)
\end{array}
\end{array}
Derivation
  1. Initial program 64.2%

    \[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. Simplified64.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_2 - \phi_1}{2}\right)}^{2}\right)}}\right)} \]
  3. Step-by-step derivation
    1. div-sub64.3%

      \[\leadsto 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 \color{blue}{\left(\frac{\phi_1}{2} - \frac{\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_2 - \phi_1}{2}\right)}^{2}\right)}}\right) \]
    2. sin-diff65.2%

      \[\leadsto 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), {\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}\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_2 - \phi_1}{2}\right)}^{2}\right)}}\right) \]
  4. Applied egg-rr65.2%

    \[\leadsto 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), {\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}\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_2 - \phi_1}{2}\right)}^{2}\right)}}\right) \]
  5. Step-by-step derivation
    1. div-sub65.2%

      \[\leadsto 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), {\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}\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 \color{blue}{\left(\frac{\phi_2}{2} - \frac{\phi_1}{2}\right)}}^{2}\right)}}\right) \]
    2. sin-diff80.6%

      \[\leadsto 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), {\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}\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), {\color{blue}{\left(\sin \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right) - \cos \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right)\right)}}^{2}\right)}}\right) \]
  6. Applied egg-rr80.6%

    \[\leadsto 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), {\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}\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), {\color{blue}{\left(\sin \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right) - \cos \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right)\right)}}^{2}\right)}}\right) \]
  7. Step-by-step derivation
    1. fma-neg80.6%

      \[\leadsto 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), {\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}\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), {\color{blue}{\left(\mathsf{fma}\left(\sin \left(\frac{\phi_2}{2}\right), \cos \left(\frac{\phi_1}{2}\right), -\cos \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right)\right)\right)}}^{2}\right)}}\right) \]
    2. distribute-rgt-neg-in80.6%

      \[\leadsto 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), {\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}\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), {\left(\mathsf{fma}\left(\sin \left(\frac{\phi_2}{2}\right), \cos \left(\frac{\phi_1}{2}\right), \color{blue}{\cos \left(\frac{\phi_2}{2}\right) \cdot \left(-\sin \left(\frac{\phi_1}{2}\right)\right)}\right)\right)}^{2}\right)}}\right) \]
  8. Simplified80.6%

    \[\leadsto 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), {\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}\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), {\color{blue}{\left(\mathsf{fma}\left(\sin \left(\frac{\phi_2}{2}\right), \cos \left(\frac{\phi_1}{2}\right), \cos \left(\frac{\phi_2}{2}\right) \cdot \left(-\sin \left(\frac{\phi_1}{2}\right)\right)\right)\right)}}^{2}\right)}}\right) \]
  9. Applied egg-rr80.6%

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

    \[\leadsto 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), {\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}\right)}}{\sqrt{e^{\mathsf{log1p}\left(-\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}, {\left(\mathsf{fma}\left(\sin \left(\phi_2 \cdot 0.5\right), \cos \left(\phi_1 \cdot 0.5\right), \sin \left(\phi_1 \cdot 0.5\right) \cdot \left(-\cos \left(\phi_2 \cdot 0.5\right)\right)\right)\right)}^{2}\right)\right)}}}\right) \]

Alternative 4: 79.3% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
t_0 := \sin \left(\frac{\phi_2}{2}\right)\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \sin \left(\frac{\phi_1}{2}\right)\\
t_3 := \cos \left(\frac{\phi_2}{2}\right)\\
t_4 := \cos \phi_2 \cdot \left(t_1 \cdot t_1\right)\\
t_5 := \cos \left(\frac{\phi_1}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, t_4, {\left(t_2 \cdot t_3 - t_5 \cdot t_0\right)}^{2}\right)}}{\sqrt{1 - \mathsf{fma}\left(\cos \phi_1, t_4, {\left(\mathsf{fma}\left(t_0, t_5, t_2 \cdot \left(-t_3\right)\right)\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Derivation
  1. Initial program 64.2%

    \[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. Simplified64.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_2 - \phi_1}{2}\right)}^{2}\right)}}\right)} \]
  3. Step-by-step derivation
    1. div-sub64.3%

      \[\leadsto 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 \color{blue}{\left(\frac{\phi_1}{2} - \frac{\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_2 - \phi_1}{2}\right)}^{2}\right)}}\right) \]
    2. sin-diff65.2%

      \[\leadsto 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), {\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}\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_2 - \phi_1}{2}\right)}^{2}\right)}}\right) \]
  4. Applied egg-rr65.2%

    \[\leadsto 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), {\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}\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_2 - \phi_1}{2}\right)}^{2}\right)}}\right) \]
  5. Step-by-step derivation
    1. div-sub65.2%

      \[\leadsto 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), {\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}\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 \color{blue}{\left(\frac{\phi_2}{2} - \frac{\phi_1}{2}\right)}}^{2}\right)}}\right) \]
    2. sin-diff80.6%

      \[\leadsto 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), {\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}\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), {\color{blue}{\left(\sin \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right) - \cos \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right)\right)}}^{2}\right)}}\right) \]
  6. Applied egg-rr80.6%

    \[\leadsto 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), {\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}\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), {\color{blue}{\left(\sin \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right) - \cos \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right)\right)}}^{2}\right)}}\right) \]
  7. Step-by-step derivation
    1. fma-neg80.6%

      \[\leadsto 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), {\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}\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), {\color{blue}{\left(\mathsf{fma}\left(\sin \left(\frac{\phi_2}{2}\right), \cos \left(\frac{\phi_1}{2}\right), -\cos \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right)\right)\right)}}^{2}\right)}}\right) \]
    2. distribute-rgt-neg-in80.6%

      \[\leadsto 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), {\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}\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), {\left(\mathsf{fma}\left(\sin \left(\frac{\phi_2}{2}\right), \cos \left(\frac{\phi_1}{2}\right), \color{blue}{\cos \left(\frac{\phi_2}{2}\right) \cdot \left(-\sin \left(\frac{\phi_1}{2}\right)\right)}\right)\right)}^{2}\right)}}\right) \]
  8. Simplified80.6%

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

    \[\leadsto 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), {\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}\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), {\left(\mathsf{fma}\left(\sin \left(\frac{\phi_2}{2}\right), \cos \left(\frac{\phi_1}{2}\right), \sin \left(\frac{\phi_1}{2}\right) \cdot \left(-\cos \left(\frac{\phi_2}{2}\right)\right)\right)\right)}^{2}\right)}}\right) \]

Alternative 5: 67.3% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_1 := \sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(t_0 \cdot t_0\right), {\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}\right)}\\ \mathbf{if}\;\lambda_1 \leq -1.8 \cdot 10^{-5}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{\left|1 - \mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(0.5 + -0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right), {\sin \left(0.5 \cdot \left(\phi_2 - \phi_1\right)\right)}^{2}\right)\right|}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{1 - \left({\left(\cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot 0.5\right) - \cos \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right)\right)}^{2} + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right)\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
          (fma
           (cos phi1)
           (* (cos phi2) (* t_0 t_0))
           (pow
            (-
             (* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
             (* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
            2.0)))))
   (if (<= lambda1 -1.8e-5)
     (*
      R
      (*
       2.0
       (atan2
        t_1
        (sqrt
         (fabs
          (-
           1.0
           (fma
            (cos phi1)
            (* (cos phi2) (+ 0.5 (* -0.5 (cos (- lambda1 lambda2)))))
            (pow (sin (* 0.5 (- phi2 phi1))) 2.0))))))))
     (*
      R
      (*
       2.0
       (atan2
        t_1
        (sqrt
         (-
          1.0
          (+
           (pow
            (-
             (* (cos (* phi1 0.5)) (sin (* phi2 0.5)))
             (* (cos (* phi2 0.5)) (sin (* phi1 0.5))))
            2.0)
           (*
            (cos phi1)
            (* (cos phi2) (pow (sin (* lambda2 -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(fma(cos(phi1), (cos(phi2) * (t_0 * t_0)), pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0)));
	double tmp;
	if (lambda1 <= -1.8e-5) {
		tmp = R * (2.0 * atan2(t_1, sqrt(fabs((1.0 - fma(cos(phi1), (cos(phi2) * (0.5 + (-0.5 * cos((lambda1 - lambda2))))), pow(sin((0.5 * (phi2 - phi1))), 2.0)))))));
	} else {
		tmp = R * (2.0 * atan2(t_1, sqrt((1.0 - (pow(((cos((phi1 * 0.5)) * sin((phi2 * 0.5))) - (cos((phi2 * 0.5)) * sin((phi1 * 0.5)))), 2.0) + (cos(phi1) * (cos(phi2) * pow(sin((lambda2 * -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(fma(cos(phi1), Float64(cos(phi2) * Float64(t_0 * t_0)), (Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0)))
	tmp = 0.0
	if (lambda1 <= -1.8e-5)
		tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(abs(Float64(1.0 - fma(cos(phi1), Float64(cos(phi2) * Float64(0.5 + Float64(-0.5 * cos(Float64(lambda1 - lambda2))))), (sin(Float64(0.5 * Float64(phi2 - phi1))) ^ 2.0))))))));
	else
		tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64(1.0 - Float64((Float64(Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(phi2 * 0.5))) - Float64(cos(Float64(phi2 * 0.5)) * sin(Float64(phi1 * 0.5)))) ^ 2.0) + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0)))))))));
	end
	return 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[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -1.8e-5], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[Abs[N[(1.0 - N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 + N[(-0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(0.5 * N[(phi2 - phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $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{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(t_0 \cdot t_0\right), {\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}\right)}\\
\mathbf{if}\;\lambda_1 \leq -1.8 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{\left|1 - \mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(0.5 + -0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right), {\sin \left(0.5 \cdot \left(\phi_2 - \phi_1\right)\right)}^{2}\right)\right|}}\right)\\

\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{1 - \left({\left(\cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot 0.5\right) - \cos \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right)\right)}^{2} + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right)\right)}}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if lambda1 < -1.80000000000000005e-5

    1. Initial program 49.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. Simplified49.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_2 - \phi_1}{2}\right)}^{2}\right)}}\right)} \]
    3. Step-by-step derivation
      1. div-sub49.4%

        \[\leadsto 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 \color{blue}{\left(\frac{\phi_1}{2} - \frac{\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_2 - \phi_1}{2}\right)}^{2}\right)}}\right) \]
      2. sin-diff50.4%

        \[\leadsto 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), {\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}\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_2 - \phi_1}{2}\right)}^{2}\right)}}\right) \]
    4. Applied egg-rr50.4%

      \[\leadsto 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), {\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}\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_2 - \phi_1}{2}\right)}^{2}\right)}}\right) \]
    5. Applied egg-rr50.9%

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

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

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

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

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

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

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

    if -1.80000000000000005e-5 < lambda1

    1. Initial program 70.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. Simplified70.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_2 - \phi_1}{2}\right)}^{2}\right)}}\right)} \]
    3. Step-by-step derivation
      1. div-sub70.5%

        \[\leadsto 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 \color{blue}{\left(\frac{\phi_1}{2} - \frac{\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_2 - \phi_1}{2}\right)}^{2}\right)}}\right) \]
      2. sin-diff71.4%

        \[\leadsto 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), {\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}\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_2 - \phi_1}{2}\right)}^{2}\right)}}\right) \]
    4. Applied egg-rr71.4%

      \[\leadsto 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), {\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}\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_2 - \phi_1}{2}\right)}^{2}\right)}}\right) \]
    5. Step-by-step derivation
      1. div-sub71.4%

        \[\leadsto 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), {\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}\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 \color{blue}{\left(\frac{\phi_2}{2} - \frac{\phi_1}{2}\right)}}^{2}\right)}}\right) \]
      2. sin-diff89.9%

        \[\leadsto 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), {\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}\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), {\color{blue}{\left(\sin \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right) - \cos \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right)\right)}}^{2}\right)}}\right) \]
    6. Applied egg-rr89.9%

      \[\leadsto 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), {\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}\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), {\color{blue}{\left(\sin \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right) - \cos \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right)\right)}}^{2}\right)}}\right) \]
    7. Step-by-step derivation
      1. fma-neg90.0%

        \[\leadsto 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), {\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}\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), {\color{blue}{\left(\mathsf{fma}\left(\sin \left(\frac{\phi_2}{2}\right), \cos \left(\frac{\phi_1}{2}\right), -\cos \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right)\right)\right)}}^{2}\right)}}\right) \]
      2. distribute-rgt-neg-in90.0%

        \[\leadsto 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), {\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}\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), {\left(\mathsf{fma}\left(\sin \left(\frac{\phi_2}{2}\right), \cos \left(\frac{\phi_1}{2}\right), \color{blue}{\cos \left(\frac{\phi_2}{2}\right) \cdot \left(-\sin \left(\frac{\phi_1}{2}\right)\right)}\right)\right)}^{2}\right)}}\right) \]
    8. Simplified90.0%

      \[\leadsto 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), {\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}\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), {\color{blue}{\left(\mathsf{fma}\left(\sin \left(\frac{\phi_2}{2}\right), \cos \left(\frac{\phi_1}{2}\right), \cos \left(\frac{\phi_2}{2}\right) \cdot \left(-\sin \left(\frac{\phi_1}{2}\right)\right)\right)\right)}}^{2}\right)}}\right) \]
    9. Taylor expanded in lambda1 around 0 75.1%

      \[\leadsto 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), {\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}\right)}}{\sqrt{\color{blue}{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(-0.5 \cdot \lambda_2\right)}^{2}\right) + {\left(-1 \cdot \left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right)\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 simplification68.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\lambda_1 \leq -1.8 \cdot 10^{-5}:\\ \;\;\;\;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), {\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}\right)}}{\sqrt{\left|1 - \mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(0.5 + -0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right), {\sin \left(0.5 \cdot \left(\phi_2 - \phi_1\right)\right)}^{2}\right)\right|}}\right)\\ \mathbf{else}:\\ \;\;\;\;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), {\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}\right)}}{\sqrt{1 - \left({\left(\cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot 0.5\right) - \cos \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right)\right)}^{2} + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right)\right)}}\right)\\ \end{array} \]

Alternative 6: 69.7% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_1 := {\left(\cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot 0.5\right) - \cos \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right)\right)}^{2}\\ t_2 := \sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(t_0 \cdot t_0\right), {\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}\right)}\\ \mathbf{if}\;\lambda_1 \leq -3.5 \cdot 10^{-6}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_2}{\sqrt{1 - \left(t_1 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}\right)\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_2}{\sqrt{1 - \left(t_1 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right)\right)}}\right)\\ \end{array} \end{array} \]
(FPCore (R lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
        (t_1
         (pow
          (-
           (* (cos (* phi1 0.5)) (sin (* phi2 0.5)))
           (* (cos (* phi2 0.5)) (sin (* phi1 0.5))))
          2.0))
        (t_2
         (sqrt
          (fma
           (cos phi1)
           (* (cos phi2) (* t_0 t_0))
           (pow
            (-
             (* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
             (* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
            2.0)))))
   (if (<= lambda1 -3.5e-6)
     (*
      R
      (*
       2.0
       (atan2
        t_2
        (sqrt
         (-
          1.0
          (+
           t_1
           (* (cos phi1) (* (cos phi2) (pow (sin (* lambda1 0.5)) 2.0)))))))))
     (*
      R
      (*
       2.0
       (atan2
        t_2
        (sqrt
         (-
          1.0
          (+
           t_1
           (*
            (cos phi1)
            (* (cos phi2) (pow (sin (* lambda2 -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 = pow(((cos((phi1 * 0.5)) * sin((phi2 * 0.5))) - (cos((phi2 * 0.5)) * sin((phi1 * 0.5)))), 2.0);
	double t_2 = sqrt(fma(cos(phi1), (cos(phi2) * (t_0 * t_0)), pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0)));
	double tmp;
	if (lambda1 <= -3.5e-6) {
		tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - (t_1 + (cos(phi1) * (cos(phi2) * pow(sin((lambda1 * 0.5)), 2.0))))))));
	} else {
		tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - (t_1 + (cos(phi1) * (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0))))))));
	}
	return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2)
	t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0))
	t_1 = Float64(Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(phi2 * 0.5))) - Float64(cos(Float64(phi2 * 0.5)) * sin(Float64(phi1 * 0.5)))) ^ 2.0
	t_2 = sqrt(fma(cos(phi1), Float64(cos(phi2) * Float64(t_0 * t_0)), (Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0)))
	tmp = 0.0
	if (lambda1 <= -3.5e-6)
		tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64(1.0 - Float64(t_1 + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda1 * 0.5)) ^ 2.0)))))))));
	else
		tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64(1.0 - Float64(t_1 + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0)))))))));
	end
	return 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[Power[N[(N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -3.5e-6], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(1.0 - N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(1.0 - N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $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 := {\left(\cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot 0.5\right) - \cos \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right)\right)}^{2}\\
t_2 := \sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(t_0 \cdot t_0\right), {\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}\right)}\\
\mathbf{if}\;\lambda_1 \leq -3.5 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_2}{\sqrt{1 - \left(t_1 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}\right)\right)}}\right)\\

\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_2}{\sqrt{1 - \left(t_1 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right)\right)}}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if lambda1 < -3.49999999999999995e-6

    1. Initial program 49.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. Simplified49.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_2 - \phi_1}{2}\right)}^{2}\right)}}\right)} \]
    3. Step-by-step derivation
      1. div-sub49.4%

        \[\leadsto 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 \color{blue}{\left(\frac{\phi_1}{2} - \frac{\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_2 - \phi_1}{2}\right)}^{2}\right)}}\right) \]
      2. sin-diff50.4%

        \[\leadsto 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), {\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}\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_2 - \phi_1}{2}\right)}^{2}\right)}}\right) \]
    4. Applied egg-rr50.4%

      \[\leadsto 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), {\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}\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_2 - \phi_1}{2}\right)}^{2}\right)}}\right) \]
    5. Step-by-step derivation
      1. div-sub50.4%

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

        \[\leadsto 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), {\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}\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), {\color{blue}{\left(\sin \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right) - \cos \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right)\right)}}^{2}\right)}}\right) \]
    6. Applied egg-rr58.3%

      \[\leadsto 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), {\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}\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), {\color{blue}{\left(\sin \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right) - \cos \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right)\right)}}^{2}\right)}}\right) \]
    7. Step-by-step derivation
      1. fma-neg58.3%

        \[\leadsto 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), {\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}\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), {\color{blue}{\left(\mathsf{fma}\left(\sin \left(\frac{\phi_2}{2}\right), \cos \left(\frac{\phi_1}{2}\right), -\cos \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right)\right)\right)}}^{2}\right)}}\right) \]
      2. distribute-rgt-neg-in58.3%

        \[\leadsto 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), {\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}\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), {\left(\mathsf{fma}\left(\sin \left(\frac{\phi_2}{2}\right), \cos \left(\frac{\phi_1}{2}\right), \color{blue}{\cos \left(\frac{\phi_2}{2}\right) \cdot \left(-\sin \left(\frac{\phi_1}{2}\right)\right)}\right)\right)}^{2}\right)}}\right) \]
    8. Simplified58.3%

      \[\leadsto 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), {\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}\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), {\color{blue}{\left(\mathsf{fma}\left(\sin \left(\frac{\phi_2}{2}\right), \cos \left(\frac{\phi_1}{2}\right), \cos \left(\frac{\phi_2}{2}\right) \cdot \left(-\sin \left(\frac{\phi_1}{2}\right)\right)\right)\right)}}^{2}\right)}}\right) \]
    9. Taylor expanded in lambda2 around 0 58.2%

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

    if -3.49999999999999995e-6 < lambda1

    1. Initial program 70.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. Simplified70.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_2 - \phi_1}{2}\right)}^{2}\right)}}\right)} \]
    3. Step-by-step derivation
      1. div-sub70.5%

        \[\leadsto 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 \color{blue}{\left(\frac{\phi_1}{2} - \frac{\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_2 - \phi_1}{2}\right)}^{2}\right)}}\right) \]
      2. sin-diff71.4%

        \[\leadsto 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), {\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}\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_2 - \phi_1}{2}\right)}^{2}\right)}}\right) \]
    4. Applied egg-rr71.4%

      \[\leadsto 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), {\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}\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_2 - \phi_1}{2}\right)}^{2}\right)}}\right) \]
    5. Step-by-step derivation
      1. div-sub71.4%

        \[\leadsto 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), {\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}\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 \color{blue}{\left(\frac{\phi_2}{2} - \frac{\phi_1}{2}\right)}}^{2}\right)}}\right) \]
      2. sin-diff89.9%

        \[\leadsto 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), {\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}\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), {\color{blue}{\left(\sin \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right) - \cos \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right)\right)}}^{2}\right)}}\right) \]
    6. Applied egg-rr89.9%

      \[\leadsto 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), {\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}\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), {\color{blue}{\left(\sin \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right) - \cos \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right)\right)}}^{2}\right)}}\right) \]
    7. Step-by-step derivation
      1. fma-neg90.0%

        \[\leadsto 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), {\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}\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), {\color{blue}{\left(\mathsf{fma}\left(\sin \left(\frac{\phi_2}{2}\right), \cos \left(\frac{\phi_1}{2}\right), -\cos \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right)\right)\right)}}^{2}\right)}}\right) \]
      2. distribute-rgt-neg-in90.0%

        \[\leadsto 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), {\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}\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), {\left(\mathsf{fma}\left(\sin \left(\frac{\phi_2}{2}\right), \cos \left(\frac{\phi_1}{2}\right), \color{blue}{\cos \left(\frac{\phi_2}{2}\right) \cdot \left(-\sin \left(\frac{\phi_1}{2}\right)\right)}\right)\right)}^{2}\right)}}\right) \]
    8. Simplified90.0%

      \[\leadsto 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), {\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}\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), {\color{blue}{\left(\mathsf{fma}\left(\sin \left(\frac{\phi_2}{2}\right), \cos \left(\frac{\phi_1}{2}\right), \cos \left(\frac{\phi_2}{2}\right) \cdot \left(-\sin \left(\frac{\phi_1}{2}\right)\right)\right)\right)}}^{2}\right)}}\right) \]
    9. Taylor expanded in lambda1 around 0 75.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\lambda_1 \leq -3.5 \cdot 10^{-6}:\\ \;\;\;\;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), {\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}\right)}}{\sqrt{1 - \left({\left(\cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot 0.5\right) - \cos \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right)\right)}^{2} + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}\right)\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;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), {\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}\right)}}{\sqrt{1 - \left({\left(\cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot 0.5\right) - \cos \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right)\right)}^{2} + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right)\right)}}\right)\\ \end{array} \]

Alternative 7: 79.3% accurate, 0.7× speedup?

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

    \[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. Simplified64.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_2 - \phi_1}{2}\right)}^{2}\right)}}\right)} \]
  3. Step-by-step derivation
    1. div-sub64.3%

      \[\leadsto 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 \color{blue}{\left(\frac{\phi_1}{2} - \frac{\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_2 - \phi_1}{2}\right)}^{2}\right)}}\right) \]
    2. sin-diff65.2%

      \[\leadsto 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), {\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}\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_2 - \phi_1}{2}\right)}^{2}\right)}}\right) \]
  4. Applied egg-rr65.2%

    \[\leadsto 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), {\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}\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_2 - \phi_1}{2}\right)}^{2}\right)}}\right) \]
  5. Step-by-step derivation
    1. div-sub65.2%

      \[\leadsto 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), {\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}\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 \color{blue}{\left(\frac{\phi_2}{2} - \frac{\phi_1}{2}\right)}}^{2}\right)}}\right) \]
    2. sin-diff80.6%

      \[\leadsto 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), {\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}\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), {\color{blue}{\left(\sin \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right) - \cos \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right)\right)}}^{2}\right)}}\right) \]
  6. Applied egg-rr80.6%

    \[\leadsto 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), {\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}\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), {\color{blue}{\left(\sin \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right) - \cos \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right)\right)}}^{2}\right)}}\right) \]
  7. Step-by-step derivation
    1. fma-neg80.6%

      \[\leadsto 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), {\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}\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), {\color{blue}{\left(\mathsf{fma}\left(\sin \left(\frac{\phi_2}{2}\right), \cos \left(\frac{\phi_1}{2}\right), -\cos \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right)\right)\right)}}^{2}\right)}}\right) \]
    2. distribute-rgt-neg-in80.6%

      \[\leadsto 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), {\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}\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), {\left(\mathsf{fma}\left(\sin \left(\frac{\phi_2}{2}\right), \cos \left(\frac{\phi_1}{2}\right), \color{blue}{\cos \left(\frac{\phi_2}{2}\right) \cdot \left(-\sin \left(\frac{\phi_1}{2}\right)\right)}\right)\right)}^{2}\right)}}\right) \]
  8. Simplified80.6%

    \[\leadsto 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), {\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}\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), {\color{blue}{\left(\mathsf{fma}\left(\sin \left(\frac{\phi_2}{2}\right), \cos \left(\frac{\phi_1}{2}\right), \cos \left(\frac{\phi_2}{2}\right) \cdot \left(-\sin \left(\frac{\phi_1}{2}\right)\right)\right)\right)}}^{2}\right)}}\right) \]
  9. Taylor expanded in phi1 around inf 80.6%

    \[\leadsto 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), {\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}\right)}}{\sqrt{\color{blue}{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(-1 \cdot \left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right)\right) + \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}}\right) \]
  10. Final simplification80.6%

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

Alternative 8: 64.6% accurate, 0.8× speedup?

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

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

    \[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. Simplified64.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_2 - \phi_1}{2}\right)}^{2}\right)}}\right)} \]
  3. Step-by-step derivation
    1. div-sub64.3%

      \[\leadsto 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 \color{blue}{\left(\frac{\phi_1}{2} - \frac{\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_2 - \phi_1}{2}\right)}^{2}\right)}}\right) \]
    2. sin-diff65.2%

      \[\leadsto 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), {\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}\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_2 - \phi_1}{2}\right)}^{2}\right)}}\right) \]
  4. Applied egg-rr65.2%

    \[\leadsto 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), {\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}\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_2 - \phi_1}{2}\right)}^{2}\right)}}\right) \]
  5. Applied egg-rr65.4%

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

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

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

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

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

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

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

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

Alternative 9: 64.1% 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(t_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\\ R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_1}}{\sqrt{1 - \left({\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} + 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 (* t_0 (* (cos phi1) (cos phi2))))))
   (*
    R
    (*
     2.0
     (atan2
      (sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_1))
      (sqrt
       (-
        1.0
        (+
         (pow
          (-
           (* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
           (* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
          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 * (t_0 * (cos(phi1) * cos(phi2)));
	return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), sqrt((1.0 - (pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 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 * (t_0 * (cos(phi1) * cos(phi2)))
    code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_1)), sqrt((1.0d0 - ((((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 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 * (t_0 * (Math.cos(phi1) * Math.cos(phi2)));
	return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), Math.sqrt((1.0 - (Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0) + t_1)))));
}
def code(R, lambda1, lambda2, phi1, phi2):
	t_0 = math.sin(((lambda1 - lambda2) / 2.0))
	t_1 = t_0 * (t_0 * (math.cos(phi1) * math.cos(phi2)))
	return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), math.sqrt((1.0 - (math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 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(t_0 * Float64(cos(phi1) * cos(phi2))))
	return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt(Float64(1.0 - Float64((Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0) + t_1))))))
end
function tmp = code(R, lambda1, lambda2, phi1, phi2)
	t_0 = sin(((lambda1 - lambda2) / 2.0));
	t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2)));
	tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt((1.0 - ((((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 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[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $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(t_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_1}}{\sqrt{1 - \left({\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} + t_1\right)}}\right)
\end{array}
\end{array}
Derivation
  1. Initial program 64.2%

    \[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. div-sub64.3%

      \[\leadsto 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 \color{blue}{\left(\frac{\phi_1}{2} - \frac{\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_2 - \phi_1}{2}\right)}^{2}\right)}}\right) \]
    2. sin-diff65.2%

      \[\leadsto 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), {\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}\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_2 - \phi_1}{2}\right)}^{2}\right)}}\right) \]
  3. Applied egg-rr64.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({\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) \]
  4. Final simplification64.9%

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

Alternative 10: 64.2% 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(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot t_0\right)\right)\\ R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\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} + t_1}}{\sqrt{1 - \left(t_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\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 (* t_0 (* (cos phi1) (* (cos phi2) t_0)))))
   (*
    R
    (*
     2.0
     (atan2
      (sqrt
       (+
        (pow
         (-
          (* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
          (* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
         2.0)
        t_1))
      (sqrt (- 1.0 (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 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 = t_0 * (cos(phi1) * (cos(phi2) * t_0));
	return R * (2.0 * atan2(sqrt((pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0) + t_1)), sqrt((1.0 - (t_1 + pow(sin(((phi1 - phi2) / 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
    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 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0) + t_1)), sqrt((1.0d0 - (t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))))))
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 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0) + t_1)), Math.sqrt((1.0 - (t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))))));
}
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 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) + t_1)), math.sqrt((1.0 - (t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2)
	t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0))
	t_1 = Float64(t_0 * Float64(cos(phi1) * Float64(cos(phi2) * t_0)))
	return Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0) + t_1)), sqrt(Float64(1.0 - Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)))))))
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 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0) + t_1)), sqrt((1.0 - (t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))))));
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[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $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 := t_0 \cdot \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot t_0\right)\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\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} + t_1}}{\sqrt{1 - \left(t_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Derivation
  1. Initial program 64.2%

    \[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. Simplified64.2%

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

      \[\leadsto 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 \color{blue}{\left(\frac{\phi_1}{2} - \frac{\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_2 - \phi_1}{2}\right)}^{2}\right)}}\right) \]
    2. sin-diff65.2%

      \[\leadsto 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), {\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}\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_2 - \phi_1}{2}\right)}^{2}\right)}}\right) \]
  4. Applied egg-rr65.1%

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

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

Alternative 11: 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 := \cos \phi_1 \cdot \left(\cos \phi_2 \cdot t_0\right)\\ 2 \cdot \left(R \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(t_0, t_1, {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}{\sqrt{1 - \mathsf{fma}\left(t_0, t_1, 0.5 - \frac{\cos \left(\phi_1 - \phi_2\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 (* (cos phi1) (* (cos phi2) t_0))))
   (*
    2.0
    (*
     R
     (atan2
      (sqrt (fma t_0 t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
      (sqrt (- 1.0 (fma t_0 t_1 (- 0.5 (/ (cos (- phi1 phi2)) 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 = cos(phi1) * (cos(phi2) * t_0);
	return 2.0 * (R * atan2(sqrt(fma(t_0, t_1, pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - fma(t_0, t_1, (0.5 - (cos((phi1 - phi2)) / 2.0)))))));
}
function code(R, lambda1, lambda2, phi1, phi2)
	t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0))
	t_1 = Float64(cos(phi1) * Float64(cos(phi2) * t_0))
	return Float64(2.0 * Float64(R * atan(sqrt(fma(t_0, t_1, (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - fma(t_0, t_1, Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0))))))))
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[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(2.0 * N[(R * N[ArcTan[N[Sqrt[N[(t$95$0 * 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[(t$95$0 * t$95$1 + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $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 := \cos \phi_1 \cdot \left(\cos \phi_2 \cdot t_0\right)\\
2 \cdot \left(R \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(t_0, t_1, {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}{\sqrt{1 - \mathsf{fma}\left(t_0, t_1, 0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}\right)
\end{array}
\end{array}
Derivation
  1. Initial program 64.2%

    \[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. Simplified64.3%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto 2 \cdot \left(\tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right), \cos \phi_1 \cdot \left(\cos \phi_2 \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(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right), \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right), \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}}\right)}} \cdot R\right) \]
  5. Step-by-step derivation
    1. div-sub62.5%

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

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

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

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

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

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

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

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

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

Alternative 12: 60.7% 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(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot t_0\right)\right)\\ R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{1 - \left(t_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\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 (* t_0 (* (cos phi1) (* (cos phi2) t_0)))))
   (*
    R
    (*
     2.0
     (atan2
      (sqrt (+ t_1 (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
      (sqrt (- 1.0 (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 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 = t_0 * (cos(phi1) * (cos(phi2) * t_0));
	return R * (2.0 * atan2(sqrt((t_1 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - (t_1 + pow(sin(((phi1 - phi2) / 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
    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 + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt((1.0d0 - (t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))))))
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 + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), Math.sqrt((1.0 - (t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))))));
}
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 + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), math.sqrt((1.0 - (t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2)
	t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0))
	t_1 = Float64(t_0 * Float64(cos(phi1) * Float64(cos(phi2) * t_0)))
	return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(1.0 - Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)))))))
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 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - (t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))))));
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[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $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 := t_0 \cdot \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot t_0\right)\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{1 - \left(t_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Derivation
  1. Initial program 64.2%

    \[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. Simplified64.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 63.3% 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(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot t_0\right)\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(cos(phi1) * Float64(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[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $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(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot t_0\right)\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 64.2%

    \[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. Simplified64.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 62.3% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
t_0 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_1 := {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\phi_2 \leq -1.1 \cdot 10^{-5} \lor \neg \left(\phi_2 \leq 4.4 \cdot 10^{-11}\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 - \left({\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_2 \cdot \left(t_2 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\right)}}\right)\\

\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 \cdot \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot t_2\right)\right) + t_1}}{\sqrt{1 - \left(\cos \phi_1 \cdot t_0 + t_1\right)}}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if phi2 < -1.1e-5 or 4.4000000000000003e-11 < phi2

    1. Initial program 53.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. Taylor expanded in phi1 around 0 49.2%

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

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

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

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

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

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

      \[\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 -1.1e-5 < phi2 < 4.4000000000000003e-11

    1. Initial program 77.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. Simplified77.6%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\phi_2 \leq -1.1 \cdot 10^{-5} \lor \neg \left(\phi_2 \leq 4.4 \cdot 10^{-11}\right):\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2} + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{1 - \left({\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)\right) + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2} + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\ \end{array} \]

Alternative 15: 63.6% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\ t_1 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\ t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ \mathbf{if}\;\phi_2 \leq -1.9 \cdot 10^{-5} \lor \neg \left(\phi_2 \leq 4.4 \cdot 10^{-11}\right):\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot t_1 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{1 - \left(t_0 + t_2 \cdot \left(t_2 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 \cdot \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot t_2\right)\right) + t_0}}{\sqrt{1 - \left(\cos \phi_1 \cdot t_1 + {\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 (/ (- phi1 phi2) 2.0)) 2.0))
        (t_1 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
        (t_2 (sin (/ (- lambda1 lambda2) 2.0))))
   (if (or (<= phi2 -1.9e-5) (not (<= phi2 4.4e-11)))
     (*
      R
      (*
       2.0
       (atan2
        (sqrt (+ (* (cos phi2) t_1) (pow (sin (* phi2 -0.5)) 2.0)))
        (sqrt (- 1.0 (+ t_0 (* t_2 (* t_2 (* (cos phi1) (cos phi2))))))))))
     (*
      R
      (*
       2.0
       (atan2
        (sqrt (+ (* t_2 (* (cos phi1) (* (cos phi2) t_2))) t_0))
        (sqrt
         (- 1.0 (+ (* (cos phi1) t_1) (pow (sin (* phi1 0.5)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
	double t_1 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
	double t_2 = sin(((lambda1 - lambda2) / 2.0));
	double tmp;
	if ((phi2 <= -1.9e-5) || !(phi2 <= 4.4e-11)) {
		tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * t_1) + pow(sin((phi2 * -0.5)), 2.0))), sqrt((1.0 - (t_0 + (t_2 * (t_2 * (cos(phi1) * cos(phi2)))))))));
	} else {
		tmp = R * (2.0 * atan2(sqrt(((t_2 * (cos(phi1) * (cos(phi2) * t_2))) + t_0)), sqrt((1.0 - ((cos(phi1) * t_1) + 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(((phi1 - phi2) / 2.0d0)) ** 2.0d0
    t_1 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
    t_2 = sin(((lambda1 - lambda2) / 2.0d0))
    if ((phi2 <= (-1.9d-5)) .or. (.not. (phi2 <= 4.4d-11))) then
        tmp = r * (2.0d0 * atan2(sqrt(((cos(phi2) * t_1) + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt((1.0d0 - (t_0 + (t_2 * (t_2 * (cos(phi1) * cos(phi2)))))))))
    else
        tmp = r * (2.0d0 * atan2(sqrt(((t_2 * (cos(phi1) * (cos(phi2) * t_2))) + t_0)), sqrt((1.0d0 - ((cos(phi1) * t_1) + (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(((phi1 - phi2) / 2.0)), 2.0);
	double t_1 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
	double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
	double tmp;
	if ((phi2 <= -1.9e-5) || !(phi2 <= 4.4e-11)) {
		tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi2) * t_1) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt((1.0 - (t_0 + (t_2 * (t_2 * (Math.cos(phi1) * Math.cos(phi2)))))))));
	} else {
		tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_2 * (Math.cos(phi1) * (Math.cos(phi2) * t_2))) + t_0)), Math.sqrt((1.0 - ((Math.cos(phi1) * t_1) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
	}
	return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2):
	t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)
	t_1 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)
	t_2 = math.sin(((lambda1 - lambda2) / 2.0))
	tmp = 0
	if (phi2 <= -1.9e-5) or not (phi2 <= 4.4e-11):
		tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi2) * t_1) + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt((1.0 - (t_0 + (t_2 * (t_2 * (math.cos(phi1) * math.cos(phi2)))))))))
	else:
		tmp = R * (2.0 * math.atan2(math.sqrt(((t_2 * (math.cos(phi1) * (math.cos(phi2) * t_2))) + t_0)), math.sqrt((1.0 - ((math.cos(phi1) * t_1) + math.pow(math.sin((phi1 * 0.5)), 2.0))))))
	return tmp
function code(R, lambda1, lambda2, phi1, phi2)
	t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0
	t_1 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0
	t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0))
	tmp = 0.0
	if ((phi2 <= -1.9e-5) || !(phi2 <= 4.4e-11))
		tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi2) * t_1) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64(1.0 - Float64(t_0 + Float64(t_2 * Float64(t_2 * Float64(cos(phi1) * cos(phi2))))))))));
	else
		tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_2 * Float64(cos(phi1) * Float64(cos(phi2) * t_2))) + t_0)), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_1) + (sin(Float64(phi1 * 0.5)) ^ 2.0)))))));
	end
	return tmp
end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
	t_0 = sin(((phi1 - phi2) / 2.0)) ^ 2.0;
	t_1 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0;
	t_2 = sin(((lambda1 - lambda2) / 2.0));
	tmp = 0.0;
	if ((phi2 <= -1.9e-5) || ~((phi2 <= 4.4e-11)))
		tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * t_1) + (sin((phi2 * -0.5)) ^ 2.0))), sqrt((1.0 - (t_0 + (t_2 * (t_2 * (cos(phi1) * cos(phi2)))))))));
	else
		tmp = R * (2.0 * atan2(sqrt(((t_2 * (cos(phi1) * (cos(phi2) * t_2))) + t_0)), sqrt((1.0 - ((cos(phi1) * t_1) + (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[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -1.9e-5], N[Not[LessEqual[phi2, 4.4e-11]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$0 + N[(t$95$2 * N[(t$95$2 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$2 * N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $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(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\phi_2 \leq -1.9 \cdot 10^{-5} \lor \neg \left(\phi_2 \leq 4.4 \cdot 10^{-11}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot t_1 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{1 - \left(t_0 + t_2 \cdot \left(t_2 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\right)}}\right)\\

\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 \cdot \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot t_2\right)\right) + t_0}}{\sqrt{1 - \left(\cos \phi_1 \cdot t_1 + {\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 < -1.9000000000000001e-5 or 4.4000000000000003e-11 < phi2

    1. Initial program 53.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. Taylor expanded in phi1 around 0 49.2%

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

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

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

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

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

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

      \[\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 -1.9000000000000001e-5 < phi2 < 4.4000000000000003e-11

    1. Initial program 77.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. Simplified77.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\phi_2 \leq -1.9 \cdot 10^{-5} \lor \neg \left(\phi_2 \leq 4.4 \cdot 10^{-11}\right):\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2} + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{1 - \left({\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2} + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\ \end{array} \]

Alternative 16: 63.6% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\ t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_2 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\ t_3 := \cos \phi_2 \cdot t_2 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\\ t_4 := \sqrt{t_1 \cdot \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot t_1\right)\right) + t_0}\\ \mathbf{if}\;\phi_2 \leq -2.6 \cdot 10^{-5}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_3}}{\sqrt{1 - \left(t_0 + t_1 \cdot \left(t_1 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\right)}}\right)\\ \mathbf{elif}\;\phi_2 \leq 4.4 \cdot 10^{-11}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_4}{\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_4}{\sqrt{1 - t_3}}\right)\\ \end{array} \end{array} \]
(FPCore (R lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
        (t_1 (sin (/ (- lambda1 lambda2) 2.0)))
        (t_2 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
        (t_3 (+ (* (cos phi2) t_2) (pow (sin (* phi2 -0.5)) 2.0)))
        (t_4 (sqrt (+ (* t_1 (* (cos phi1) (* (cos phi2) t_1))) t_0))))
   (if (<= phi2 -2.6e-5)
     (*
      R
      (*
       2.0
       (atan2
        (sqrt t_3)
        (sqrt (- 1.0 (+ t_0 (* t_1 (* t_1 (* (cos phi1) (cos phi2))))))))))
     (if (<= phi2 4.4e-11)
       (*
        R
        (*
         2.0
         (atan2
          t_4
          (sqrt (- 1.0 (+ (* (cos phi1) t_2) (pow (sin (* phi1 0.5)) 2.0)))))))
       (* R (* 2.0 (atan2 t_4 (sqrt (- 1.0 t_3)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
	double t_1 = sin(((lambda1 - lambda2) / 2.0));
	double t_2 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
	double t_3 = (cos(phi2) * t_2) + pow(sin((phi2 * -0.5)), 2.0);
	double t_4 = sqrt(((t_1 * (cos(phi1) * (cos(phi2) * t_1))) + t_0));
	double tmp;
	if (phi2 <= -2.6e-5) {
		tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - (t_0 + (t_1 * (t_1 * (cos(phi1) * cos(phi2)))))))));
	} else if (phi2 <= 4.4e-11) {
		tmp = R * (2.0 * atan2(t_4, sqrt((1.0 - ((cos(phi1) * t_2) + pow(sin((phi1 * 0.5)), 2.0))))));
	} else {
		tmp = R * (2.0 * atan2(t_4, sqrt((1.0 - t_3))));
	}
	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) :: tmp
    t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
    t_1 = sin(((lambda1 - lambda2) / 2.0d0))
    t_2 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
    t_3 = (cos(phi2) * t_2) + (sin((phi2 * (-0.5d0))) ** 2.0d0)
    t_4 = sqrt(((t_1 * (cos(phi1) * (cos(phi2) * t_1))) + t_0))
    if (phi2 <= (-2.6d-5)) then
        tmp = r * (2.0d0 * atan2(sqrt(t_3), sqrt((1.0d0 - (t_0 + (t_1 * (t_1 * (cos(phi1) * cos(phi2)))))))))
    else if (phi2 <= 4.4d-11) then
        tmp = r * (2.0d0 * atan2(t_4, sqrt((1.0d0 - ((cos(phi1) * t_2) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
    else
        tmp = r * (2.0d0 * atan2(t_4, sqrt((1.0d0 - t_3))))
    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 - phi2) / 2.0)), 2.0);
	double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
	double t_2 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
	double t_3 = (Math.cos(phi2) * t_2) + Math.pow(Math.sin((phi2 * -0.5)), 2.0);
	double t_4 = Math.sqrt(((t_1 * (Math.cos(phi1) * (Math.cos(phi2) * t_1))) + t_0));
	double tmp;
	if (phi2 <= -2.6e-5) {
		tmp = R * (2.0 * Math.atan2(Math.sqrt(t_3), Math.sqrt((1.0 - (t_0 + (t_1 * (t_1 * (Math.cos(phi1) * Math.cos(phi2)))))))));
	} else if (phi2 <= 4.4e-11) {
		tmp = R * (2.0 * Math.atan2(t_4, 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_4, Math.sqrt((1.0 - t_3))));
	}
	return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2):
	t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)
	t_1 = math.sin(((lambda1 - lambda2) / 2.0))
	t_2 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)
	t_3 = (math.cos(phi2) * t_2) + math.pow(math.sin((phi2 * -0.5)), 2.0)
	t_4 = math.sqrt(((t_1 * (math.cos(phi1) * (math.cos(phi2) * t_1))) + t_0))
	tmp = 0
	if phi2 <= -2.6e-5:
		tmp = R * (2.0 * math.atan2(math.sqrt(t_3), math.sqrt((1.0 - (t_0 + (t_1 * (t_1 * (math.cos(phi1) * math.cos(phi2)))))))))
	elif phi2 <= 4.4e-11:
		tmp = R * (2.0 * math.atan2(t_4, 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_4, math.sqrt((1.0 - t_3))))
	return tmp
function code(R, lambda1, lambda2, phi1, phi2)
	t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0
	t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0))
	t_2 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0
	t_3 = Float64(Float64(cos(phi2) * t_2) + (sin(Float64(phi2 * -0.5)) ^ 2.0))
	t_4 = sqrt(Float64(Float64(t_1 * Float64(cos(phi1) * Float64(cos(phi2) * t_1))) + t_0))
	tmp = 0.0
	if (phi2 <= -2.6e-5)
		tmp = Float64(R * Float64(2.0 * atan(sqrt(t_3), sqrt(Float64(1.0 - Float64(t_0 + Float64(t_1 * Float64(t_1 * Float64(cos(phi1) * cos(phi2))))))))));
	elseif (phi2 <= 4.4e-11)
		tmp = Float64(R * Float64(2.0 * atan(t_4, 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_4, sqrt(Float64(1.0 - t_3)))));
	end
	return tmp
end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
	t_0 = sin(((phi1 - phi2) / 2.0)) ^ 2.0;
	t_1 = sin(((lambda1 - lambda2) / 2.0));
	t_2 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0;
	t_3 = (cos(phi2) * t_2) + (sin((phi2 * -0.5)) ^ 2.0);
	t_4 = sqrt(((t_1 * (cos(phi1) * (cos(phi2) * t_1))) + t_0));
	tmp = 0.0;
	if (phi2 <= -2.6e-5)
		tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - (t_0 + (t_1 * (t_1 * (cos(phi1) * cos(phi2)))))))));
	elseif (phi2 <= 4.4e-11)
		tmp = R * (2.0 * atan2(t_4, sqrt((1.0 - ((cos(phi1) * t_2) + (sin((phi1 * 0.5)) ^ 2.0))))));
	else
		tmp = R * (2.0 * atan2(t_4, sqrt((1.0 - t_3))));
	end
	tmp_2 = tmp;
end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $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[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(N[(t$95$1 * N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -2.6e-5], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$3], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$0 + N[(t$95$1 * N[(t$95$1 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 4.4e-11], N[(R * N[(2.0 * N[ArcTan[t$95$4 / 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$4 / N[Sqrt[N[(1.0 - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_3 := \cos \phi_2 \cdot t_2 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\\
t_4 := \sqrt{t_1 \cdot \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot t_1\right)\right) + t_0}\\
\mathbf{if}\;\phi_2 \leq -2.6 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_3}}{\sqrt{1 - \left(t_0 + t_1 \cdot \left(t_1 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\right)}}\right)\\

\mathbf{elif}\;\phi_2 \leq 4.4 \cdot 10^{-11}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_4}{\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_4}{\sqrt{1 - t_3}}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if phi2 < -2.59999999999999984e-5

    1. Initial program 43.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. Taylor expanded in phi1 around 0 39.2%

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

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

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

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

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

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

      \[\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.59999999999999984e-5 < phi2 < 4.4000000000000003e-11

    1. Initial program 77.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. Simplified77.6%

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

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

    1. Initial program 64.2%

      \[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. Simplified64.2%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\phi_2 \leq -2.6 \cdot 10^{-5}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2} + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{1 - \left({\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\right)}}\right)\\ \mathbf{elif}\;\phi_2 \leq 4.4 \cdot 10^{-11}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\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(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2} + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}\right)\\ \end{array} \]

Alternative 17: 48.7% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_1 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\ t_2 := {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\\ \mathbf{if}\;\phi_2 \leq -0.0035 \lor \neg \left(\phi_2 \leq 4.2 \cdot 10^{-11}\right):\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot t_1 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{1 - \mathsf{fma}\left({\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}, \cos \phi_1, {\sin \left(\phi_1 \cdot -0.5\right)}^{2}\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot t_0\right)\right) + t_2}}{\sqrt{1 - \left(\cos \phi_1 \cdot t_1 + t_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 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
        (t_2 (pow (sin (* phi1 0.5)) 2.0)))
   (if (or (<= phi2 -0.0035) (not (<= phi2 4.2e-11)))
     (*
      R
      (*
       2.0
       (atan2
        (sqrt (+ (* (cos phi2) t_1) (pow (sin (* phi2 -0.5)) 2.0)))
        (sqrt
         (-
          1.0
          (fma
           (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)
           (cos phi1)
           (pow (sin (* phi1 -0.5)) 2.0)))))))
     (*
      R
      (*
       2.0
       (atan2
        (sqrt (+ (* t_0 (* (cos phi1) (* (cos phi2) t_0))) t_2))
        (sqrt (- 1.0 (+ (* (cos phi1) t_1) 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 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
	double t_2 = pow(sin((phi1 * 0.5)), 2.0);
	double tmp;
	if ((phi2 <= -0.0035) || !(phi2 <= 4.2e-11)) {
		tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * t_1) + pow(sin((phi2 * -0.5)), 2.0))), sqrt((1.0 - fma(pow(sin((-0.5 * (lambda2 - lambda1))), 2.0), cos(phi1), pow(sin((phi1 * -0.5)), 2.0))))));
	} else {
		tmp = R * (2.0 * atan2(sqrt(((t_0 * (cos(phi1) * (cos(phi2) * t_0))) + t_2)), sqrt((1.0 - ((cos(phi1) * t_1) + t_2)))));
	}
	return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2)
	t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0))
	t_1 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0
	t_2 = sin(Float64(phi1 * 0.5)) ^ 2.0
	tmp = 0.0
	if ((phi2 <= -0.0035) || !(phi2 <= 4.2e-11))
		tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi2) * t_1) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64(1.0 - fma((sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0), cos(phi1), (sin(Float64(phi1 * -0.5)) ^ 2.0)))))));
	else
		tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(cos(phi1) * Float64(cos(phi2) * t_0))) + t_2)), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_1) + t_2))))));
	end
	return 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[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[phi2, -0.0035], N[Not[LessEqual[phi2, 4.2e-11]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] * N[Cos[phi1], $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[(N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$2), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision] + t$95$2), $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 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_2 := {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\\
\mathbf{if}\;\phi_2 \leq -0.0035 \lor \neg \left(\phi_2 \leq 4.2 \cdot 10^{-11}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot t_1 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{1 - \mathsf{fma}\left({\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}, \cos \phi_1, {\sin \left(\phi_1 \cdot -0.5\right)}^{2}\right)}}\right)\\

\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot t_0\right)\right) + t_2}}{\sqrt{1 - \left(\cos \phi_1 \cdot t_1 + t_2\right)}}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if phi2 < -0.00350000000000000007 or 4.1999999999999997e-11 < phi2

    1. Initial program 52.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. Simplified52.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_2 - \phi_1}{2}\right)}^{2}\right)}}\right)} \]
    3. Taylor expanded in phi2 around 0 22.0%

      \[\leadsto 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{\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) \]
    4. Step-by-step derivation
      1. *-commutative22.0%

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

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

      \[\leadsto 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{\color{blue}{1 - \mathsf{fma}\left({\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}, \cos \phi_1, {\sin \left(-0.5 \cdot \phi_1\right)}^{2}\right)}}}\right) \]
    6. Taylor expanded in phi1 around 0 22.0%

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

      \[\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 - \mathsf{fma}\left({\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}, \cos \phi_1, {\sin \left(-0.5 \cdot \phi_1\right)}^{2}\right)}}\right) \]

    if -0.00350000000000000007 < phi2 < 4.1999999999999997e-11

    1. Initial program 77.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. Simplified77.5%

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

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

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

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

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

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

Alternative 18: 41.9% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\ t_1 := \sqrt{1 - \left(\cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2} + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}\\ t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ \mathbf{if}\;\lambda_2 \leq 3.55 \cdot 10^{-40}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \sin \left(\lambda_1 \cdot 0.5\right)\right)\right)}}{t_1}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \sin \left(\lambda_2 \cdot -0.5\right)\right)\right)}}{t_1}\right)\\ \end{array} \end{array} \]
(FPCore (R lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
        (t_1
         (sqrt
          (-
           1.0
           (+
            (* (cos phi1) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
            (pow (sin (* phi1 0.5)) 2.0)))))
        (t_2 (sin (/ (- lambda1 lambda2) 2.0))))
   (if (<= lambda2 3.55e-40)
     (*
      R
      (*
       2.0
       (atan2
        (sqrt
         (+ t_0 (* t_2 (* (cos phi1) (* (cos phi2) (sin (* lambda1 0.5)))))))
        t_1)))
     (*
      R
      (*
       2.0
       (atan2
        (sqrt
         (+ t_0 (* t_2 (* (cos phi1) (* (cos phi2) (sin (* lambda2 -0.5)))))))
        t_1))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
	double t_1 = sqrt((1.0 - ((cos(phi1) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)) + pow(sin((phi1 * 0.5)), 2.0))));
	double t_2 = sin(((lambda1 - lambda2) / 2.0));
	double tmp;
	if (lambda2 <= 3.55e-40) {
		tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (cos(phi1) * (cos(phi2) * sin((lambda1 * 0.5))))))), t_1));
	} else {
		tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (cos(phi1) * (cos(phi2) * sin((lambda2 * -0.5))))))), t_1));
	}
	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(((phi1 - phi2) / 2.0d0)) ** 2.0d0
    t_1 = sqrt((1.0d0 - ((cos(phi1) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)) + (sin((phi1 * 0.5d0)) ** 2.0d0))))
    t_2 = sin(((lambda1 - lambda2) / 2.0d0))
    if (lambda2 <= 3.55d-40) then
        tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_2 * (cos(phi1) * (cos(phi2) * sin((lambda1 * 0.5d0))))))), t_1))
    else
        tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_2 * (cos(phi1) * (cos(phi2) * sin((lambda2 * (-0.5d0)))))))), t_1))
    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 - phi2) / 2.0)), 2.0);
	double t_1 = Math.sqrt((1.0 - ((Math.cos(phi1) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))));
	double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
	double tmp;
	if (lambda2 <= 3.55e-40) {
		tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * (Math.cos(phi1) * (Math.cos(phi2) * Math.sin((lambda1 * 0.5))))))), t_1));
	} else {
		tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * (Math.cos(phi1) * (Math.cos(phi2) * Math.sin((lambda2 * -0.5))))))), t_1));
	}
	return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2):
	t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)
	t_1 = math.sqrt((1.0 - ((math.cos(phi1) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)) + math.pow(math.sin((phi1 * 0.5)), 2.0))))
	t_2 = math.sin(((lambda1 - lambda2) / 2.0))
	tmp = 0
	if lambda2 <= 3.55e-40:
		tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_2 * (math.cos(phi1) * (math.cos(phi2) * math.sin((lambda1 * 0.5))))))), t_1))
	else:
		tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_2 * (math.cos(phi1) * (math.cos(phi2) * math.sin((lambda2 * -0.5))))))), t_1))
	return tmp
function code(R, lambda1, lambda2, phi1, phi2)
	t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0
	t_1 = sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))
	t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0))
	tmp = 0.0
	if (lambda2 <= 3.55e-40)
		tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * Float64(cos(phi1) * Float64(cos(phi2) * sin(Float64(lambda1 * 0.5))))))), t_1)));
	else
		tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * Float64(cos(phi1) * Float64(cos(phi2) * sin(Float64(lambda2 * -0.5))))))), t_1)));
	end
	return tmp
end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
	t_0 = sin(((phi1 - phi2) / 2.0)) ^ 2.0;
	t_1 = sqrt((1.0 - ((cos(phi1) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)) + (sin((phi1 * 0.5)) ^ 2.0))));
	t_2 = sin(((lambda1 - lambda2) / 2.0));
	tmp = 0.0;
	if (lambda2 <= 3.55e-40)
		tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (cos(phi1) * (cos(phi2) * sin((lambda1 * 0.5))))))), t_1));
	else
		tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (cos(phi1) * (cos(phi2) * sin((lambda2 * -0.5))))))), t_1));
	end
	tmp_2 = tmp;
end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, 3.55e-40], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := \sqrt{1 - \left(\cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2} + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\lambda_2 \leq 3.55 \cdot 10^{-40}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \sin \left(\lambda_1 \cdot 0.5\right)\right)\right)}}{t_1}\right)\\

\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \sin \left(\lambda_2 \cdot -0.5\right)\right)\right)}}{t_1}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if lambda2 < 3.55000000000000012e-40

    1. Initial program 69.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. Simplified69.6%

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

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

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

    1. Initial program 48.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. Simplified48.8%

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

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

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

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

Alternative 19: 44.4% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_1 := {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\\ t_2 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\ \mathbf{if}\;\lambda_2 \leq 2.6 \cdot 10^{-5}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot t_0\right)\right) + t_2}}{\sqrt{1 - \left(t_1 + \cos \phi_1 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 + t_0 \cdot \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \sin \left(\lambda_2 \cdot -0.5\right)\right)\right)}}{\sqrt{1 - \left(\cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\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 (pow (sin (* phi1 0.5)) 2.0))
        (t_2 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
   (if (<= lambda2 2.6e-5)
     (*
      R
      (*
       2.0
       (atan2
        (sqrt (+ (* t_0 (* (cos phi1) (* (cos phi2) t_0))) t_2))
        (sqrt
         (- 1.0 (+ t_1 (* (cos phi1) (pow (sin (* lambda1 0.5)) 2.0))))))))
     (*
      R
      (*
       2.0
       (atan2
        (sqrt
         (+ t_2 (* t_0 (* (cos phi1) (* (cos phi2) (sin (* lambda2 -0.5)))))))
        (sqrt
         (-
          1.0
          (+
           (* (cos phi1) (pow (sin (* (- lambda1 lambda2) 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 = pow(sin((phi1 * 0.5)), 2.0);
	double t_2 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
	double tmp;
	if (lambda2 <= 2.6e-5) {
		tmp = R * (2.0 * atan2(sqrt(((t_0 * (cos(phi1) * (cos(phi2) * t_0))) + t_2)), sqrt((1.0 - (t_1 + (cos(phi1) * pow(sin((lambda1 * 0.5)), 2.0)))))));
	} else {
		tmp = R * (2.0 * atan2(sqrt((t_2 + (t_0 * (cos(phi1) * (cos(phi2) * sin((lambda2 * -0.5))))))), sqrt((1.0 - ((cos(phi1) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)) + t_1)))));
	}
	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 = sin((phi1 * 0.5d0)) ** 2.0d0
    t_2 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
    if (lambda2 <= 2.6d-5) then
        tmp = r * (2.0d0 * atan2(sqrt(((t_0 * (cos(phi1) * (cos(phi2) * t_0))) + t_2)), sqrt((1.0d0 - (t_1 + (cos(phi1) * (sin((lambda1 * 0.5d0)) ** 2.0d0)))))))
    else
        tmp = r * (2.0d0 * atan2(sqrt((t_2 + (t_0 * (cos(phi1) * (cos(phi2) * sin((lambda2 * (-0.5d0)))))))), sqrt((1.0d0 - ((cos(phi1) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)) + t_1)))))
    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.pow(Math.sin((phi1 * 0.5)), 2.0);
	double t_2 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
	double tmp;
	if (lambda2 <= 2.6e-5) {
		tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_0 * (Math.cos(phi1) * (Math.cos(phi2) * t_0))) + t_2)), Math.sqrt((1.0 - (t_1 + (Math.cos(phi1) * Math.pow(Math.sin((lambda1 * 0.5)), 2.0)))))));
	} else {
		tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + (t_0 * (Math.cos(phi1) * (Math.cos(phi2) * Math.sin((lambda2 * -0.5))))))), Math.sqrt((1.0 - ((Math.cos(phi1) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)) + t_1)))));
	}
	return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2):
	t_0 = math.sin(((lambda1 - lambda2) / 2.0))
	t_1 = math.pow(math.sin((phi1 * 0.5)), 2.0)
	t_2 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)
	tmp = 0
	if lambda2 <= 2.6e-5:
		tmp = R * (2.0 * math.atan2(math.sqrt(((t_0 * (math.cos(phi1) * (math.cos(phi2) * t_0))) + t_2)), math.sqrt((1.0 - (t_1 + (math.cos(phi1) * math.pow(math.sin((lambda1 * 0.5)), 2.0)))))))
	else:
		tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + (t_0 * (math.cos(phi1) * (math.cos(phi2) * math.sin((lambda2 * -0.5))))))), math.sqrt((1.0 - ((math.cos(phi1) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)) + t_1)))))
	return tmp
function code(R, lambda1, lambda2, phi1, phi2)
	t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0))
	t_1 = sin(Float64(phi1 * 0.5)) ^ 2.0
	t_2 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0
	tmp = 0.0
	if (lambda2 <= 2.6e-5)
		tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(cos(phi1) * Float64(cos(phi2) * t_0))) + t_2)), sqrt(Float64(1.0 - Float64(t_1 + Float64(cos(phi1) * (sin(Float64(lambda1 * 0.5)) ^ 2.0))))))));
	else
		tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(t_0 * Float64(cos(phi1) * Float64(cos(phi2) * sin(Float64(lambda2 * -0.5))))))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)) + t_1))))));
	end
	return tmp
end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
	t_0 = sin(((lambda1 - lambda2) / 2.0));
	t_1 = sin((phi1 * 0.5)) ^ 2.0;
	t_2 = sin(((phi1 - phi2) / 2.0)) ^ 2.0;
	tmp = 0.0;
	if (lambda2 <= 2.6e-5)
		tmp = R * (2.0 * atan2(sqrt(((t_0 * (cos(phi1) * (cos(phi2) * t_0))) + t_2)), sqrt((1.0 - (t_1 + (cos(phi1) * (sin((lambda1 * 0.5)) ^ 2.0)))))));
	else
		tmp = R * (2.0 * atan2(sqrt((t_2 + (t_0 * (cos(phi1) * (cos(phi2) * sin((lambda2 * -0.5))))))), sqrt((1.0 - ((cos(phi1) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)) + t_1)))));
	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[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[lambda2, 2.6e-5], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$2), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $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 := {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\\
t_2 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
\mathbf{if}\;\lambda_2 \leq 2.6 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot t_0\right)\right) + t_2}}{\sqrt{1 - \left(t_1 + \cos \phi_1 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}\right)}}\right)\\

\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 + t_0 \cdot \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \sin \left(\lambda_2 \cdot -0.5\right)\right)\right)}}{\sqrt{1 - \left(\cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2} + t_1\right)}}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if lambda2 < 2.59999999999999984e-5

    1. Initial program 70.0%

      \[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. Simplified70.0%

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

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

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

    if 2.59999999999999984e-5 < lambda2

    1. Initial program 45.0%

      \[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. Simplified45.0%

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

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

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

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

Alternative 20: 44.7% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_1 := {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\\ t_2 := \sqrt{t_0 \cdot \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot t_0\right)\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}\\ \mathbf{if}\;\lambda_2 \leq 5.2 \cdot 10^{-6}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_2}{\sqrt{1 - \left(t_1 + \cos \phi_1 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_2}{\sqrt{1 - \left(t_1 + \cos \phi_1 \cdot {\sin \left(\lambda_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 (pow (sin (* phi1 0.5)) 2.0))
        (t_2
         (sqrt
          (+
           (* t_0 (* (cos phi1) (* (cos phi2) t_0)))
           (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))))
   (if (<= lambda2 5.2e-6)
     (*
      R
      (*
       2.0
       (atan2
        t_2
        (sqrt
         (- 1.0 (+ t_1 (* (cos phi1) (pow (sin (* lambda1 0.5)) 2.0))))))))
     (*
      R
      (*
       2.0
       (atan2
        t_2
        (sqrt
         (- 1.0 (+ t_1 (* (cos phi1) (pow (sin (* lambda2 -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 = pow(sin((phi1 * 0.5)), 2.0);
	double t_2 = sqrt(((t_0 * (cos(phi1) * (cos(phi2) * t_0))) + pow(sin(((phi1 - phi2) / 2.0)), 2.0)));
	double tmp;
	if (lambda2 <= 5.2e-6) {
		tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - (t_1 + (cos(phi1) * pow(sin((lambda1 * 0.5)), 2.0)))))));
	} else {
		tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - (t_1 + (cos(phi1) * pow(sin((lambda2 * -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 = sin((phi1 * 0.5d0)) ** 2.0d0
    t_2 = sqrt(((t_0 * (cos(phi1) * (cos(phi2) * t_0))) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)))
    if (lambda2 <= 5.2d-6) then
        tmp = r * (2.0d0 * atan2(t_2, sqrt((1.0d0 - (t_1 + (cos(phi1) * (sin((lambda1 * 0.5d0)) ** 2.0d0)))))))
    else
        tmp = r * (2.0d0 * atan2(t_2, sqrt((1.0d0 - (t_1 + (cos(phi1) * (sin((lambda2 * (-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.pow(Math.sin((phi1 * 0.5)), 2.0);
	double t_2 = Math.sqrt(((t_0 * (Math.cos(phi1) * (Math.cos(phi2) * t_0))) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)));
	double tmp;
	if (lambda2 <= 5.2e-6) {
		tmp = R * (2.0 * Math.atan2(t_2, Math.sqrt((1.0 - (t_1 + (Math.cos(phi1) * Math.pow(Math.sin((lambda1 * 0.5)), 2.0)))))));
	} else {
		tmp = R * (2.0 * Math.atan2(t_2, Math.sqrt((1.0 - (t_1 + (Math.cos(phi1) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0)))))));
	}
	return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2):
	t_0 = math.sin(((lambda1 - lambda2) / 2.0))
	t_1 = math.pow(math.sin((phi1 * 0.5)), 2.0)
	t_2 = math.sqrt(((t_0 * (math.cos(phi1) * (math.cos(phi2) * t_0))) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)))
	tmp = 0
	if lambda2 <= 5.2e-6:
		tmp = R * (2.0 * math.atan2(t_2, math.sqrt((1.0 - (t_1 + (math.cos(phi1) * math.pow(math.sin((lambda1 * 0.5)), 2.0)))))))
	else:
		tmp = R * (2.0 * math.atan2(t_2, math.sqrt((1.0 - (t_1 + (math.cos(phi1) * math.pow(math.sin((lambda2 * -0.5)), 2.0)))))))
	return tmp
function code(R, lambda1, lambda2, phi1, phi2)
	t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0))
	t_1 = sin(Float64(phi1 * 0.5)) ^ 2.0
	t_2 = sqrt(Float64(Float64(t_0 * Float64(cos(phi1) * Float64(cos(phi2) * t_0))) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)))
	tmp = 0.0
	if (lambda2 <= 5.2e-6)
		tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64(1.0 - Float64(t_1 + Float64(cos(phi1) * (sin(Float64(lambda1 * 0.5)) ^ 2.0))))))));
	else
		tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64(1.0 - Float64(t_1 + Float64(cos(phi1) * (sin(Float64(lambda2 * -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 = sin((phi1 * 0.5)) ^ 2.0;
	t_2 = sqrt(((t_0 * (cos(phi1) * (cos(phi2) * t_0))) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0)));
	tmp = 0.0;
	if (lambda2 <= 5.2e-6)
		tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - (t_1 + (cos(phi1) * (sin((lambda1 * 0.5)) ^ 2.0)))))));
	else
		tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - (t_1 + (cos(phi1) * (sin((lambda2 * -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[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, 5.2e-6], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(1.0 - N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(1.0 - N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $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 := {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\\
t_2 := \sqrt{t_0 \cdot \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot t_0\right)\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}\\
\mathbf{if}\;\lambda_2 \leq 5.2 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_2}{\sqrt{1 - \left(t_1 + \cos \phi_1 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}\right)}}\right)\\

\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_2}{\sqrt{1 - \left(t_1 + \cos \phi_1 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right)}}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if lambda2 < 5.20000000000000019e-6

    1. Initial program 70.0%

      \[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. Simplified70.0%

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

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

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

    if 5.20000000000000019e-6 < lambda2

    1. Initial program 45.0%

      \[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. Simplified45.0%

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

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

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

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

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

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

Alternative 21: 35.1% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot t_0\right)\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{{\left(\sqrt[3]{1 - {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}\right)}^{3}}}\right)
\end{array}
\end{array}
Derivation
  1. Initial program 64.2%

    \[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. Simplified64.2%

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

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

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

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

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

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

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

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

Alternative 22: 35.1% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot t_0\right)\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}\right)
\end{array}
\end{array}
Derivation
  1. Initial program 64.2%

    \[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. Simplified64.2%

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

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

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

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

Alternative 23: 32.4% accurate, 1.4× 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(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot t_0\right)\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}\\ \mathbf{if}\;\lambda_1 \leq -1.6 \cdot 10^{-10}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{{\cos \left(\lambda_1 \cdot 0.5\right)}^{2}}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{{\cos \left(\lambda_2 \cdot -0.5\right)}^{2}}}\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)))))
   (if (<= lambda1 -1.6e-10)
     (* R (* 2.0 (atan2 t_1 (sqrt (pow (cos (* lambda1 0.5)) 2.0)))))
     (* R (* 2.0 (atan2 t_1 (sqrt (pow (cos (* lambda2 -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 tmp;
	if (lambda1 <= -1.6e-10) {
		tmp = R * (2.0 * atan2(t_1, sqrt(pow(cos((lambda1 * 0.5)), 2.0))));
	} else {
		tmp = R * (2.0 * atan2(t_1, sqrt(pow(cos((lambda2 * -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) :: 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)))
    if (lambda1 <= (-1.6d-10)) then
        tmp = r * (2.0d0 * atan2(t_1, sqrt((cos((lambda1 * 0.5d0)) ** 2.0d0))))
    else
        tmp = r * (2.0d0 * atan2(t_1, sqrt((cos((lambda2 * (-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 tmp;
	if (lambda1 <= -1.6e-10) {
		tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt(Math.pow(Math.cos((lambda1 * 0.5)), 2.0))));
	} else {
		tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt(Math.pow(Math.cos((lambda2 * -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)))
	tmp = 0
	if lambda1 <= -1.6e-10:
		tmp = R * (2.0 * math.atan2(t_1, math.sqrt(math.pow(math.cos((lambda1 * 0.5)), 2.0))))
	else:
		tmp = R * (2.0 * math.atan2(t_1, math.sqrt(math.pow(math.cos((lambda2 * -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(cos(phi1) * Float64(cos(phi2) * t_0))) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)))
	tmp = 0.0
	if (lambda1 <= -1.6e-10)
		tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt((cos(Float64(lambda1 * 0.5)) ^ 2.0)))));
	else
		tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt((cos(Float64(lambda2 * -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)));
	tmp = 0.0;
	if (lambda1 <= -1.6e-10)
		tmp = R * (2.0 * atan2(t_1, sqrt((cos((lambda1 * 0.5)) ^ 2.0))));
	else
		tmp = R * (2.0 * atan2(t_1, sqrt((cos((lambda2 * -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[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -1.6e-10], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[Power[N[Cos[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[Power[N[Cos[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $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(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot t_0\right)\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}\\
\mathbf{if}\;\lambda_1 \leq -1.6 \cdot 10^{-10}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{{\cos \left(\lambda_1 \cdot 0.5\right)}^{2}}}\right)\\

\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{{\cos \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if lambda1 < -1.5999999999999999e-10

    1. Initial program 48.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. Simplified48.5%

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

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

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

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

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

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

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

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

    if -1.5999999999999999e-10 < lambda1

    1. Initial program 71.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. Simplified71.1%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\lambda_1 \leq -1.6 \cdot 10^{-10}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{{\cos \left(\lambda_1 \cdot 0.5\right)}^{2}}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{{\cos \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)\\ \end{array} \]

Alternative 24: 30.0% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot t_0\right)\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{{\cos \left(\lambda_1 \cdot 0.5\right)}^{2}}}\right)
\end{array}
\end{array}
Derivation
  1. Initial program 64.2%

    \[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. Simplified64.2%

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

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

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

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

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

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

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

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

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

Alternative 25: 13.8% accurate, 1.5× speedup?

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

\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right) \cdot \sqrt{\cos \phi_1}}{\sqrt{1 - \mathsf{fma}\left(0.5 - \frac{\cos \left(\lambda_1 - \lambda_2\right)}{2}, \cos \phi_1, {\sin \left(\phi_1 \cdot -0.5\right)}^{2}\right)}}\right)
\end{array}
Derivation
  1. Initial program 64.2%

    \[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. Simplified64.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_2 - \phi_1}{2}\right)}^{2}\right)}}\right)} \]
  3. Taylor expanded in phi2 around 0 47.3%

    \[\leadsto 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{\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) \]
  4. Step-by-step derivation
    1. *-commutative47.3%

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

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

    \[\leadsto 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{\color{blue}{1 - \mathsf{fma}\left({\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}, \cos \phi_1, {\sin \left(-0.5 \cdot \phi_1\right)}^{2}\right)}}}\right) \]
  6. Taylor expanded in phi1 around 0 25.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 26: 13.7% accurate, 2.2× speedup?

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

\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right) \cdot \sqrt{\cos \phi_1}}{\sqrt{1 - {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)
\end{array}
Derivation
  1. Initial program 64.2%

    \[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. Simplified64.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_2 - \phi_1}{2}\right)}^{2}\right)}}\right)} \]
  3. Taylor expanded in phi2 around 0 47.3%

    \[\leadsto 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{\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) \]
  4. Step-by-step derivation
    1. *-commutative47.3%

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

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

    \[\leadsto 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{\color{blue}{1 - \mathsf{fma}\left({\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}, \cos \phi_1, {\sin \left(-0.5 \cdot \phi_1\right)}^{2}\right)}}}\right) \]
  6. Taylor expanded in phi1 around 0 25.1%

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

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

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

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

Reproduce

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