Distance on a great circle

Percentage Accurate: 61.2% → 61.7%
Time: 1.9min
Alternatives: 31
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 31 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: 61.2% 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: 61.7% accurate, 0.9× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 2: 61.2% 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 \cos \phi_2\\ R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 \cdot \left(t_0 \cdot t_0\right) + {\left(\mathsf{expm1}\left(\mathsf{log1p}\left(\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)\right)\right)\right)}^{2}}}{\sqrt{\left(1 - {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right) + t_1 \cdot \frac{\cos \left(\lambda_2 - \lambda_1\right) + -1}{2}}}\right) \end{array} \end{array} \]
    (FPCore (R lambda1 lambda2 phi1 phi2)
     :precision binary64
     (let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
            (t_1 (* (cos phi1) (cos phi2))))
       (*
        R
        (*
         2.0
         (atan2
          (sqrt
           (+
            (* t_1 (* t_0 t_0))
            (pow (expm1 (log1p (sin (* (- phi1 phi2) 0.5)))) 2.0)))
          (sqrt
           (+
            (- 1.0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
            (* t_1 (/ (+ (cos (- lambda2 lambda1)) -1.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 = cos(phi1) * cos(phi2);
    	return R * (2.0 * atan2(sqrt(((t_1 * (t_0 * t_0)) + pow(expm1(log1p(sin(((phi1 - phi2) * 0.5)))), 2.0))), sqrt(((1.0 - pow(sin(((phi1 - phi2) / 2.0)), 2.0)) + (t_1 * ((cos((lambda2 - lambda1)) + -1.0) / 2.0))))));
    }
    
    public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
    	double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
    	double t_1 = Math.cos(phi1) * Math.cos(phi2);
    	return R * (2.0 * Math.atan2(Math.sqrt(((t_1 * (t_0 * t_0)) + Math.pow(Math.expm1(Math.log1p(Math.sin(((phi1 - phi2) * 0.5)))), 2.0))), Math.sqrt(((1.0 - Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)) + (t_1 * ((Math.cos((lambda2 - lambda1)) + -1.0) / 2.0))))));
    }
    
    def code(R, lambda1, lambda2, phi1, phi2):
    	t_0 = math.sin(((lambda1 - lambda2) / 2.0))
    	t_1 = math.cos(phi1) * math.cos(phi2)
    	return R * (2.0 * math.atan2(math.sqrt(((t_1 * (t_0 * t_0)) + math.pow(math.expm1(math.log1p(math.sin(((phi1 - phi2) * 0.5)))), 2.0))), math.sqrt(((1.0 - math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)) + (t_1 * ((math.cos((lambda2 - lambda1)) + -1.0) / 2.0))))))
    
    function code(R, lambda1, lambda2, phi1, phi2)
    	t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0))
    	t_1 = Float64(cos(phi1) * cos(phi2))
    	return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(t_0 * t_0)) + (expm1(log1p(sin(Float64(Float64(phi1 - phi2) * 0.5)))) ^ 2.0))), sqrt(Float64(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)) + Float64(t_1 * Float64(Float64(cos(Float64(lambda2 - lambda1)) + -1.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[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[(Exp[N[Log[1 + N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[(t$95$1 * N[(N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] + -1.0), $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 := \cos \phi_1 \cdot \cos \phi_2\\
    R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 \cdot \left(t_0 \cdot t_0\right) + {\left(\mathsf{expm1}\left(\mathsf{log1p}\left(\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)\right)\right)\right)}^{2}}}{\sqrt{\left(1 - {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right) + t_1 \cdot \frac{\cos \left(\lambda_2 - \lambda_1\right) + -1}{2}}}\right)
    \end{array}
    \end{array}
    
    Derivation
    1. Initial program 64.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      Alternative 3: 59.6% accurate, 1.1× speedup?

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

        1. Initial program 50.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. Step-by-step derivation
          1. associate-*l*49.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          if -2.54999999999999998e-5 < phi2 < 3.00000000000000012e-26

          1. Initial program 82.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. Step-by-step derivation
            1. associate-*l*82.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          Alternative 4: 55.3% 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(\lambda_2 \cdot -0.5\right)\\ t_2 := \cos \phi_1 \cdot \cos \phi_2\\ t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_4 := t_2 \cdot \left(t_3 \cdot t_3\right)\\ \mathbf{if}\;\phi_1 \leq -0.00088:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_1 \cdot \left(t_2 \cdot t_3\right)}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - t_1 \cdot \left(\cos \phi_1 \cdot \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\right)}}\right)\\ \mathbf{elif}\;\phi_1 \leq 0.000205:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_4 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{\left(1 - t_0\right) + t_2 \cdot \frac{\cos \left(\lambda_2 - \lambda_1\right) + -1}{2}}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_4}}{\sqrt{\left(1 - {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right) + t_2 \cdot \frac{\cos \lambda_1 + -1}{2}}}\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 (* lambda2 -0.5)))
                  (t_2 (* (cos phi1) (cos phi2)))
                  (t_3 (sin (/ (- lambda1 lambda2) 2.0)))
                  (t_4 (* t_2 (* t_3 t_3))))
             (if (<= phi1 -0.00088)
               (*
                R
                (*
                 2.0
                 (atan2
                  (sqrt (+ t_0 (* t_1 (* t_2 t_3))))
                  (sqrt
                   (-
                    (pow (cos (* phi1 0.5)) 2.0)
                    (* t_1 (* (cos phi1) (sin (* (- lambda1 lambda2) 0.5)))))))))
               (if (<= phi1 0.000205)
                 (*
                  R
                  (*
                   2.0
                   (atan2
                    (sqrt (+ t_4 (pow (sin (* phi2 -0.5)) 2.0)))
                    (sqrt
                     (+
                      (- 1.0 t_0)
                      (* t_2 (/ (+ (cos (- lambda2 lambda1)) -1.0) 2.0)))))))
                 (*
                  R
                  (*
                   2.0
                   (atan2
                    (sqrt (+ t_0 t_4))
                    (sqrt
                     (+
                      (- 1.0 (pow (sin (* phi1 0.5)) 2.0))
                      (* t_2 (/ (+ (cos lambda1) -1.0) 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 = sin((lambda2 * -0.5));
          	double t_2 = cos(phi1) * cos(phi2);
          	double t_3 = sin(((lambda1 - lambda2) / 2.0));
          	double t_4 = t_2 * (t_3 * t_3);
          	double tmp;
          	if (phi1 <= -0.00088) {
          		tmp = R * (2.0 * atan2(sqrt((t_0 + (t_1 * (t_2 * t_3)))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (t_1 * (cos(phi1) * sin(((lambda1 - lambda2) * 0.5))))))));
          	} else if (phi1 <= 0.000205) {
          		tmp = R * (2.0 * atan2(sqrt((t_4 + pow(sin((phi2 * -0.5)), 2.0))), sqrt(((1.0 - t_0) + (t_2 * ((cos((lambda2 - lambda1)) + -1.0) / 2.0))))));
          	} else {
          		tmp = R * (2.0 * atan2(sqrt((t_0 + t_4)), sqrt(((1.0 - pow(sin((phi1 * 0.5)), 2.0)) + (t_2 * ((cos(lambda1) + -1.0) / 2.0))))));
          	}
          	return tmp;
          }
          
          real(8) function code(r, lambda1, lambda2, phi1, phi2)
              real(8), intent (in) :: r
              real(8), intent (in) :: lambda1
              real(8), intent (in) :: lambda2
              real(8), intent (in) :: phi1
              real(8), intent (in) :: phi2
              real(8) :: t_0
              real(8) :: t_1
              real(8) :: t_2
              real(8) :: t_3
              real(8) :: t_4
              real(8) :: tmp
              t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
              t_1 = sin((lambda2 * (-0.5d0)))
              t_2 = cos(phi1) * cos(phi2)
              t_3 = sin(((lambda1 - lambda2) / 2.0d0))
              t_4 = t_2 * (t_3 * t_3)
              if (phi1 <= (-0.00088d0)) then
                  tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_1 * (t_2 * t_3)))), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (t_1 * (cos(phi1) * sin(((lambda1 - lambda2) * 0.5d0))))))))
              else if (phi1 <= 0.000205d0) then
                  tmp = r * (2.0d0 * atan2(sqrt((t_4 + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt(((1.0d0 - t_0) + (t_2 * ((cos((lambda2 - lambda1)) + (-1.0d0)) / 2.0d0))))))
              else
                  tmp = r * (2.0d0 * atan2(sqrt((t_0 + t_4)), sqrt(((1.0d0 - (sin((phi1 * 0.5d0)) ** 2.0d0)) + (t_2 * ((cos(lambda1) + (-1.0d0)) / 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.sin((lambda2 * -0.5));
          	double t_2 = Math.cos(phi1) * Math.cos(phi2);
          	double t_3 = Math.sin(((lambda1 - lambda2) / 2.0));
          	double t_4 = t_2 * (t_3 * t_3);
          	double tmp;
          	if (phi1 <= -0.00088) {
          		tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_1 * (t_2 * t_3)))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (t_1 * (Math.cos(phi1) * Math.sin(((lambda1 - lambda2) * 0.5))))))));
          	} else if (phi1 <= 0.000205) {
          		tmp = R * (2.0 * Math.atan2(Math.sqrt((t_4 + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt(((1.0 - t_0) + (t_2 * ((Math.cos((lambda2 - lambda1)) + -1.0) / 2.0))))));
          	} else {
          		tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + t_4)), Math.sqrt(((1.0 - Math.pow(Math.sin((phi1 * 0.5)), 2.0)) + (t_2 * ((Math.cos(lambda1) + -1.0) / 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.sin((lambda2 * -0.5))
          	t_2 = math.cos(phi1) * math.cos(phi2)
          	t_3 = math.sin(((lambda1 - lambda2) / 2.0))
          	t_4 = t_2 * (t_3 * t_3)
          	tmp = 0
          	if phi1 <= -0.00088:
          		tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_1 * (t_2 * t_3)))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (t_1 * (math.cos(phi1) * math.sin(((lambda1 - lambda2) * 0.5))))))))
          	elif phi1 <= 0.000205:
          		tmp = R * (2.0 * math.atan2(math.sqrt((t_4 + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt(((1.0 - t_0) + (t_2 * ((math.cos((lambda2 - lambda1)) + -1.0) / 2.0))))))
          	else:
          		tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + t_4)), math.sqrt(((1.0 - math.pow(math.sin((phi1 * 0.5)), 2.0)) + (t_2 * ((math.cos(lambda1) + -1.0) / 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(lambda2 * -0.5))
          	t_2 = Float64(cos(phi1) * cos(phi2))
          	t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0))
          	t_4 = Float64(t_2 * Float64(t_3 * t_3))
          	tmp = 0.0
          	if (phi1 <= -0.00088)
          		tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_1 * Float64(t_2 * t_3)))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(t_1 * Float64(cos(phi1) * sin(Float64(Float64(lambda1 - lambda2) * 0.5)))))))));
          	elseif (phi1 <= 0.000205)
          		tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_4 + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64(Float64(1.0 - t_0) + Float64(t_2 * Float64(Float64(cos(Float64(lambda2 - lambda1)) + -1.0) / 2.0)))))));
          	else
          		tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + t_4)), sqrt(Float64(Float64(1.0 - (sin(Float64(phi1 * 0.5)) ^ 2.0)) + Float64(t_2 * Float64(Float64(cos(lambda1) + -1.0) / 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((lambda2 * -0.5));
          	t_2 = cos(phi1) * cos(phi2);
          	t_3 = sin(((lambda1 - lambda2) / 2.0));
          	t_4 = t_2 * (t_3 * t_3);
          	tmp = 0.0;
          	if (phi1 <= -0.00088)
          		tmp = R * (2.0 * atan2(sqrt((t_0 + (t_1 * (t_2 * t_3)))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (t_1 * (cos(phi1) * sin(((lambda1 - lambda2) * 0.5))))))));
          	elseif (phi1 <= 0.000205)
          		tmp = R * (2.0 * atan2(sqrt((t_4 + (sin((phi2 * -0.5)) ^ 2.0))), sqrt(((1.0 - t_0) + (t_2 * ((cos((lambda2 - lambda1)) + -1.0) / 2.0))))));
          	else
          		tmp = R * (2.0 * atan2(sqrt((t_0 + t_4)), sqrt(((1.0 - (sin((phi1 * 0.5)) ^ 2.0)) + (t_2 * ((cos(lambda1) + -1.0) / 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[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$2 * N[(t$95$3 * t$95$3), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -0.00088], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$1 * N[(t$95$2 * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(t$95$1 * N[(N[Cos[phi1], $MachinePrecision] * N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 0.000205], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$4 + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$0), $MachinePrecision] + N[(t$95$2 * N[(N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + t$95$4), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[(t$95$2 * N[(N[(N[Cos[lambda1], $MachinePrecision] + -1.0), $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(\lambda_2 \cdot -0.5\right)\\
          t_2 := \cos \phi_1 \cdot \cos \phi_2\\
          t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
          t_4 := t_2 \cdot \left(t_3 \cdot t_3\right)\\
          \mathbf{if}\;\phi_1 \leq -0.00088:\\
          \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_1 \cdot \left(t_2 \cdot t_3\right)}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - t_1 \cdot \left(\cos \phi_1 \cdot \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\right)}}\right)\\
          
          \mathbf{elif}\;\phi_1 \leq 0.000205:\\
          \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_4 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{\left(1 - t_0\right) + t_2 \cdot \frac{\cos \left(\lambda_2 - \lambda_1\right) + -1}{2}}}\right)\\
          
          \mathbf{else}:\\
          \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_4}}{\sqrt{\left(1 - {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right) + t_2 \cdot \frac{\cos \lambda_1 + -1}{2}}}\right)\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if phi1 < -8.80000000000000031e-4

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

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

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

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

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

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

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

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

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

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

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

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

            if -8.80000000000000031e-4 < phi1 < 2.05e-4

            1. Initial program 85.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              if 2.05e-4 < phi1

              1. Initial program 42.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              Alternative 5: 50.7% accurate, 1.1× speedup?

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

                1. Initial program 58.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  if -1.44999999999999996e-89 < lambda1

                  1. Initial program 67.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. associate-*l*67.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  Alternative 6: 54.2% accurate, 1.1× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\ t_1 := 1 - t_0\\ t_2 := \cos \phi_1 \cdot \cos \phi_2\\ t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ \mathbf{if}\;\lambda_2 \leq 320:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot \left(t_3 \cdot t_3\right)}}{\sqrt{t_1 + t_2 \cdot \frac{\cos \lambda_1 + -1}{2}}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot \left(t_3 \cdot \sin \left(\lambda_2 \cdot -0.5\right)\right)}}{\sqrt{t_1 + t_2 \cdot \frac{\cos \left(\lambda_2 - \lambda_1\right) + -1}{2}}}\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 (- 1.0 t_0))
                          (t_2 (* (cos phi1) (cos phi2)))
                          (t_3 (sin (/ (- lambda1 lambda2) 2.0))))
                     (if (<= lambda2 320.0)
                       (*
                        R
                        (*
                         2.0
                         (atan2
                          (sqrt (+ t_0 (* t_2 (* t_3 t_3))))
                          (sqrt (+ t_1 (* t_2 (/ (+ (cos lambda1) -1.0) 2.0)))))))
                       (*
                        R
                        (*
                         2.0
                         (atan2
                          (sqrt (+ t_0 (* t_2 (* t_3 (sin (* lambda2 -0.5))))))
                          (sqrt (+ t_1 (* t_2 (/ (+ (cos (- lambda2 lambda1)) -1.0) 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 = 1.0 - t_0;
                  	double t_2 = cos(phi1) * cos(phi2);
                  	double t_3 = sin(((lambda1 - lambda2) / 2.0));
                  	double tmp;
                  	if (lambda2 <= 320.0) {
                  		tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_3 * t_3)))), sqrt((t_1 + (t_2 * ((cos(lambda1) + -1.0) / 2.0))))));
                  	} else {
                  		tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_3 * sin((lambda2 * -0.5)))))), sqrt((t_1 + (t_2 * ((cos((lambda2 - lambda1)) + -1.0) / 2.0))))));
                  	}
                  	return tmp;
                  }
                  
                  real(8) function code(r, lambda1, lambda2, phi1, phi2)
                      real(8), intent (in) :: r
                      real(8), intent (in) :: lambda1
                      real(8), intent (in) :: lambda2
                      real(8), intent (in) :: phi1
                      real(8), intent (in) :: phi2
                      real(8) :: t_0
                      real(8) :: t_1
                      real(8) :: t_2
                      real(8) :: t_3
                      real(8) :: tmp
                      t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
                      t_1 = 1.0d0 - t_0
                      t_2 = cos(phi1) * cos(phi2)
                      t_3 = sin(((lambda1 - lambda2) / 2.0d0))
                      if (lambda2 <= 320.0d0) then
                          tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_2 * (t_3 * t_3)))), sqrt((t_1 + (t_2 * ((cos(lambda1) + (-1.0d0)) / 2.0d0))))))
                      else
                          tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_2 * (t_3 * sin((lambda2 * (-0.5d0))))))), sqrt((t_1 + (t_2 * ((cos((lambda2 - lambda1)) + (-1.0d0)) / 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 = 1.0 - t_0;
                  	double t_2 = Math.cos(phi1) * Math.cos(phi2);
                  	double t_3 = Math.sin(((lambda1 - lambda2) / 2.0));
                  	double tmp;
                  	if (lambda2 <= 320.0) {
                  		tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * (t_3 * t_3)))), Math.sqrt((t_1 + (t_2 * ((Math.cos(lambda1) + -1.0) / 2.0))))));
                  	} else {
                  		tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * (t_3 * Math.sin((lambda2 * -0.5)))))), Math.sqrt((t_1 + (t_2 * ((Math.cos((lambda2 - lambda1)) + -1.0) / 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 = 1.0 - t_0
                  	t_2 = math.cos(phi1) * math.cos(phi2)
                  	t_3 = math.sin(((lambda1 - lambda2) / 2.0))
                  	tmp = 0
                  	if lambda2 <= 320.0:
                  		tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_2 * (t_3 * t_3)))), math.sqrt((t_1 + (t_2 * ((math.cos(lambda1) + -1.0) / 2.0))))))
                  	else:
                  		tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_2 * (t_3 * math.sin((lambda2 * -0.5)))))), math.sqrt((t_1 + (t_2 * ((math.cos((lambda2 - lambda1)) + -1.0) / 2.0))))))
                  	return tmp
                  
                  function code(R, lambda1, lambda2, phi1, phi2)
                  	t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0
                  	t_1 = Float64(1.0 - t_0)
                  	t_2 = Float64(cos(phi1) * cos(phi2))
                  	t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0))
                  	tmp = 0.0
                  	if (lambda2 <= 320.0)
                  		tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * Float64(t_3 * t_3)))), sqrt(Float64(t_1 + Float64(t_2 * Float64(Float64(cos(lambda1) + -1.0) / 2.0)))))));
                  	else
                  		tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * Float64(t_3 * sin(Float64(lambda2 * -0.5)))))), sqrt(Float64(t_1 + Float64(t_2 * Float64(Float64(cos(Float64(lambda2 - lambda1)) + -1.0) / 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 = 1.0 - t_0;
                  	t_2 = cos(phi1) * cos(phi2);
                  	t_3 = sin(((lambda1 - lambda2) / 2.0));
                  	tmp = 0.0;
                  	if (lambda2 <= 320.0)
                  		tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_3 * t_3)))), sqrt((t_1 + (t_2 * ((cos(lambda1) + -1.0) / 2.0))))));
                  	else
                  		tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_3 * sin((lambda2 * -0.5)))))), sqrt((t_1 + (t_2 * ((cos((lambda2 - lambda1)) + -1.0) / 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[(1.0 - t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, 320.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[(t$95$3 * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$1 + N[(t$95$2 * N[(N[(N[Cos[lambda1], $MachinePrecision] + -1.0), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[(t$95$3 * N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$1 + N[(t$95$2 * N[(N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] + -1.0), $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 := 1 - t_0\\
                  t_2 := \cos \phi_1 \cdot \cos \phi_2\\
                  t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
                  \mathbf{if}\;\lambda_2 \leq 320:\\
                  \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot \left(t_3 \cdot t_3\right)}}{\sqrt{t_1 + t_2 \cdot \frac{\cos \lambda_1 + -1}{2}}}\right)\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot \left(t_3 \cdot \sin \left(\lambda_2 \cdot -0.5\right)\right)}}{\sqrt{t_1 + t_2 \cdot \frac{\cos \left(\lambda_2 - \lambda_1\right) + -1}{2}}}\right)\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if lambda2 < 320

                    1. Initial program 68.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      if 320 < lambda2

                      1. Initial program 51.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      Alternative 7: 61.3% accurate, 1.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                        Alternative 8: 38.3% accurate, 1.1× speedup?

                        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_1 := \cos \phi_1 \cdot \cos \phi_2\\ t_2 := \sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)\\ t_3 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\ t_4 := t_1 \cdot t_0\\ t_5 := \sin \left(\lambda_2 \cdot -0.5\right)\\ \mathbf{if}\;\lambda_1 \leq -32000000000:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_2, {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot -0.5\right)}^{2}, \phi_2 \cdot \left(\phi_2 \cdot 0.25\right)\right)}}{\sqrt{\left(1 - t_3\right) + t_1 \cdot \frac{\cos \left(\lambda_2 - \lambda_1\right) + -1}{2}}}\right)\\ \mathbf{elif}\;\lambda_1 \leq -1.6 \cdot 10^{-152}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_3 + t_0 \cdot t_4}}{\sqrt{1 - {\left(\sqrt[3]{t_2 \cdot {t_2}^{2}}\right)}^{2}}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_3 + t_5 \cdot t_4}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - t_5 \cdot \left(\cos \phi_2 \cdot \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\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 (* (cos phi1) (cos phi2)))
                                (t_2 (sin (* (- phi1 phi2) 0.5)))
                                (t_3 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
                                (t_4 (* t_1 t_0))
                                (t_5 (sin (* lambda2 -0.5))))
                           (if (<= lambda1 -32000000000.0)
                             (*
                              R
                              (*
                               2.0
                               (atan2
                                (sqrt
                                 (fma
                                  (cos phi2)
                                  (pow (sin (* (- lambda2 lambda1) -0.5)) 2.0)
                                  (* phi2 (* phi2 0.25))))
                                (sqrt
                                 (+ (- 1.0 t_3) (* t_1 (/ (+ (cos (- lambda2 lambda1)) -1.0) 2.0)))))))
                             (if (<= lambda1 -1.6e-152)
                               (*
                                R
                                (*
                                 2.0
                                 (atan2
                                  (sqrt (+ t_3 (* t_0 t_4)))
                                  (sqrt (- 1.0 (pow (cbrt (* t_2 (pow t_2 2.0))) 2.0))))))
                               (*
                                R
                                (*
                                 2.0
                                 (atan2
                                  (sqrt (+ t_3 (* t_5 t_4)))
                                  (sqrt
                                   (-
                                    (pow (cos (* phi2 -0.5)) 2.0)
                                    (* t_5 (* (cos phi2) (sin (* (- lambda1 lambda2) 0.5)))))))))))))
                        double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
                        	double t_0 = sin(((lambda1 - lambda2) / 2.0));
                        	double t_1 = cos(phi1) * cos(phi2);
                        	double t_2 = sin(((phi1 - phi2) * 0.5));
                        	double t_3 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
                        	double t_4 = t_1 * t_0;
                        	double t_5 = sin((lambda2 * -0.5));
                        	double tmp;
                        	if (lambda1 <= -32000000000.0) {
                        		tmp = R * (2.0 * atan2(sqrt(fma(cos(phi2), pow(sin(((lambda2 - lambda1) * -0.5)), 2.0), (phi2 * (phi2 * 0.25)))), sqrt(((1.0 - t_3) + (t_1 * ((cos((lambda2 - lambda1)) + -1.0) / 2.0))))));
                        	} else if (lambda1 <= -1.6e-152) {
                        		tmp = R * (2.0 * atan2(sqrt((t_3 + (t_0 * t_4))), sqrt((1.0 - pow(cbrt((t_2 * pow(t_2, 2.0))), 2.0)))));
                        	} else {
                        		tmp = R * (2.0 * atan2(sqrt((t_3 + (t_5 * t_4))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (t_5 * (cos(phi2) * sin(((lambda1 - lambda2) * 0.5))))))));
                        	}
                        	return tmp;
                        }
                        
                        function code(R, lambda1, lambda2, phi1, phi2)
                        	t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0))
                        	t_1 = Float64(cos(phi1) * cos(phi2))
                        	t_2 = sin(Float64(Float64(phi1 - phi2) * 0.5))
                        	t_3 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0
                        	t_4 = Float64(t_1 * t_0)
                        	t_5 = sin(Float64(lambda2 * -0.5))
                        	tmp = 0.0
                        	if (lambda1 <= -32000000000.0)
                        		tmp = Float64(R * Float64(2.0 * atan(sqrt(fma(cos(phi2), (sin(Float64(Float64(lambda2 - lambda1) * -0.5)) ^ 2.0), Float64(phi2 * Float64(phi2 * 0.25)))), sqrt(Float64(Float64(1.0 - t_3) + Float64(t_1 * Float64(Float64(cos(Float64(lambda2 - lambda1)) + -1.0) / 2.0)))))));
                        	elseif (lambda1 <= -1.6e-152)
                        		tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + Float64(t_0 * t_4))), sqrt(Float64(1.0 - (cbrt(Float64(t_2 * (t_2 ^ 2.0))) ^ 2.0))))));
                        	else
                        		tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + Float64(t_5 * t_4))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(t_5 * Float64(cos(phi2) * sin(Float64(Float64(lambda1 - lambda2) * 0.5)))))))));
                        	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[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$1 * t$95$0), $MachinePrecision]}, Block[{t$95$5 = N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -32000000000.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda2 - lambda1), $MachinePrecision] * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(phi2 * N[(phi2 * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$3), $MachinePrecision] + N[(t$95$1 * N[(N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda1, -1.6e-152], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + N[(t$95$0 * t$95$4), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Power[N[(t$95$2 * N[Power[t$95$2, 2.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + N[(t$95$5 * t$95$4), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(t$95$5 * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $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 := \cos \phi_1 \cdot \cos \phi_2\\
                        t_2 := \sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)\\
                        t_3 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
                        t_4 := t_1 \cdot t_0\\
                        t_5 := \sin \left(\lambda_2 \cdot -0.5\right)\\
                        \mathbf{if}\;\lambda_1 \leq -32000000000:\\
                        \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_2, {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot -0.5\right)}^{2}, \phi_2 \cdot \left(\phi_2 \cdot 0.25\right)\right)}}{\sqrt{\left(1 - t_3\right) + t_1 \cdot \frac{\cos \left(\lambda_2 - \lambda_1\right) + -1}{2}}}\right)\\
                        
                        \mathbf{elif}\;\lambda_1 \leq -1.6 \cdot 10^{-152}:\\
                        \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_3 + t_0 \cdot t_4}}{\sqrt{1 - {\left(\sqrt[3]{t_2 \cdot {t_2}^{2}}\right)}^{2}}}\right)\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_3 + t_5 \cdot t_4}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - t_5 \cdot \left(\cos \phi_2 \cdot \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\right)}}\right)\\
                        
                        
                        \end{array}
                        \end{array}
                        
                        Derivation
                        1. Split input into 3 regimes
                        2. if lambda1 < -3.2e10

                          1. Initial program 55.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                            if -3.2e10 < lambda1 < -1.60000000000000006e-152

                            1. Initial program 79.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. Taylor expanded in lambda1 around 0 76.5%

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

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

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

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

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

                            if -1.60000000000000006e-152 < lambda1

                            1. Initial program 65.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. Taylor expanded in lambda1 around 0 53.0%

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

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

                              \[\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(-0.5 \cdot \lambda_2\right)}}{\sqrt{\color{blue}{1 - \left(\sin \left(-0.5 \cdot \lambda_2\right) \cdot \left(\cos \phi_2 \cdot \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right) + {\sin \left(-0.5 \cdot \phi_2\right)}^{2}\right)}}}\right) \]
                            5. Step-by-step derivation
                              1. +-commutative42.8%

                                \[\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(-0.5 \cdot \lambda_2\right)}}{\sqrt{1 - \color{blue}{\left({\sin \left(-0.5 \cdot \phi_2\right)}^{2} + \sin \left(-0.5 \cdot \lambda_2\right) \cdot \left(\cos \phi_2 \cdot \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\right)}}}\right) \]
                              2. associate--r+42.8%

                                \[\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(-0.5 \cdot \lambda_2\right)}}{\sqrt{\color{blue}{\left(1 - {\sin \left(-0.5 \cdot \phi_2\right)}^{2}\right) - \sin \left(-0.5 \cdot \lambda_2\right) \cdot \left(\cos \phi_2 \cdot \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)}}}\right) \]
                              3. unpow242.8%

                                \[\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(-0.5 \cdot \lambda_2\right)}}{\sqrt{\left(1 - \color{blue}{\sin \left(-0.5 \cdot \phi_2\right) \cdot \sin \left(-0.5 \cdot \phi_2\right)}\right) - \sin \left(-0.5 \cdot \lambda_2\right) \cdot \left(\cos \phi_2 \cdot \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)}}\right) \]
                              4. 1-sub-sin42.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(-0.5 \cdot \lambda_2\right)}}{\sqrt{\color{blue}{\cos \left(-0.5 \cdot \phi_2\right) \cdot \cos \left(-0.5 \cdot \phi_2\right)} - \sin \left(-0.5 \cdot \lambda_2\right) \cdot \left(\cos \phi_2 \cdot \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)}}\right) \]
                              5. unpow242.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(-0.5 \cdot \lambda_2\right)}}{\sqrt{\color{blue}{{\cos \left(-0.5 \cdot \phi_2\right)}^{2}} - \sin \left(-0.5 \cdot \lambda_2\right) \cdot \left(\cos \phi_2 \cdot \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)}}\right) \]
                              6. *-commutative42.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(-0.5 \cdot \lambda_2\right)}}{\sqrt{{\cos \left(-0.5 \cdot \phi_2\right)}^{2} - \sin \color{blue}{\left(\lambda_2 \cdot -0.5\right)} \cdot \left(\cos \phi_2 \cdot \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)}}\right) \]
                              7. *-commutative42.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(-0.5 \cdot \lambda_2\right)}}{\sqrt{{\cos \left(-0.5 \cdot \phi_2\right)}^{2} - \sin \left(\lambda_2 \cdot -0.5\right) \cdot \left(\cos \phi_2 \cdot \sin \color{blue}{\left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}\right)}}\right) \]
                            6. Simplified42.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(-0.5 \cdot \lambda_2\right)}}{\sqrt{\color{blue}{{\cos \left(-0.5 \cdot \phi_2\right)}^{2} - \sin \left(\lambda_2 \cdot -0.5\right) \cdot \left(\cos \phi_2 \cdot \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\right)}}}\right) \]
                          7. Recombined 3 regimes into one program.
                          8. Final simplification42.2%

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

                          Alternative 9: 40.7% 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(\lambda_2 \cdot -0.5\right)\\ t_2 := \cos \phi_1 \cdot \cos \phi_2\\ t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_4 := t_2 \cdot t_3\\ t_5 := \sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)\\ \mathbf{if}\;\lambda_1 \leq -3 \cdot 10^{-6}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot \left(t_3 \cdot t_3\right)}}{\sqrt{\left(1 - {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right) + t_2 \cdot \frac{\cos \lambda_1 + -1}{2}}}\right)\\ \mathbf{elif}\;\lambda_1 \leq -3 \cdot 10^{-153}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_3 \cdot t_4}}{\sqrt{1 - {\left(\sqrt[3]{t_5 \cdot {t_5}^{2}}\right)}^{2}}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_1 \cdot t_4}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - t_1 \cdot \left(\cos \phi_2 \cdot \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\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 (sin (* lambda2 -0.5)))
                                  (t_2 (* (cos phi1) (cos phi2)))
                                  (t_3 (sin (/ (- lambda1 lambda2) 2.0)))
                                  (t_4 (* t_2 t_3))
                                  (t_5 (sin (* (- phi1 phi2) 0.5))))
                             (if (<= lambda1 -3e-6)
                               (*
                                R
                                (*
                                 2.0
                                 (atan2
                                  (sqrt (+ t_0 (* t_2 (* t_3 t_3))))
                                  (sqrt
                                   (+
                                    (- 1.0 (pow (sin (* phi1 0.5)) 2.0))
                                    (* t_2 (/ (+ (cos lambda1) -1.0) 2.0)))))))
                               (if (<= lambda1 -3e-153)
                                 (*
                                  R
                                  (*
                                   2.0
                                   (atan2
                                    (sqrt (+ t_0 (* t_3 t_4)))
                                    (sqrt (- 1.0 (pow (cbrt (* t_5 (pow t_5 2.0))) 2.0))))))
                                 (*
                                  R
                                  (*
                                   2.0
                                   (atan2
                                    (sqrt (+ t_0 (* t_1 t_4)))
                                    (sqrt
                                     (-
                                      (pow (cos (* phi2 -0.5)) 2.0)
                                      (* t_1 (* (cos phi2) (sin (* (- lambda1 lambda2) 0.5)))))))))))))
                          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((lambda2 * -0.5));
                          	double t_2 = cos(phi1) * cos(phi2);
                          	double t_3 = sin(((lambda1 - lambda2) / 2.0));
                          	double t_4 = t_2 * t_3;
                          	double t_5 = sin(((phi1 - phi2) * 0.5));
                          	double tmp;
                          	if (lambda1 <= -3e-6) {
                          		tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_3 * t_3)))), sqrt(((1.0 - pow(sin((phi1 * 0.5)), 2.0)) + (t_2 * ((cos(lambda1) + -1.0) / 2.0))))));
                          	} else if (lambda1 <= -3e-153) {
                          		tmp = R * (2.0 * atan2(sqrt((t_0 + (t_3 * t_4))), sqrt((1.0 - pow(cbrt((t_5 * pow(t_5, 2.0))), 2.0)))));
                          	} else {
                          		tmp = R * (2.0 * atan2(sqrt((t_0 + (t_1 * t_4))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (t_1 * (cos(phi2) * sin(((lambda1 - lambda2) * 0.5))))))));
                          	}
                          	return tmp;
                          }
                          
                          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((lambda2 * -0.5));
                          	double t_2 = Math.cos(phi1) * Math.cos(phi2);
                          	double t_3 = Math.sin(((lambda1 - lambda2) / 2.0));
                          	double t_4 = t_2 * t_3;
                          	double t_5 = Math.sin(((phi1 - phi2) * 0.5));
                          	double tmp;
                          	if (lambda1 <= -3e-6) {
                          		tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * (t_3 * t_3)))), Math.sqrt(((1.0 - Math.pow(Math.sin((phi1 * 0.5)), 2.0)) + (t_2 * ((Math.cos(lambda1) + -1.0) / 2.0))))));
                          	} else if (lambda1 <= -3e-153) {
                          		tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_3 * t_4))), Math.sqrt((1.0 - Math.pow(Math.cbrt((t_5 * Math.pow(t_5, 2.0))), 2.0)))));
                          	} else {
                          		tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_1 * t_4))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (t_1 * (Math.cos(phi2) * Math.sin(((lambda1 - lambda2) * 0.5))))))));
                          	}
                          	return tmp;
                          }
                          
                          function code(R, lambda1, lambda2, phi1, phi2)
                          	t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0
                          	t_1 = sin(Float64(lambda2 * -0.5))
                          	t_2 = Float64(cos(phi1) * cos(phi2))
                          	t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0))
                          	t_4 = Float64(t_2 * t_3)
                          	t_5 = sin(Float64(Float64(phi1 - phi2) * 0.5))
                          	tmp = 0.0
                          	if (lambda1 <= -3e-6)
                          		tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * Float64(t_3 * t_3)))), sqrt(Float64(Float64(1.0 - (sin(Float64(phi1 * 0.5)) ^ 2.0)) + Float64(t_2 * Float64(Float64(cos(lambda1) + -1.0) / 2.0)))))));
                          	elseif (lambda1 <= -3e-153)
                          		tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_3 * t_4))), sqrt(Float64(1.0 - (cbrt(Float64(t_5 * (t_5 ^ 2.0))) ^ 2.0))))));
                          	else
                          		tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_1 * t_4))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(t_1 * Float64(cos(phi2) * sin(Float64(Float64(lambda1 - lambda2) * 0.5)))))))));
                          	end
                          	return 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[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$2 * t$95$3), $MachinePrecision]}, Block[{t$95$5 = N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -3e-6], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[(t$95$3 * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[(t$95$2 * N[(N[(N[Cos[lambda1], $MachinePrecision] + -1.0), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda1, -3e-153], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$3 * t$95$4), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Power[N[(t$95$5 * N[Power[t$95$5, 2.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$1 * t$95$4), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(t$95$1 * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $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(\lambda_2 \cdot -0.5\right)\\
                          t_2 := \cos \phi_1 \cdot \cos \phi_2\\
                          t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
                          t_4 := t_2 \cdot t_3\\
                          t_5 := \sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)\\
                          \mathbf{if}\;\lambda_1 \leq -3 \cdot 10^{-6}:\\
                          \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot \left(t_3 \cdot t_3\right)}}{\sqrt{\left(1 - {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right) + t_2 \cdot \frac{\cos \lambda_1 + -1}{2}}}\right)\\
                          
                          \mathbf{elif}\;\lambda_1 \leq -3 \cdot 10^{-153}:\\
                          \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_3 \cdot t_4}}{\sqrt{1 - {\left(\sqrt[3]{t_5 \cdot {t_5}^{2}}\right)}^{2}}}\right)\\
                          
                          \mathbf{else}:\\
                          \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_1 \cdot t_4}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - t_1 \cdot \left(\cos \phi_2 \cdot \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\right)}}\right)\\
                          
                          
                          \end{array}
                          \end{array}
                          
                          Derivation
                          1. Split input into 3 regimes
                          2. if lambda1 < -3.0000000000000001e-6

                            1. Initial program 55.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                              if -3.0000000000000001e-6 < lambda1 < -3e-153

                              1. Initial program 80.7%

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

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

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

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

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

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

                              if -3e-153 < lambda1

                              1. Initial program 65.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. Taylor expanded in lambda1 around 0 53.0%

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

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

                                \[\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(-0.5 \cdot \lambda_2\right)}}{\sqrt{\color{blue}{1 - \left(\sin \left(-0.5 \cdot \lambda_2\right) \cdot \left(\cos \phi_2 \cdot \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right) + {\sin \left(-0.5 \cdot \phi_2\right)}^{2}\right)}}}\right) \]
                              5. Step-by-step derivation
                                1. +-commutative42.8%

                                  \[\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(-0.5 \cdot \lambda_2\right)}}{\sqrt{1 - \color{blue}{\left({\sin \left(-0.5 \cdot \phi_2\right)}^{2} + \sin \left(-0.5 \cdot \lambda_2\right) \cdot \left(\cos \phi_2 \cdot \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\right)}}}\right) \]
                                2. associate--r+42.8%

                                  \[\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(-0.5 \cdot \lambda_2\right)}}{\sqrt{\color{blue}{\left(1 - {\sin \left(-0.5 \cdot \phi_2\right)}^{2}\right) - \sin \left(-0.5 \cdot \lambda_2\right) \cdot \left(\cos \phi_2 \cdot \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)}}}\right) \]
                                3. unpow242.8%

                                  \[\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(-0.5 \cdot \lambda_2\right)}}{\sqrt{\left(1 - \color{blue}{\sin \left(-0.5 \cdot \phi_2\right) \cdot \sin \left(-0.5 \cdot \phi_2\right)}\right) - \sin \left(-0.5 \cdot \lambda_2\right) \cdot \left(\cos \phi_2 \cdot \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)}}\right) \]
                                4. 1-sub-sin42.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(-0.5 \cdot \lambda_2\right)}}{\sqrt{\color{blue}{\cos \left(-0.5 \cdot \phi_2\right) \cdot \cos \left(-0.5 \cdot \phi_2\right)} - \sin \left(-0.5 \cdot \lambda_2\right) \cdot \left(\cos \phi_2 \cdot \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)}}\right) \]
                                5. unpow242.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(-0.5 \cdot \lambda_2\right)}}{\sqrt{\color{blue}{{\cos \left(-0.5 \cdot \phi_2\right)}^{2}} - \sin \left(-0.5 \cdot \lambda_2\right) \cdot \left(\cos \phi_2 \cdot \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)}}\right) \]
                                6. *-commutative42.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(-0.5 \cdot \lambda_2\right)}}{\sqrt{{\cos \left(-0.5 \cdot \phi_2\right)}^{2} - \sin \color{blue}{\left(\lambda_2 \cdot -0.5\right)} \cdot \left(\cos \phi_2 \cdot \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)}}\right) \]
                                7. *-commutative42.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(-0.5 \cdot \lambda_2\right)}}{\sqrt{{\cos \left(-0.5 \cdot \phi_2\right)}^{2} - \sin \left(\lambda_2 \cdot -0.5\right) \cdot \left(\cos \phi_2 \cdot \sin \color{blue}{\left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}\right)}}\right) \]
                              6. Simplified42.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(-0.5 \cdot \lambda_2\right)}}{\sqrt{\color{blue}{{\cos \left(-0.5 \cdot \phi_2\right)}^{2} - \sin \left(\lambda_2 \cdot -0.5\right) \cdot \left(\cos \phi_2 \cdot \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\right)}}}\right) \]
                            7. Recombined 3 regimes into one program.
                            8. Final simplification44.8%

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

                            Alternative 10: 38.3% accurate, 1.1× speedup?

                            \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \phi_1 \cdot \cos \phi_2\\ t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\ t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_3 := t_0 \cdot t_2\\ t_4 := \sin \left(\lambda_2 \cdot -0.5\right)\\ \mathbf{if}\;\lambda_1 \leq -105000000000:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_2, {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot -0.5\right)}^{2}, \phi_2 \cdot \left(\phi_2 \cdot 0.25\right)\right)}}{\sqrt{\left(1 - t_1\right) + t_0 \cdot \frac{\cos \left(\lambda_2 - \lambda_1\right) + -1}{2}}}\right)\\ \mathbf{elif}\;\lambda_1 \leq -2.05 \cdot 10^{-152}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + t_2 \cdot t_3}}{\sqrt{1 - {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + t_4 \cdot t_3}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - t_4 \cdot \left(\cos \phi_2 \cdot \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\right)}}\right)\\ \end{array} \end{array} \]
                            (FPCore (R lambda1 lambda2 phi1 phi2)
                             :precision binary64
                             (let* ((t_0 (* (cos phi1) (cos phi2)))
                                    (t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
                                    (t_2 (sin (/ (- lambda1 lambda2) 2.0)))
                                    (t_3 (* t_0 t_2))
                                    (t_4 (sin (* lambda2 -0.5))))
                               (if (<= lambda1 -105000000000.0)
                                 (*
                                  R
                                  (*
                                   2.0
                                   (atan2
                                    (sqrt
                                     (fma
                                      (cos phi2)
                                      (pow (sin (* (- lambda2 lambda1) -0.5)) 2.0)
                                      (* phi2 (* phi2 0.25))))
                                    (sqrt
                                     (+ (- 1.0 t_1) (* t_0 (/ (+ (cos (- lambda2 lambda1)) -1.0) 2.0)))))))
                                 (if (<= lambda1 -2.05e-152)
                                   (*
                                    R
                                    (*
                                     2.0
                                     (atan2
                                      (sqrt (+ t_1 (* t_2 t_3)))
                                      (sqrt (- 1.0 (pow (sin (* (- phi1 phi2) 0.5)) 2.0))))))
                                   (*
                                    R
                                    (*
                                     2.0
                                     (atan2
                                      (sqrt (+ t_1 (* t_4 t_3)))
                                      (sqrt
                                       (-
                                        (pow (cos (* phi2 -0.5)) 2.0)
                                        (* t_4 (* (cos phi2) (sin (* (- lambda1 lambda2) 0.5)))))))))))))
                            double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
                            	double t_0 = cos(phi1) * cos(phi2);
                            	double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
                            	double t_2 = sin(((lambda1 - lambda2) / 2.0));
                            	double t_3 = t_0 * t_2;
                            	double t_4 = sin((lambda2 * -0.5));
                            	double tmp;
                            	if (lambda1 <= -105000000000.0) {
                            		tmp = R * (2.0 * atan2(sqrt(fma(cos(phi2), pow(sin(((lambda2 - lambda1) * -0.5)), 2.0), (phi2 * (phi2 * 0.25)))), sqrt(((1.0 - t_1) + (t_0 * ((cos((lambda2 - lambda1)) + -1.0) / 2.0))))));
                            	} else if (lambda1 <= -2.05e-152) {
                            		tmp = R * (2.0 * atan2(sqrt((t_1 + (t_2 * t_3))), sqrt((1.0 - pow(sin(((phi1 - phi2) * 0.5)), 2.0)))));
                            	} else {
                            		tmp = R * (2.0 * atan2(sqrt((t_1 + (t_4 * t_3))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (t_4 * (cos(phi2) * sin(((lambda1 - lambda2) * 0.5))))))));
                            	}
                            	return tmp;
                            }
                            
                            function code(R, lambda1, lambda2, phi1, phi2)
                            	t_0 = Float64(cos(phi1) * cos(phi2))
                            	t_1 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0
                            	t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0))
                            	t_3 = Float64(t_0 * t_2)
                            	t_4 = sin(Float64(lambda2 * -0.5))
                            	tmp = 0.0
                            	if (lambda1 <= -105000000000.0)
                            		tmp = Float64(R * Float64(2.0 * atan(sqrt(fma(cos(phi2), (sin(Float64(Float64(lambda2 - lambda1) * -0.5)) ^ 2.0), Float64(phi2 * Float64(phi2 * 0.25)))), sqrt(Float64(Float64(1.0 - t_1) + Float64(t_0 * Float64(Float64(cos(Float64(lambda2 - lambda1)) + -1.0) / 2.0)))))));
                            	elseif (lambda1 <= -2.05e-152)
                            		tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_2 * t_3))), sqrt(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0))))));
                            	else
                            		tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_4 * t_3))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(t_4 * Float64(cos(phi2) * sin(Float64(Float64(lambda1 - lambda2) * 0.5)))))))));
                            	end
                            	return tmp
                            end
                            
                            code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$0 * t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -105000000000.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda2 - lambda1), $MachinePrecision] * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(phi2 * N[(phi2 * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$1), $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda1, -2.05e-152], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(t$95$2 * t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(t$95$4 * t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(t$95$4 * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
                            
                            \begin{array}{l}
                            
                            \\
                            \begin{array}{l}
                            t_0 := \cos \phi_1 \cdot \cos \phi_2\\
                            t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
                            t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
                            t_3 := t_0 \cdot t_2\\
                            t_4 := \sin \left(\lambda_2 \cdot -0.5\right)\\
                            \mathbf{if}\;\lambda_1 \leq -105000000000:\\
                            \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_2, {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot -0.5\right)}^{2}, \phi_2 \cdot \left(\phi_2 \cdot 0.25\right)\right)}}{\sqrt{\left(1 - t_1\right) + t_0 \cdot \frac{\cos \left(\lambda_2 - \lambda_1\right) + -1}{2}}}\right)\\
                            
                            \mathbf{elif}\;\lambda_1 \leq -2.05 \cdot 10^{-152}:\\
                            \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + t_2 \cdot t_3}}{\sqrt{1 - {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}}}\right)\\
                            
                            \mathbf{else}:\\
                            \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + t_4 \cdot t_3}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - t_4 \cdot \left(\cos \phi_2 \cdot \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\right)}}\right)\\
                            
                            
                            \end{array}
                            \end{array}
                            
                            Derivation
                            1. Split input into 3 regimes
                            2. if lambda1 < -1.05e11

                              1. Initial program 55.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                if -1.05e11 < lambda1 < -2.0500000000000001e-152

                                1. Initial program 79.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. Taylor expanded in lambda1 around 0 76.5%

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

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

                                if -2.0500000000000001e-152 < lambda1

                                1. Initial program 65.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. Taylor expanded in lambda1 around 0 53.0%

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

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

                                  \[\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(-0.5 \cdot \lambda_2\right)}}{\sqrt{\color{blue}{1 - \left(\sin \left(-0.5 \cdot \lambda_2\right) \cdot \left(\cos \phi_2 \cdot \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right) + {\sin \left(-0.5 \cdot \phi_2\right)}^{2}\right)}}}\right) \]
                                5. Step-by-step derivation
                                  1. +-commutative42.8%

                                    \[\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(-0.5 \cdot \lambda_2\right)}}{\sqrt{1 - \color{blue}{\left({\sin \left(-0.5 \cdot \phi_2\right)}^{2} + \sin \left(-0.5 \cdot \lambda_2\right) \cdot \left(\cos \phi_2 \cdot \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\right)}}}\right) \]
                                  2. associate--r+42.8%

                                    \[\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(-0.5 \cdot \lambda_2\right)}}{\sqrt{\color{blue}{\left(1 - {\sin \left(-0.5 \cdot \phi_2\right)}^{2}\right) - \sin \left(-0.5 \cdot \lambda_2\right) \cdot \left(\cos \phi_2 \cdot \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)}}}\right) \]
                                  3. unpow242.8%

                                    \[\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(-0.5 \cdot \lambda_2\right)}}{\sqrt{\left(1 - \color{blue}{\sin \left(-0.5 \cdot \phi_2\right) \cdot \sin \left(-0.5 \cdot \phi_2\right)}\right) - \sin \left(-0.5 \cdot \lambda_2\right) \cdot \left(\cos \phi_2 \cdot \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)}}\right) \]
                                  4. 1-sub-sin42.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(-0.5 \cdot \lambda_2\right)}}{\sqrt{\color{blue}{\cos \left(-0.5 \cdot \phi_2\right) \cdot \cos \left(-0.5 \cdot \phi_2\right)} - \sin \left(-0.5 \cdot \lambda_2\right) \cdot \left(\cos \phi_2 \cdot \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)}}\right) \]
                                  5. unpow242.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(-0.5 \cdot \lambda_2\right)}}{\sqrt{\color{blue}{{\cos \left(-0.5 \cdot \phi_2\right)}^{2}} - \sin \left(-0.5 \cdot \lambda_2\right) \cdot \left(\cos \phi_2 \cdot \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)}}\right) \]
                                  6. *-commutative42.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(-0.5 \cdot \lambda_2\right)}}{\sqrt{{\cos \left(-0.5 \cdot \phi_2\right)}^{2} - \sin \color{blue}{\left(\lambda_2 \cdot -0.5\right)} \cdot \left(\cos \phi_2 \cdot \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)}}\right) \]
                                  7. *-commutative42.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(-0.5 \cdot \lambda_2\right)}}{\sqrt{{\cos \left(-0.5 \cdot \phi_2\right)}^{2} - \sin \left(\lambda_2 \cdot -0.5\right) \cdot \left(\cos \phi_2 \cdot \sin \color{blue}{\left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}\right)}}\right) \]
                                6. Simplified42.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(-0.5 \cdot \lambda_2\right)}}{\sqrt{\color{blue}{{\cos \left(-0.5 \cdot \phi_2\right)}^{2} - \sin \left(\lambda_2 \cdot -0.5\right) \cdot \left(\cos \phi_2 \cdot \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\right)}}}\right) \]
                              7. Recombined 3 regimes into one program.
                              8. Final simplification42.2%

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

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

                                1. Initial program 55.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                  if -2.45e-5 < lambda1

                                  1. Initial program 67.7%

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

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

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

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

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

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

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

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

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

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

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

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

                                Alternative 12: 36.2% accurate, 1.1× speedup?

                                \[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_1 := \cos \phi_1 \cdot \cos \phi_2\\ t_2 := t_1 \cdot t_0\\ t_3 := \sin \left(\lambda_2 \cdot -0.5\right)\\ t_4 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\ \mathbf{if}\;\lambda_1 \leq -32000000000:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_2, {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot -0.5\right)}^{2}, \phi_2 \cdot \left(\phi_2 \cdot 0.25\right)\right)}}{\sqrt{\left(1 - t_4\right) + t_1 \cdot \frac{\cos \left(\lambda_2 - \lambda_1\right) + -1}{2}}}\right)\\ \mathbf{elif}\;\lambda_1 \leq -5.8 \cdot 10^{-180}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_4 + t_0 \cdot t_2}}{\sqrt{1 - {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_2 \cdot -0.5\right)}^{2} + \cos \phi_2 \cdot {t_3}^{2}}}{\sqrt{1 - \left(t_4 + t_3 \cdot 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 (* (cos phi1) (cos phi2)))
                                        (t_2 (* t_1 t_0))
                                        (t_3 (sin (* lambda2 -0.5)))
                                        (t_4 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
                                   (if (<= lambda1 -32000000000.0)
                                     (*
                                      R
                                      (*
                                       2.0
                                       (atan2
                                        (sqrt
                                         (fma
                                          (cos phi2)
                                          (pow (sin (* (- lambda2 lambda1) -0.5)) 2.0)
                                          (* phi2 (* phi2 0.25))))
                                        (sqrt
                                         (+ (- 1.0 t_4) (* t_1 (/ (+ (cos (- lambda2 lambda1)) -1.0) 2.0)))))))
                                     (if (<= lambda1 -5.8e-180)
                                       (*
                                        R
                                        (*
                                         2.0
                                         (atan2
                                          (sqrt (+ t_4 (* t_0 t_2)))
                                          (sqrt (- 1.0 (pow (sin (* (- phi1 phi2) 0.5)) 2.0))))))
                                       (*
                                        R
                                        (*
                                         2.0
                                         (atan2
                                          (sqrt (+ (pow (sin (* phi2 -0.5)) 2.0) (* (cos phi2) (pow t_3 2.0))))
                                          (sqrt (- 1.0 (+ t_4 (* t_3 t_2)))))))))))
                                double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
                                	double t_0 = sin(((lambda1 - lambda2) / 2.0));
                                	double t_1 = cos(phi1) * cos(phi2);
                                	double t_2 = t_1 * t_0;
                                	double t_3 = sin((lambda2 * -0.5));
                                	double t_4 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
                                	double tmp;
                                	if (lambda1 <= -32000000000.0) {
                                		tmp = R * (2.0 * atan2(sqrt(fma(cos(phi2), pow(sin(((lambda2 - lambda1) * -0.5)), 2.0), (phi2 * (phi2 * 0.25)))), sqrt(((1.0 - t_4) + (t_1 * ((cos((lambda2 - lambda1)) + -1.0) / 2.0))))));
                                	} else if (lambda1 <= -5.8e-180) {
                                		tmp = R * (2.0 * atan2(sqrt((t_4 + (t_0 * t_2))), sqrt((1.0 - pow(sin(((phi1 - phi2) * 0.5)), 2.0)))));
                                	} else {
                                		tmp = R * (2.0 * atan2(sqrt((pow(sin((phi2 * -0.5)), 2.0) + (cos(phi2) * pow(t_3, 2.0)))), sqrt((1.0 - (t_4 + (t_3 * t_2))))));
                                	}
                                	return tmp;
                                }
                                
                                function code(R, lambda1, lambda2, phi1, phi2)
                                	t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0))
                                	t_1 = Float64(cos(phi1) * cos(phi2))
                                	t_2 = Float64(t_1 * t_0)
                                	t_3 = sin(Float64(lambda2 * -0.5))
                                	t_4 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0
                                	tmp = 0.0
                                	if (lambda1 <= -32000000000.0)
                                		tmp = Float64(R * Float64(2.0 * atan(sqrt(fma(cos(phi2), (sin(Float64(Float64(lambda2 - lambda1) * -0.5)) ^ 2.0), Float64(phi2 * Float64(phi2 * 0.25)))), sqrt(Float64(Float64(1.0 - t_4) + Float64(t_1 * Float64(Float64(cos(Float64(lambda2 - lambda1)) + -1.0) / 2.0)))))));
                                	elseif (lambda1 <= -5.8e-180)
                                		tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_4 + Float64(t_0 * t_2))), sqrt(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0))))));
                                	else
                                		tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(phi2 * -0.5)) ^ 2.0) + Float64(cos(phi2) * (t_3 ^ 2.0)))), sqrt(Float64(1.0 - Float64(t_4 + Float64(t_3 * 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[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * t$95$0), $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[lambda1, -32000000000.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda2 - lambda1), $MachinePrecision] * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(phi2 * N[(phi2 * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$4), $MachinePrecision] + N[(t$95$1 * N[(N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda1, -5.8e-180], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$4 + N[(t$95$0 * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Power[t$95$3, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$4 + N[(t$95$3 * t$95$2), $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 \cos \phi_2\\
                                t_2 := t_1 \cdot t_0\\
                                t_3 := \sin \left(\lambda_2 \cdot -0.5\right)\\
                                t_4 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
                                \mathbf{if}\;\lambda_1 \leq -32000000000:\\
                                \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_2, {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot -0.5\right)}^{2}, \phi_2 \cdot \left(\phi_2 \cdot 0.25\right)\right)}}{\sqrt{\left(1 - t_4\right) + t_1 \cdot \frac{\cos \left(\lambda_2 - \lambda_1\right) + -1}{2}}}\right)\\
                                
                                \mathbf{elif}\;\lambda_1 \leq -5.8 \cdot 10^{-180}:\\
                                \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_4 + t_0 \cdot t_2}}{\sqrt{1 - {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}}}\right)\\
                                
                                \mathbf{else}:\\
                                \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_2 \cdot -0.5\right)}^{2} + \cos \phi_2 \cdot {t_3}^{2}}}{\sqrt{1 - \left(t_4 + t_3 \cdot t_2\right)}}\right)\\
                                
                                
                                \end{array}
                                \end{array}
                                
                                Derivation
                                1. Split input into 3 regimes
                                2. if lambda1 < -3.2e10

                                  1. Initial program 55.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                    if -3.2e10 < lambda1 < -5.79999999999999961e-180

                                    1. Initial program 81.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 lambda1 around 0 78.6%

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

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

                                    if -5.79999999999999961e-180 < lambda1

                                    1. Initial program 64.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. Taylor expanded in lambda1 around 0 52.2%

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

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

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

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

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

                                  Alternative 13: 39.0% accurate, 1.2× speedup?

                                  \[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)\\ t_1 := \cos \phi_1 \cdot \cos \phi_2\\ t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ \mathbf{if}\;\lambda_1 - \lambda_2 \leq -5000000:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_2, {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot -0.5\right)}^{2}, \phi_2 \cdot \left(\phi_2 \cdot 0.25\right)\right)}}{\sqrt{\left(1 - {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right) + t_1 \cdot \frac{\cos \left(\lambda_2 - \lambda_1\right) + -1}{2}}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\mathsf{expm1}\left(\mathsf{log1p}\left(t_0\right)\right)\right)}^{2} + t_2 \cdot \left(t_1 \cdot t_2\right)}}{\sqrt{1 - {t_0}^{2}}}\right)\\ \end{array} \end{array} \]
                                  (FPCore (R lambda1 lambda2 phi1 phi2)
                                   :precision binary64
                                   (let* ((t_0 (sin (* (- phi1 phi2) 0.5)))
                                          (t_1 (* (cos phi1) (cos phi2)))
                                          (t_2 (sin (/ (- lambda1 lambda2) 2.0))))
                                     (if (<= (- lambda1 lambda2) -5000000.0)
                                       (*
                                        R
                                        (*
                                         2.0
                                         (atan2
                                          (sqrt
                                           (fma
                                            (cos phi2)
                                            (pow (sin (* (- lambda2 lambda1) -0.5)) 2.0)
                                            (* phi2 (* phi2 0.25))))
                                          (sqrt
                                           (+
                                            (- 1.0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
                                            (* t_1 (/ (+ (cos (- lambda2 lambda1)) -1.0) 2.0)))))))
                                       (*
                                        R
                                        (*
                                         2.0
                                         (atan2
                                          (sqrt (+ (pow (expm1 (log1p t_0)) 2.0) (* t_2 (* t_1 t_2))))
                                          (sqrt (- 1.0 (pow t_0 2.0)))))))))
                                  double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
                                  	double t_0 = sin(((phi1 - phi2) * 0.5));
                                  	double t_1 = cos(phi1) * cos(phi2);
                                  	double t_2 = sin(((lambda1 - lambda2) / 2.0));
                                  	double tmp;
                                  	if ((lambda1 - lambda2) <= -5000000.0) {
                                  		tmp = R * (2.0 * atan2(sqrt(fma(cos(phi2), pow(sin(((lambda2 - lambda1) * -0.5)), 2.0), (phi2 * (phi2 * 0.25)))), sqrt(((1.0 - pow(sin(((phi1 - phi2) / 2.0)), 2.0)) + (t_1 * ((cos((lambda2 - lambda1)) + -1.0) / 2.0))))));
                                  	} else {
                                  		tmp = R * (2.0 * atan2(sqrt((pow(expm1(log1p(t_0)), 2.0) + (t_2 * (t_1 * t_2)))), sqrt((1.0 - pow(t_0, 2.0)))));
                                  	}
                                  	return tmp;
                                  }
                                  
                                  function code(R, lambda1, lambda2, phi1, phi2)
                                  	t_0 = sin(Float64(Float64(phi1 - phi2) * 0.5))
                                  	t_1 = Float64(cos(phi1) * cos(phi2))
                                  	t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0))
                                  	tmp = 0.0
                                  	if (Float64(lambda1 - lambda2) <= -5000000.0)
                                  		tmp = Float64(R * Float64(2.0 * atan(sqrt(fma(cos(phi2), (sin(Float64(Float64(lambda2 - lambda1) * -0.5)) ^ 2.0), Float64(phi2 * Float64(phi2 * 0.25)))), sqrt(Float64(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)) + Float64(t_1 * Float64(Float64(cos(Float64(lambda2 - lambda1)) + -1.0) / 2.0)))))));
                                  	else
                                  		tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((expm1(log1p(t_0)) ^ 2.0) + Float64(t_2 * Float64(t_1 * t_2)))), sqrt(Float64(1.0 - (t_0 ^ 2.0))))));
                                  	end
                                  	return tmp
                                  end
                                  
                                  code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -5000000.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda2 - lambda1), $MachinePrecision] * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(phi2 * N[(phi2 * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[(t$95$1 * N[(N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(Exp[N[Log[1 + t$95$0], $MachinePrecision]] - 1), $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$2 * N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
                                  
                                  \begin{array}{l}
                                  
                                  \\
                                  \begin{array}{l}
                                  t_0 := \sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)\\
                                  t_1 := \cos \phi_1 \cdot \cos \phi_2\\
                                  t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
                                  \mathbf{if}\;\lambda_1 - \lambda_2 \leq -5000000:\\
                                  \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_2, {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot -0.5\right)}^{2}, \phi_2 \cdot \left(\phi_2 \cdot 0.25\right)\right)}}{\sqrt{\left(1 - {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right) + t_1 \cdot \frac{\cos \left(\lambda_2 - \lambda_1\right) + -1}{2}}}\right)\\
                                  
                                  \mathbf{else}:\\
                                  \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\mathsf{expm1}\left(\mathsf{log1p}\left(t_0\right)\right)\right)}^{2} + t_2 \cdot \left(t_1 \cdot t_2\right)}}{\sqrt{1 - {t_0}^{2}}}\right)\\
                                  
                                  
                                  \end{array}
                                  \end{array}
                                  
                                  Derivation
                                  1. Split input into 2 regimes
                                  2. if (-.f64 lambda1 lambda2) < -5e6

                                    1. Initial program 61.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                      if -5e6 < (-.f64 lambda1 lambda2)

                                      1. Initial program 66.7%

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

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

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

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

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

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

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

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

                                    Alternative 14: 39.0% accurate, 1.2× 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 := \cos \phi_1 \cdot \cos \phi_2\\ \mathbf{if}\;\lambda_1 - \lambda_2 \leq -5000000:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_2, {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot -0.5\right)}^{2}, \phi_2 \cdot \left(\phi_2 \cdot 0.25\right)\right)}}{\sqrt{\left(1 - t_0\right) + t_2 \cdot \frac{\cos \left(\lambda_2 - \lambda_1\right) + -1}{2}}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_1 \cdot \left(t_2 \cdot t_1\right)}}{\sqrt{1 - {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}}}\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 (* (cos phi1) (cos phi2))))
                                       (if (<= (- lambda1 lambda2) -5000000.0)
                                         (*
                                          R
                                          (*
                                           2.0
                                           (atan2
                                            (sqrt
                                             (fma
                                              (cos phi2)
                                              (pow (sin (* (- lambda2 lambda1) -0.5)) 2.0)
                                              (* phi2 (* phi2 0.25))))
                                            (sqrt
                                             (+ (- 1.0 t_0) (* t_2 (/ (+ (cos (- lambda2 lambda1)) -1.0) 2.0)))))))
                                         (*
                                          R
                                          (*
                                           2.0
                                           (atan2
                                            (sqrt (+ t_0 (* t_1 (* t_2 t_1))))
                                            (sqrt (- 1.0 (pow (sin (* (- phi1 phi2) 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 = sin(((lambda1 - lambda2) / 2.0));
                                    	double t_2 = cos(phi1) * cos(phi2);
                                    	double tmp;
                                    	if ((lambda1 - lambda2) <= -5000000.0) {
                                    		tmp = R * (2.0 * atan2(sqrt(fma(cos(phi2), pow(sin(((lambda2 - lambda1) * -0.5)), 2.0), (phi2 * (phi2 * 0.25)))), sqrt(((1.0 - t_0) + (t_2 * ((cos((lambda2 - lambda1)) + -1.0) / 2.0))))));
                                    	} else {
                                    		tmp = R * (2.0 * atan2(sqrt((t_0 + (t_1 * (t_2 * t_1)))), sqrt((1.0 - pow(sin(((phi1 - phi2) * 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) / 2.0))
                                    	t_2 = Float64(cos(phi1) * cos(phi2))
                                    	tmp = 0.0
                                    	if (Float64(lambda1 - lambda2) <= -5000000.0)
                                    		tmp = Float64(R * Float64(2.0 * atan(sqrt(fma(cos(phi2), (sin(Float64(Float64(lambda2 - lambda1) * -0.5)) ^ 2.0), Float64(phi2 * Float64(phi2 * 0.25)))), sqrt(Float64(Float64(1.0 - t_0) + Float64(t_2 * Float64(Float64(cos(Float64(lambda2 - lambda1)) + -1.0) / 2.0)))))));
                                    	else
                                    		tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_1 * Float64(t_2 * t_1)))), sqrt(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0))))));
                                    	end
                                    	return 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[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -5000000.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda2 - lambda1), $MachinePrecision] * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(phi2 * N[(phi2 * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$0), $MachinePrecision] + N[(t$95$2 * N[(N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$1 * N[(t$95$2 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $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(\frac{\lambda_1 - \lambda_2}{2}\right)\\
                                    t_2 := \cos \phi_1 \cdot \cos \phi_2\\
                                    \mathbf{if}\;\lambda_1 - \lambda_2 \leq -5000000:\\
                                    \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_2, {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot -0.5\right)}^{2}, \phi_2 \cdot \left(\phi_2 \cdot 0.25\right)\right)}}{\sqrt{\left(1 - t_0\right) + t_2 \cdot \frac{\cos \left(\lambda_2 - \lambda_1\right) + -1}{2}}}\right)\\
                                    
                                    \mathbf{else}:\\
                                    \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_1 \cdot \left(t_2 \cdot t_1\right)}}{\sqrt{1 - {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}}}\right)\\
                                    
                                    
                                    \end{array}
                                    \end{array}
                                    
                                    Derivation
                                    1. Split input into 2 regimes
                                    2. if (-.f64 lambda1 lambda2) < -5e6

                                      1. Initial program 61.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                        if -5e6 < (-.f64 lambda1 lambda2)

                                        1. Initial program 66.7%

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

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

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

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

                                      Alternative 15: 37.2% accurate, 1.4× speedup?

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

                                        1. Initial program 68.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. Taylor expanded in lambda1 around 0 45.9%

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

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

                                        if 320 < lambda2

                                        1. Initial program 51.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. Taylor expanded in lambda1 around 0 51.4%

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

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

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

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

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

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

                                      Alternative 16: 36.5% accurate, 1.4× 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 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_1\\ t_3 := \sin \left(\lambda_2 \cdot -0.5\right)\\ \mathbf{if}\;\lambda_2 \leq 1500:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_1 \cdot t_2}}{\sqrt{1 - {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_3 \cdot \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}}{\sqrt{1 - \left(t_0 + t_3 \cdot t_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 (sin (/ (- lambda1 lambda2) 2.0)))
                                              (t_2 (* (* (cos phi1) (cos phi2)) t_1))
                                              (t_3 (sin (* lambda2 -0.5))))
                                         (if (<= lambda2 1500.0)
                                           (*
                                            R
                                            (*
                                             2.0
                                             (atan2
                                              (sqrt (+ t_0 (* t_1 t_2)))
                                              (sqrt (- 1.0 (pow (sin (* (- phi1 phi2) 0.5)) 2.0))))))
                                           (*
                                            R
                                            (*
                                             2.0
                                             (atan2
                                              (sqrt (* t_3 (sin (* (- lambda1 lambda2) 0.5))))
                                              (sqrt (- 1.0 (+ t_0 (* t_3 t_2))))))))))
                                      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 = (cos(phi1) * cos(phi2)) * t_1;
                                      	double t_3 = sin((lambda2 * -0.5));
                                      	double tmp;
                                      	if (lambda2 <= 1500.0) {
                                      		tmp = R * (2.0 * atan2(sqrt((t_0 + (t_1 * t_2))), sqrt((1.0 - pow(sin(((phi1 - phi2) * 0.5)), 2.0)))));
                                      	} else {
                                      		tmp = R * (2.0 * atan2(sqrt((t_3 * sin(((lambda1 - lambda2) * 0.5)))), sqrt((1.0 - (t_0 + (t_3 * t_2))))));
                                      	}
                                      	return tmp;
                                      }
                                      
                                      real(8) function code(r, lambda1, lambda2, phi1, phi2)
                                          real(8), intent (in) :: r
                                          real(8), intent (in) :: lambda1
                                          real(8), intent (in) :: lambda2
                                          real(8), intent (in) :: phi1
                                          real(8), intent (in) :: phi2
                                          real(8) :: t_0
                                          real(8) :: t_1
                                          real(8) :: t_2
                                          real(8) :: t_3
                                          real(8) :: tmp
                                          t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
                                          t_1 = sin(((lambda1 - lambda2) / 2.0d0))
                                          t_2 = (cos(phi1) * cos(phi2)) * t_1
                                          t_3 = sin((lambda2 * (-0.5d0)))
                                          if (lambda2 <= 1500.0d0) then
                                              tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_1 * t_2))), sqrt((1.0d0 - (sin(((phi1 - phi2) * 0.5d0)) ** 2.0d0)))))
                                          else
                                              tmp = r * (2.0d0 * atan2(sqrt((t_3 * sin(((lambda1 - lambda2) * 0.5d0)))), sqrt((1.0d0 - (t_0 + (t_3 * t_2))))))
                                          end if
                                          code = tmp
                                      end function
                                      
                                      public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
                                      	double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
                                      	double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
                                      	double t_2 = (Math.cos(phi1) * Math.cos(phi2)) * t_1;
                                      	double t_3 = Math.sin((lambda2 * -0.5));
                                      	double tmp;
                                      	if (lambda2 <= 1500.0) {
                                      		tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_1 * t_2))), Math.sqrt((1.0 - Math.pow(Math.sin(((phi1 - phi2) * 0.5)), 2.0)))));
                                      	} else {
                                      		tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 * Math.sin(((lambda1 - lambda2) * 0.5)))), Math.sqrt((1.0 - (t_0 + (t_3 * t_2))))));
                                      	}
                                      	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.cos(phi1) * math.cos(phi2)) * t_1
                                      	t_3 = math.sin((lambda2 * -0.5))
                                      	tmp = 0
                                      	if lambda2 <= 1500.0:
                                      		tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_1 * t_2))), math.sqrt((1.0 - math.pow(math.sin(((phi1 - phi2) * 0.5)), 2.0)))))
                                      	else:
                                      		tmp = R * (2.0 * math.atan2(math.sqrt((t_3 * math.sin(((lambda1 - lambda2) * 0.5)))), math.sqrt((1.0 - (t_0 + (t_3 * t_2))))))
                                      	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 = Float64(Float64(cos(phi1) * cos(phi2)) * t_1)
                                      	t_3 = sin(Float64(lambda2 * -0.5))
                                      	tmp = 0.0
                                      	if (lambda2 <= 1500.0)
                                      		tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_1 * t_2))), sqrt(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0))))));
                                      	else
                                      		tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 * sin(Float64(Float64(lambda1 - lambda2) * 0.5)))), sqrt(Float64(1.0 - Float64(t_0 + Float64(t_3 * t_2)))))));
                                      	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 = (cos(phi1) * cos(phi2)) * t_1;
                                      	t_3 = sin((lambda2 * -0.5));
                                      	tmp = 0.0;
                                      	if (lambda2 <= 1500.0)
                                      		tmp = R * (2.0 * atan2(sqrt((t_0 + (t_1 * t_2))), sqrt((1.0 - (sin(((phi1 - phi2) * 0.5)) ^ 2.0)))));
                                      	else
                                      		tmp = R * (2.0 * atan2(sqrt((t_3 * sin(((lambda1 - lambda2) * 0.5)))), sqrt((1.0 - (t_0 + (t_3 * t_2))))));
                                      	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[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, 1500.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 * N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$0 + N[(t$95$3 * t$95$2), $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(\frac{\lambda_1 - \lambda_2}{2}\right)\\
                                      t_2 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_1\\
                                      t_3 := \sin \left(\lambda_2 \cdot -0.5\right)\\
                                      \mathbf{if}\;\lambda_2 \leq 1500:\\
                                      \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_1 \cdot t_2}}{\sqrt{1 - {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}}}\right)\\
                                      
                                      \mathbf{else}:\\
                                      \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_3 \cdot \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}}{\sqrt{1 - \left(t_0 + t_3 \cdot t_2\right)}}\right)\\
                                      
                                      
                                      \end{array}
                                      \end{array}
                                      
                                      Derivation
                                      1. Split input into 2 regimes
                                      2. if lambda2 < 1500

                                        1. Initial program 68.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. Taylor expanded in lambda1 around 0 45.9%

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

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

                                        if 1500 < lambda2

                                        1. Initial program 51.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. Taylor expanded in lambda1 around 0 51.4%

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

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

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

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

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

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

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

                                      Alternative 17: 34.1% accurate, 1.4× speedup?

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

                                        1. Initial program 50.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 lambda1 around 0 40.9%

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

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

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

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

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

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

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

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

                                        if -5.39999999999999977e-18 < phi2 < 1.30000000000000005e-26

                                        1. Initial program 82.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. Taylor expanded in lambda1 around 0 55.5%

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

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

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

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

                                      Alternative 18: 35.1% accurate, 1.4× speedup?

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

                                        1. Initial program 50.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 lambda1 around 0 40.9%

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

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

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

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

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

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

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

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

                                        if -1.79999999999999997e-17 < phi2 < 3.00000000000000012e-26

                                        1. Initial program 82.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. Taylor expanded in lambda1 around 0 55.5%

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

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

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

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

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

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

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

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

                                      Alternative 19: 32.4% accurate, 1.4× speedup?

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

                                        1. Initial program 58.3%

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

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

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

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

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

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

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

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

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

                                        if -2.4000000000000001e-93 < lambda1

                                        1. Initial program 67.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. Taylor expanded in lambda1 around 0 55.9%

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

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

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

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

                                      Alternative 20: 32.7% accurate, 1.4× speedup?

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

                                        1. Initial program 58.3%

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

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

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

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

                                        if -1.75e-93 < lambda1

                                        1. Initial program 67.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. Taylor expanded in lambda1 around 0 55.9%

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

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

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

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

                                      Alternative 21: 34.9% 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{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)}}{\sqrt{1 - {\sin \left(\left(\phi_1 - \phi_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
                                             (+
                                              (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
                                              (* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
                                            (sqrt (- 1.0 (pow (sin (* (- phi1 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((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((1.0 - pow(sin(((phi1 - phi2) * 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(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((1.0d0 - (sin(((phi1 - phi2) * 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((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)))), Math.sqrt((1.0 - Math.pow(Math.sin(((phi1 - phi2) * 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((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)))), math.sqrt((1.0 - math.pow(math.sin(((phi1 - 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(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))), sqrt(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) * 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(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((1.0 - (sin(((phi1 - 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[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $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{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)}}{\sqrt{1 - {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}}}\right)
                                      \end{array}
                                      \end{array}
                                      
                                      Derivation
                                      1. Initial program 64.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. Taylor expanded in lambda1 around 0 47.3%

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

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

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

                                      Alternative 22: 28.3% accurate, 1.4× speedup?

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

                                        1. Initial program 58.3%

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

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

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

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

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

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

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

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

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

                                        if -1.02e-93 < lambda1

                                        1. Initial program 67.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. Taylor expanded in lambda1 around 0 55.9%

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

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

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

                                            \[\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 - \color{blue}{\sin \left(-0.5 \cdot \phi_2\right) \cdot \sin \left(-0.5 \cdot \phi_2\right)}}}\right) \]
                                          2. 1-sub-sin31.8%

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

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

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

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

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

                                      Alternative 23: 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{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)}}{\sqrt{{\cos \left(\phi_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))))
                                         (*
                                          R
                                          (*
                                           2.0
                                           (atan2
                                            (sqrt
                                             (+
                                              (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
                                              (* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
                                            (sqrt (pow (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((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt(pow(cos((phi2 * -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(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((cos((phi2 * (-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((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)))), Math.sqrt(Math.pow(Math.cos((phi2 * -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((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)))), math.sqrt(math.pow(math.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(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))), sqrt((cos(Float64(phi2 * -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(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((cos((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[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Power[N[Cos[N[(phi2 * -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{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2}}}\right)
                                      \end{array}
                                      \end{array}
                                      
                                      Derivation
                                      1. Initial program 64.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. Taylor expanded in lambda1 around 0 47.3%

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

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

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

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

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

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

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

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

                                      Alternative 24: 28.7% accurate, 1.4× speedup?

                                      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2}}\\ \mathbf{if}\;\lambda_2 \leq 1.8 \cdot 10^{-131}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2} + \cos \phi_2 \cdot \left(\cos \phi_1 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}\right)}}{t_0}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_2 \cdot -0.5\right)}^{2} + \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}{t_0}\right)\\ \end{array} \end{array} \]
                                      (FPCore (R lambda1 lambda2 phi1 phi2)
                                       :precision binary64
                                       (let* ((t_0 (sqrt (pow (cos (* phi2 -0.5)) 2.0))))
                                         (if (<= lambda2 1.8e-131)
                                           (*
                                            R
                                            (*
                                             2.0
                                             (atan2
                                              (sqrt
                                               (+
                                                (pow (sin (* (- phi1 phi2) 0.5)) 2.0)
                                                (* (cos phi2) (* (cos phi1) (pow (sin (* lambda1 0.5)) 2.0)))))
                                              t_0)))
                                           (*
                                            R
                                            (*
                                             2.0
                                             (atan2
                                              (sqrt
                                               (+
                                                (pow (sin (* phi2 -0.5)) 2.0)
                                                (* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))
                                              t_0))))))
                                      double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
                                      	double t_0 = sqrt(pow(cos((phi2 * -0.5)), 2.0));
                                      	double tmp;
                                      	if (lambda2 <= 1.8e-131) {
                                      		tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) * 0.5)), 2.0) + (cos(phi2) * (cos(phi1) * pow(sin((lambda1 * 0.5)), 2.0))))), t_0));
                                      	} else {
                                      		tmp = R * (2.0 * atan2(sqrt((pow(sin((phi2 * -0.5)), 2.0) + (cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))), t_0));
                                      	}
                                      	return tmp;
                                      }
                                      
                                      real(8) function code(r, lambda1, lambda2, phi1, phi2)
                                          real(8), intent (in) :: r
                                          real(8), intent (in) :: lambda1
                                          real(8), intent (in) :: lambda2
                                          real(8), intent (in) :: phi1
                                          real(8), intent (in) :: phi2
                                          real(8) :: t_0
                                          real(8) :: tmp
                                          t_0 = sqrt((cos((phi2 * (-0.5d0))) ** 2.0d0))
                                          if (lambda2 <= 1.8d-131) then
                                              tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) * 0.5d0)) ** 2.0d0) + (cos(phi2) * (cos(phi1) * (sin((lambda1 * 0.5d0)) ** 2.0d0))))), t_0))
                                          else
                                              tmp = r * (2.0d0 * atan2(sqrt(((sin((phi2 * (-0.5d0))) ** 2.0d0) + (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))), t_0))
                                          end if
                                          code = tmp
                                      end function
                                      
                                      public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
                                      	double t_0 = Math.sqrt(Math.pow(Math.cos((phi2 * -0.5)), 2.0));
                                      	double tmp;
                                      	if (lambda2 <= 1.8e-131) {
                                      		tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) * 0.5)), 2.0) + (Math.cos(phi2) * (Math.cos(phi1) * Math.pow(Math.sin((lambda1 * 0.5)), 2.0))))), t_0));
                                      	} else {
                                      		tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin((phi2 * -0.5)), 2.0) + (Math.cos(phi2) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), t_0));
                                      	}
                                      	return tmp;
                                      }
                                      
                                      def code(R, lambda1, lambda2, phi1, phi2):
                                      	t_0 = math.sqrt(math.pow(math.cos((phi2 * -0.5)), 2.0))
                                      	tmp = 0
                                      	if lambda2 <= 1.8e-131:
                                      		tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) * 0.5)), 2.0) + (math.cos(phi2) * (math.cos(phi1) * math.pow(math.sin((lambda1 * 0.5)), 2.0))))), t_0))
                                      	else:
                                      		tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin((phi2 * -0.5)), 2.0) + (math.cos(phi2) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), t_0))
                                      	return tmp
                                      
                                      function code(R, lambda1, lambda2, phi1, phi2)
                                      	t_0 = sqrt((cos(Float64(phi2 * -0.5)) ^ 2.0))
                                      	tmp = 0.0
                                      	if (lambda2 <= 1.8e-131)
                                      		tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0) + Float64(cos(phi2) * Float64(cos(phi1) * (sin(Float64(lambda1 * 0.5)) ^ 2.0))))), t_0)));
                                      	else
                                      		tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(phi2 * -0.5)) ^ 2.0) + Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))), t_0)));
                                      	end
                                      	return tmp
                                      end
                                      
                                      function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
                                      	t_0 = sqrt((cos((phi2 * -0.5)) ^ 2.0));
                                      	tmp = 0.0;
                                      	if (lambda2 <= 1.8e-131)
                                      		tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) * 0.5)) ^ 2.0) + (cos(phi2) * (cos(phi1) * (sin((lambda1 * 0.5)) ^ 2.0))))), t_0));
                                      	else
                                      		tmp = R * (2.0 * atan2(sqrt(((sin((phi2 * -0.5)) ^ 2.0) + (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)))), t_0));
                                      	end
                                      	tmp_2 = tmp;
                                      end
                                      
                                      code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sqrt[N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, 1.8e-131], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
                                      
                                      \begin{array}{l}
                                      
                                      \\
                                      \begin{array}{l}
                                      t_0 := \sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2}}\\
                                      \mathbf{if}\;\lambda_2 \leq 1.8 \cdot 10^{-131}:\\
                                      \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2} + \cos \phi_2 \cdot \left(\cos \phi_1 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}\right)}}{t_0}\right)\\
                                      
                                      \mathbf{else}:\\
                                      \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_2 \cdot -0.5\right)}^{2} + \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}{t_0}\right)\\
                                      
                                      
                                      \end{array}
                                      \end{array}
                                      
                                      Derivation
                                      1. Split input into 2 regimes
                                      2. if lambda2 < 1.8e-131

                                        1. Initial program 67.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. Taylor expanded in lambda1 around 0 45.6%

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

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

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

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

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

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

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

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

                                        if 1.8e-131 < lambda2

                                        1. Initial program 59.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 lambda1 around 0 50.4%

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

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

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

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

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

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

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

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

                                      Alternative 25: 28.6% accurate, 1.4× speedup?

                                      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2}}\\ \mathbf{if}\;\lambda_1 \leq -1.75 \cdot 10^{-93}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_2 \cdot -0.5\right)}^{2} + \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}{t_0}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}}{t_0}\right)\\ \end{array} \end{array} \]
                                      (FPCore (R lambda1 lambda2 phi1 phi2)
                                       :precision binary64
                                       (let* ((t_0 (sqrt (pow (cos (* phi2 -0.5)) 2.0))))
                                         (if (<= lambda1 -1.75e-93)
                                           (*
                                            R
                                            (*
                                             2.0
                                             (atan2
                                              (sqrt
                                               (+
                                                (pow (sin (* phi2 -0.5)) 2.0)
                                                (* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))
                                              t_0)))
                                           (*
                                            R
                                            (*
                                             2.0
                                             (atan2
                                              (sqrt
                                               (+
                                                (pow (sin (* (- phi1 phi2) 0.5)) 2.0)
                                                (* (* (cos phi1) (cos phi2)) (pow (sin (* lambda2 -0.5)) 2.0))))
                                              t_0))))))
                                      double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
                                      	double t_0 = sqrt(pow(cos((phi2 * -0.5)), 2.0));
                                      	double tmp;
                                      	if (lambda1 <= -1.75e-93) {
                                      		tmp = R * (2.0 * atan2(sqrt((pow(sin((phi2 * -0.5)), 2.0) + (cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))), t_0));
                                      	} else {
                                      		tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) * 0.5)), 2.0) + ((cos(phi1) * cos(phi2)) * pow(sin((lambda2 * -0.5)), 2.0)))), t_0));
                                      	}
                                      	return tmp;
                                      }
                                      
                                      real(8) function code(r, lambda1, lambda2, phi1, phi2)
                                          real(8), intent (in) :: r
                                          real(8), intent (in) :: lambda1
                                          real(8), intent (in) :: lambda2
                                          real(8), intent (in) :: phi1
                                          real(8), intent (in) :: phi2
                                          real(8) :: t_0
                                          real(8) :: tmp
                                          t_0 = sqrt((cos((phi2 * (-0.5d0))) ** 2.0d0))
                                          if (lambda1 <= (-1.75d-93)) then
                                              tmp = r * (2.0d0 * atan2(sqrt(((sin((phi2 * (-0.5d0))) ** 2.0d0) + (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))), t_0))
                                          else
                                              tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) * 0.5d0)) ** 2.0d0) + ((cos(phi1) * cos(phi2)) * (sin((lambda2 * (-0.5d0))) ** 2.0d0)))), t_0))
                                          end if
                                          code = tmp
                                      end function
                                      
                                      public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
                                      	double t_0 = Math.sqrt(Math.pow(Math.cos((phi2 * -0.5)), 2.0));
                                      	double tmp;
                                      	if (lambda1 <= -1.75e-93) {
                                      		tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin((phi2 * -0.5)), 2.0) + (Math.cos(phi2) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), t_0));
                                      	} else {
                                      		tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) * 0.5)), 2.0) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0)))), t_0));
                                      	}
                                      	return tmp;
                                      }
                                      
                                      def code(R, lambda1, lambda2, phi1, phi2):
                                      	t_0 = math.sqrt(math.pow(math.cos((phi2 * -0.5)), 2.0))
                                      	tmp = 0
                                      	if lambda1 <= -1.75e-93:
                                      		tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin((phi2 * -0.5)), 2.0) + (math.cos(phi2) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), t_0))
                                      	else:
                                      		tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) * 0.5)), 2.0) + ((math.cos(phi1) * math.cos(phi2)) * math.pow(math.sin((lambda2 * -0.5)), 2.0)))), t_0))
                                      	return tmp
                                      
                                      function code(R, lambda1, lambda2, phi1, phi2)
                                      	t_0 = sqrt((cos(Float64(phi2 * -0.5)) ^ 2.0))
                                      	tmp = 0.0
                                      	if (lambda1 <= -1.75e-93)
                                      		tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(phi2 * -0.5)) ^ 2.0) + Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))), t_0)));
                                      	else
                                      		tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0) + Float64(Float64(cos(phi1) * cos(phi2)) * (sin(Float64(lambda2 * -0.5)) ^ 2.0)))), t_0)));
                                      	end
                                      	return tmp
                                      end
                                      
                                      function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
                                      	t_0 = sqrt((cos((phi2 * -0.5)) ^ 2.0));
                                      	tmp = 0.0;
                                      	if (lambda1 <= -1.75e-93)
                                      		tmp = R * (2.0 * atan2(sqrt(((sin((phi2 * -0.5)) ^ 2.0) + (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)))), t_0));
                                      	else
                                      		tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) * 0.5)) ^ 2.0) + ((cos(phi1) * cos(phi2)) * (sin((lambda2 * -0.5)) ^ 2.0)))), t_0));
                                      	end
                                      	tmp_2 = tmp;
                                      end
                                      
                                      code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sqrt[N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -1.75e-93], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
                                      
                                      \begin{array}{l}
                                      
                                      \\
                                      \begin{array}{l}
                                      t_0 := \sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2}}\\
                                      \mathbf{if}\;\lambda_1 \leq -1.75 \cdot 10^{-93}:\\
                                      \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_2 \cdot -0.5\right)}^{2} + \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}{t_0}\right)\\
                                      
                                      \mathbf{else}:\\
                                      \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}}{t_0}\right)\\
                                      
                                      
                                      \end{array}
                                      \end{array}
                                      
                                      Derivation
                                      1. Split input into 2 regimes
                                      2. if lambda1 < -1.75e-93

                                        1. Initial program 58.3%

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

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

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

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

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

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

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

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

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

                                        if -1.75e-93 < lambda1

                                        1. Initial program 67.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. Taylor expanded in lambda1 around 0 55.9%

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

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

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

                                            \[\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 - \color{blue}{\sin \left(-0.5 \cdot \phi_2\right) \cdot \sin \left(-0.5 \cdot \phi_2\right)}}}\right) \]
                                          2. 1-sub-sin31.8%

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

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

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

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

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

                                      Alternative 26: 27.9% accurate, 1.5× speedup?

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

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

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

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

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

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

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

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

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

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

                                      Alternative 27: 15.0% accurate, 1.7× speedup?

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

                                        1. Initial program 66.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                          if 1.71999999999999997e-153 < phi2

                                          1. Initial program 60.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                          Alternative 28: 16.2% accurate, 1.7× speedup?

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

                                            1. Initial program 65.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                              if 3.0000000000000003e-222 < phi2

                                              1. Initial program 63.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. associate-*l*63.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                              Alternative 29: 11.2% accurate, 1.7× speedup?

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

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

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

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

                                                \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\color{blue}{\sin \left(-0.5 \cdot \phi_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(-0.5 \cdot \lambda_2\right)\right)}}\right) \]
                                              6. Final simplification10.6%

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

                                              Alternative 30: 11.3% accurate, 1.9× speedup?

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

                                                1. Initial program 64.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                  if 2.24999999999999998e-279 < phi2

                                                  1. Initial program 64.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                  Alternative 31: 8.5% accurate, 1.9× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                    Reproduce

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