Distance on a great circle

Percentage Accurate: 62.1% → 63.4%
Time: 39.5s
Alternatives: 15
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 15 alternatives:

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

Initial Program: 62.1% 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: 63.4% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2} + \cos \phi_2 \cdot \left(\cos \phi_1 \cdot {\left(\sin \left(\frac{\lambda_1}{2}\right) \cdot \cos \left(\frac{\lambda_2}{2}\right) - \cos \left(\frac{\lambda_1}{2}\right) \cdot \sin \left(\frac{\lambda_2}{2}\right)\right)}^{2}\right)}}{\sqrt{1 - \left({\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\right)}}\right)
\end{array}
\end{array}
Derivation
  1. Initial program 63.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. Add Preprocessing
  3. Step-by-step derivation
    1. lift-sin.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 63.0% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
t_0 := {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot -0.5\right)}^{2}\\
R \cdot \left(\tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(t\_0 \cdot \cos \phi_2, \cos \phi_1, {\left(\mathsf{fma}\left(\cos \left(-0.5 \cdot \phi_2\right), \sin \left(0.5 \cdot \phi_1\right), \sin \left(-0.5 \cdot \phi_2\right) \cdot \cos \left(-0.5 \cdot \phi_1\right)\right)\right)}^{2}\right)}}{\sqrt{1 - \mathsf{fma}\left(\cos \phi_2 \cdot \cos \phi_1, t\_0, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}} \cdot 2\right)
\end{array}
\end{array}
Derivation
  1. Initial program 63.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. Add Preprocessing
  3. Step-by-step derivation
    1. lift-sin.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 62.2% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \cos \phi_1\\
t_1 := {\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}^{2}\\
\tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(t\_1, t\_0, {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}{\sqrt{{\cos \left(\frac{\phi_1 - \phi_2}{-2}\right)}^{2} - t\_1 \cdot t\_0}} \cdot \left(R \cdot 2\right)
\end{array}
\end{array}
Derivation
  1. Initial program 63.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. Add Preprocessing
  3. Applied rewrites63.9%

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

Alternative 4: 62.1% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\cos \phi_2 \cdot \cos \phi_1, {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot -0.5\right)}^{2}, {\sin \left(\left(\phi_2 - \phi_1\right) \cdot -0.5\right)}^{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0}}{\sqrt{1 - t\_0}}\right)
\end{array}
\end{array}
Derivation
  1. Initial program 63.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. Add Preprocessing
  3. Taylor expanded in lambda1 around 0

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

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

Alternative 5: 62.8% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
t_0 := {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot -0.5\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\phi_1 \leq -8.5 \cdot 10^{-5} \lor \neg \left(\phi_1 \leq 2.75 \cdot 10^{-12}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left({\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}, \cos \phi_1, {\sin \left(0.5 \cdot \phi_1\right)}^{2}\right)}}{\sqrt{{\cos \left(-0.5 \cdot \phi_1\right)}^{2} - t\_0 \cdot \cos \phi_1}}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if phi1 < -8.500000000000001e-5 or 2.7500000000000002e-12 < phi1

    1. Initial program 46.3%

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

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

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

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

        \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\color{blue}{\mathsf{fma}\left({\sin \left(\frac{1}{2} \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}, \cos \phi_2, {\sin \left(\frac{-1}{2} \cdot \phi_2\right)}^{2}\right)}}}{\sqrt{{\cos \left(\frac{-1}{2} \cdot \phi_1\right)}^{2} - {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot \frac{-1}{2}\right)}^{2} \cdot \cos \phi_1}}\right) \]
      3. lower-pow.f64N/A

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

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

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

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

        \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left({\sin \left(\frac{1}{2} \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}, \color{blue}{\cos \phi_2}, {\sin \left(\frac{-1}{2} \cdot \phi_2\right)}^{2}\right)}}{\sqrt{{\cos \left(\frac{-1}{2} \cdot \phi_1\right)}^{2} - {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot \frac{-1}{2}\right)}^{2} \cdot \cos \phi_1}}\right) \]
      8. lower-pow.f64N/A

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

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

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

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

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

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

        \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\color{blue}{{\sin \left(\frac{1}{2} \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} \cdot \cos \phi_1} + {\sin \left(\frac{1}{2} \cdot \phi_1\right)}^{2}}}{\sqrt{{\cos \left(\frac{-1}{2} \cdot \phi_1\right)}^{2} - {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot \frac{-1}{2}\right)}^{2} \cdot \cos \phi_1}}\right) \]
      3. lower-fma.f64N/A

        \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\color{blue}{\mathsf{fma}\left({\sin \left(\frac{1}{2} \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}, \cos \phi_1, {\sin \left(\frac{1}{2} \cdot \phi_1\right)}^{2}\right)}}}{\sqrt{{\cos \left(\frac{-1}{2} \cdot \phi_1\right)}^{2} - {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot \frac{-1}{2}\right)}^{2} \cdot \cos \phi_1}}\right) \]
      4. lower-pow.f64N/A

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

        \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left({\color{blue}{\sin \left(\frac{1}{2} \cdot \left(\lambda_1 - \lambda_2\right)\right)}}^{2}, \cos \phi_1, {\sin \left(\frac{1}{2} \cdot \phi_1\right)}^{2}\right)}}{\sqrt{{\cos \left(\frac{-1}{2} \cdot \phi_1\right)}^{2} - {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot \frac{-1}{2}\right)}^{2} \cdot \cos \phi_1}}\right) \]
      6. lower-*.f64N/A

        \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left({\sin \color{blue}{\left(\frac{1}{2} \cdot \left(\lambda_1 - \lambda_2\right)\right)}}^{2}, \cos \phi_1, {\sin \left(\frac{1}{2} \cdot \phi_1\right)}^{2}\right)}}{\sqrt{{\cos \left(\frac{-1}{2} \cdot \phi_1\right)}^{2} - {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot \frac{-1}{2}\right)}^{2} \cdot \cos \phi_1}}\right) \]
      7. lower--.f64N/A

        \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left({\sin \left(\frac{1}{2} \cdot \color{blue}{\left(\lambda_1 - \lambda_2\right)}\right)}^{2}, \cos \phi_1, {\sin \left(\frac{1}{2} \cdot \phi_1\right)}^{2}\right)}}{\sqrt{{\cos \left(\frac{-1}{2} \cdot \phi_1\right)}^{2} - {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot \frac{-1}{2}\right)}^{2} \cdot \cos \phi_1}}\right) \]
      8. lower-cos.f64N/A

        \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left({\sin \left(\frac{1}{2} \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}, \color{blue}{\cos \phi_1}, {\sin \left(\frac{1}{2} \cdot \phi_1\right)}^{2}\right)}}{\sqrt{{\cos \left(\frac{-1}{2} \cdot \phi_1\right)}^{2} - {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot \frac{-1}{2}\right)}^{2} \cdot \cos \phi_1}}\right) \]
      9. lower-pow.f64N/A

        \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left({\sin \left(\frac{1}{2} \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}, \cos \phi_1, \color{blue}{{\sin \left(\frac{1}{2} \cdot \phi_1\right)}^{2}}\right)}}{\sqrt{{\cos \left(\frac{-1}{2} \cdot \phi_1\right)}^{2} - {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot \frac{-1}{2}\right)}^{2} \cdot \cos \phi_1}}\right) \]
      10. lower-sin.f64N/A

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

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

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

    if -8.500000000000001e-5 < phi1 < 2.7500000000000002e-12

    1. Initial program 79.5%

      \[R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}}{\sqrt{1 - \left({\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in phi1 around 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{\color{blue}{1 - \left(\cos \phi_2 \cdot {\sin \left(\frac{1}{2} \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} + {\sin \left(\frac{-1}{2} \cdot \phi_2\right)}^{2}\right)}}}\right) \]
    4. Applied rewrites79.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}{{\cos \left(0.5 \cdot \phi_2\right)}^{2} - {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot -0.5\right)}^{2} \cdot \cos \phi_2}}}\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification64.7%

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

Alternative 6: 62.4% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
t_0 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
t_1 := \cos \left(-0.5 \cdot \phi_1\right)\\
t_2 := t\_0 \cdot \cos \phi_1\\
\mathbf{if}\;\phi_2 \leq -4400 \lor \neg \left(\phi_2 \leq 1.32 \cdot 10^{-5}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(t\_0, \cos \phi_2, {\sin \left(-0.5 \cdot \phi_2\right)}^{2}\right)}}{\sqrt{\left(1 - {\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}^{2} \cdot \left(\cos \phi_2 \cdot \cos \phi_1\right)\right) - {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}\right)\\

\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\mathsf{fma}\left(t\_1, -0.5 \cdot \phi_2, \sin \left(0.5 \cdot \phi_1\right)\right)\right)}^{2} + t\_2}}{\sqrt{{t\_1}^{2} - t\_2}}\right)\\


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

    1. Initial program 50.5%

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

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

        \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\color{blue}{\sin \left(\frac{1}{2} \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 - \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. lower-*.f6414.1

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

      \[\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 - \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) \]
    6. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{1}{2} \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{\color{blue}{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. lift-+.f64N/A

        \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{1}{2} \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 - \color{blue}{\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. +-commutativeN/A

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

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

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

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

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

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

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

        \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\color{blue}{\mathsf{fma}\left({\sin \left(\frac{1}{2} \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}, \cos \phi_2, {\sin \left(\frac{-1}{2} \cdot \phi_2\right)}^{2}\right)}}}{\sqrt{\left(1 - {\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}^{2} \cdot \left(\cos \phi_2 \cdot \cos \phi_1\right)\right) - {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}\right) \]
      4. lower-pow.f64N/A

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

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

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

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

        \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left({\sin \left(\frac{1}{2} \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}, \color{blue}{\cos \phi_2}, {\sin \left(\frac{-1}{2} \cdot \phi_2\right)}^{2}\right)}}{\sqrt{\left(1 - {\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}^{2} \cdot \left(\cos \phi_2 \cdot \cos \phi_1\right)\right) - {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}\right) \]
      9. lower-pow.f64N/A

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

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

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

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

    if -4400 < phi2 < 1.32000000000000007e-5

    1. Initial program 78.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. Add Preprocessing
    3. Taylor expanded in phi2 around 0

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

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

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

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

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

        \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\mathsf{fma}\left(\color{blue}{\cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot \phi_1\right)\right)}, \frac{-1}{2} \cdot \phi_2, \sin \left(\frac{1}{2} \cdot \phi_1\right)\right)\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}}{\sqrt{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) \]
      6. lower-cos.f64N/A

        \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\mathsf{fma}\left(\color{blue}{\cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot \phi_1\right)\right)}, \frac{-1}{2} \cdot \phi_2, \sin \left(\frac{1}{2} \cdot \phi_1\right)\right)\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}}{\sqrt{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) \]
      7. distribute-lft-neg-inN/A

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

        \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\mathsf{fma}\left(\cos \left(\color{blue}{\frac{-1}{2}} \cdot \phi_1\right), \frac{-1}{2} \cdot \phi_2, \sin \left(\frac{1}{2} \cdot \phi_1\right)\right)\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}}{\sqrt{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) \]
      9. lower-*.f64N/A

        \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\mathsf{fma}\left(\cos \color{blue}{\left(\frac{-1}{2} \cdot \phi_1\right)}, \frac{-1}{2} \cdot \phi_2, \sin \left(\frac{1}{2} \cdot \phi_1\right)\right)\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}}{\sqrt{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) \]
      10. lower-*.f64N/A

        \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\mathsf{fma}\left(\cos \left(\frac{-1}{2} \cdot \phi_1\right), \color{blue}{\frac{-1}{2} \cdot \phi_2}, \sin \left(\frac{1}{2} \cdot \phi_1\right)\right)\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}}{\sqrt{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) \]
      11. lower-sin.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\mathsf{fma}\left(\cos \left(\frac{-1}{2} \cdot \phi_1\right), \frac{-1}{2} \cdot \phi_2, \sin \left(\frac{1}{2} \cdot \phi_1\right)\right)\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}}{\sqrt{{\color{blue}{\cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot \phi_1\right)\right)}}^{2} - \cos \phi_1 \cdot {\sin \left(\frac{1}{2} \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}}\right) \]
      10. distribute-lft-neg-inN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 53.5% accurate, 1.1× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if phi2 < -4400 or 7.2e45 < phi2

    1. Initial program 50.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. Add Preprocessing
    3. Taylor expanded in lambda2 around 0

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

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

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

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

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

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

          \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\left(\phi_2 - \phi_1\right) \cdot \frac{-1}{2}\right)}^{2}}}{\sqrt{1 - \left({\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)}\right)}}\right) \]
        4. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

      if -4400 < phi2 < 7.2e45

      1. Initial program 74.9%

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

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

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

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

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

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

          \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\mathsf{fma}\left(\color{blue}{\cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot \phi_1\right)\right)}, \frac{-1}{2} \cdot \phi_2, \sin \left(\frac{1}{2} \cdot \phi_1\right)\right)\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}}{\sqrt{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) \]
        6. lower-cos.f64N/A

          \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\mathsf{fma}\left(\color{blue}{\cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot \phi_1\right)\right)}, \frac{-1}{2} \cdot \phi_2, \sin \left(\frac{1}{2} \cdot \phi_1\right)\right)\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}}{\sqrt{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) \]
        7. distribute-lft-neg-inN/A

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

          \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\mathsf{fma}\left(\cos \left(\color{blue}{\frac{-1}{2}} \cdot \phi_1\right), \frac{-1}{2} \cdot \phi_2, \sin \left(\frac{1}{2} \cdot \phi_1\right)\right)\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}}{\sqrt{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) \]
        9. lower-*.f64N/A

          \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\mathsf{fma}\left(\cos \color{blue}{\left(\frac{-1}{2} \cdot \phi_1\right)}, \frac{-1}{2} \cdot \phi_2, \sin \left(\frac{1}{2} \cdot \phi_1\right)\right)\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}}{\sqrt{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) \]
        10. lower-*.f64N/A

          \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\mathsf{fma}\left(\cos \left(\frac{-1}{2} \cdot \phi_1\right), \color{blue}{\frac{-1}{2} \cdot \phi_2}, \sin \left(\frac{1}{2} \cdot \phi_1\right)\right)\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}}{\sqrt{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) \]
        11. lower-sin.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\mathsf{fma}\left(\cos \left(\frac{-1}{2} \cdot \phi_1\right), \frac{-1}{2} \cdot \phi_2, \sin \left(\frac{1}{2} \cdot \phi_1\right)\right)\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}}{\sqrt{{\color{blue}{\cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot \phi_1\right)\right)}}^{2} - \cos \phi_1 \cdot {\sin \left(\frac{1}{2} \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}}\right) \]
        10. distribute-lft-neg-inN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 8: 53.5% accurate, 1.2× speedup?

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

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

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

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

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

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

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

            \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\left(\phi_2 - \phi_1\right) \cdot \frac{-1}{2}\right)}^{2}}}{\sqrt{1 - \left({\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)}\right)}}\right) \]
          4. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

        if -0.13500000000000001 < phi2 < 7.79999999999999935e50

        1. Initial program 75.5%

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

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

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

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

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

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

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

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

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

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

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

      Alternative 9: 52.2% accurate, 1.2× speedup?

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

        1. Initial program 50.5%

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

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

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

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

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

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

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

              \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\left(\phi_2 - \phi_1\right) \cdot \frac{-1}{2}\right)}^{2}}}{\sqrt{1 - \left({\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)}\right)}}\right) \]
            4. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

          if -1.55e-7 < phi2 < 3.00000000000000023e46

          1. Initial program 76.1%

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

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

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

              \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\color{blue}{\mathsf{fma}\left({\sin \left(\frac{1}{2} \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}, \cos \phi_2, {\sin \left(\frac{-1}{2} \cdot \phi_2\right)}^{2}\right)}}}{\sqrt{{\cos \left(\frac{-1}{2} \cdot \phi_1\right)}^{2} - {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot \frac{-1}{2}\right)}^{2} \cdot \cos \phi_1}}\right) \]
            3. lower-pow.f64N/A

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

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

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

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

              \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left({\sin \left(\frac{1}{2} \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}, \color{blue}{\cos \phi_2}, {\sin \left(\frac{-1}{2} \cdot \phi_2\right)}^{2}\right)}}{\sqrt{{\cos \left(\frac{-1}{2} \cdot \phi_1\right)}^{2} - {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot \frac{-1}{2}\right)}^{2} \cdot \cos \phi_1}}\right) \]
            8. lower-pow.f64N/A

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

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

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

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

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

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

              \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\color{blue}{{\sin \left(\frac{1}{2} \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} \cdot \cos \phi_1} + {\sin \left(\frac{1}{2} \cdot \phi_1\right)}^{2}}}{\sqrt{{\cos \left(\frac{-1}{2} \cdot \phi_1\right)}^{2} - {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot \frac{-1}{2}\right)}^{2} \cdot \cos \phi_1}}\right) \]
            3. lower-fma.f64N/A

              \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\color{blue}{\mathsf{fma}\left({\sin \left(\frac{1}{2} \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}, \cos \phi_1, {\sin \left(\frac{1}{2} \cdot \phi_1\right)}^{2}\right)}}}{\sqrt{{\cos \left(\frac{-1}{2} \cdot \phi_1\right)}^{2} - {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot \frac{-1}{2}\right)}^{2} \cdot \cos \phi_1}}\right) \]
            4. lower-pow.f64N/A

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

              \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left({\color{blue}{\sin \left(\frac{1}{2} \cdot \left(\lambda_1 - \lambda_2\right)\right)}}^{2}, \cos \phi_1, {\sin \left(\frac{1}{2} \cdot \phi_1\right)}^{2}\right)}}{\sqrt{{\cos \left(\frac{-1}{2} \cdot \phi_1\right)}^{2} - {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot \frac{-1}{2}\right)}^{2} \cdot \cos \phi_1}}\right) \]
            6. lower-*.f64N/A

              \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left({\sin \color{blue}{\left(\frac{1}{2} \cdot \left(\lambda_1 - \lambda_2\right)\right)}}^{2}, \cos \phi_1, {\sin \left(\frac{1}{2} \cdot \phi_1\right)}^{2}\right)}}{\sqrt{{\cos \left(\frac{-1}{2} \cdot \phi_1\right)}^{2} - {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot \frac{-1}{2}\right)}^{2} \cdot \cos \phi_1}}\right) \]
            7. lower--.f64N/A

              \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left({\sin \left(\frac{1}{2} \cdot \color{blue}{\left(\lambda_1 - \lambda_2\right)}\right)}^{2}, \cos \phi_1, {\sin \left(\frac{1}{2} \cdot \phi_1\right)}^{2}\right)}}{\sqrt{{\cos \left(\frac{-1}{2} \cdot \phi_1\right)}^{2} - {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot \frac{-1}{2}\right)}^{2} \cdot \cos \phi_1}}\right) \]
            8. lower-cos.f64N/A

              \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left({\sin \left(\frac{1}{2} \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}, \color{blue}{\cos \phi_1}, {\sin \left(\frac{1}{2} \cdot \phi_1\right)}^{2}\right)}}{\sqrt{{\cos \left(\frac{-1}{2} \cdot \phi_1\right)}^{2} - {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot \frac{-1}{2}\right)}^{2} \cdot \cos \phi_1}}\right) \]
            9. lower-pow.f64N/A

              \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left({\sin \left(\frac{1}{2} \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}, \cos \phi_1, \color{blue}{{\sin \left(\frac{1}{2} \cdot \phi_1\right)}^{2}}\right)}}{\sqrt{{\cos \left(\frac{-1}{2} \cdot \phi_1\right)}^{2} - {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot \frac{-1}{2}\right)}^{2} \cdot \cos \phi_1}}\right) \]
            10. lower-sin.f64N/A

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

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

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

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

        Alternative 10: 30.4% accurate, 1.5× speedup?

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

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

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

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

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

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

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

              \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\left(\phi_2 - \phi_1\right) \cdot \frac{-1}{2}\right)}^{2}}}{\sqrt{1 - \left({\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)}\right)}}\right) \]
            4. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

          Alternative 11: 29.0% accurate, 1.5× speedup?

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

            1. Initial program 68.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              if 0.40000000000000002 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))

              1. Initial program 54.9%

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

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

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

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

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

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

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

                    \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\left(\phi_2 - \phi_1\right) \cdot \frac{-1}{2}\right)}^{2}}}{\sqrt{1 - \color{blue}{\mathsf{fma}\left({\sin \left(\frac{1}{2} \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}, \cos \phi_2, {\sin \left(\frac{-1}{2} \cdot \phi_2\right)}^{2}\right)}}}\right) \]
                  3. lower-pow.f64N/A

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

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

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

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

                    \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\left(\phi_2 - \phi_1\right) \cdot \frac{-1}{2}\right)}^{2}}}{\sqrt{1 - \mathsf{fma}\left({\sin \left(\frac{1}{2} \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}, \color{blue}{\cos \phi_2}, {\sin \left(\frac{-1}{2} \cdot \phi_2\right)}^{2}\right)}}\right) \]
                  8. lower-pow.f64N/A

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

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

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

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

              Alternative 12: 29.8% accurate, 1.5× speedup?

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

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

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

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

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

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

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

                    \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\left(\phi_2 - \phi_1\right) \cdot \frac{-1}{2}\right)}^{2}}}{\sqrt{1 - \color{blue}{\mathsf{fma}\left(\cos \phi_1 \cdot \cos \phi_2, {\sin \left(\frac{1}{2} \cdot \lambda_1\right)}^{2}, {\sin \left(\frac{1}{2} \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}}}\right) \]
                  3. *-commutativeN/A

                    \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\left(\phi_2 - \phi_1\right) \cdot \frac{-1}{2}\right)}^{2}}}{\sqrt{1 - \mathsf{fma}\left(\color{blue}{\cos \phi_2 \cdot \cos \phi_1}, {\sin \left(\frac{1}{2} \cdot \lambda_1\right)}^{2}, {\sin \left(\frac{1}{2} \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}}\right) \]
                  4. lower-*.f64N/A

                    \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\left(\phi_2 - \phi_1\right) \cdot \frac{-1}{2}\right)}^{2}}}{\sqrt{1 - \mathsf{fma}\left(\color{blue}{\cos \phi_2 \cdot \cos \phi_1}, {\sin \left(\frac{1}{2} \cdot \lambda_1\right)}^{2}, {\sin \left(\frac{1}{2} \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}}\right) \]
                  5. lower-cos.f64N/A

                    \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\left(\phi_2 - \phi_1\right) \cdot \frac{-1}{2}\right)}^{2}}}{\sqrt{1 - \mathsf{fma}\left(\color{blue}{\cos \phi_2} \cdot \cos \phi_1, {\sin \left(\frac{1}{2} \cdot \lambda_1\right)}^{2}, {\sin \left(\frac{1}{2} \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}}\right) \]
                  6. lower-cos.f64N/A

                    \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\left(\phi_2 - \phi_1\right) \cdot \frac{-1}{2}\right)}^{2}}}{\sqrt{1 - \mathsf{fma}\left(\cos \phi_2 \cdot \color{blue}{\cos \phi_1}, {\sin \left(\frac{1}{2} \cdot \lambda_1\right)}^{2}, {\sin \left(\frac{1}{2} \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}}\right) \]
                  7. lower-pow.f64N/A

                    \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\left(\phi_2 - \phi_1\right) \cdot \frac{-1}{2}\right)}^{2}}}{\sqrt{1 - \mathsf{fma}\left(\cos \phi_2 \cdot \cos \phi_1, \color{blue}{{\sin \left(\frac{1}{2} \cdot \lambda_1\right)}^{2}}, {\sin \left(\frac{1}{2} \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}}\right) \]
                  8. lower-sin.f64N/A

                    \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\left(\phi_2 - \phi_1\right) \cdot \frac{-1}{2}\right)}^{2}}}{\sqrt{1 - \mathsf{fma}\left(\cos \phi_2 \cdot \cos \phi_1, {\color{blue}{\sin \left(\frac{1}{2} \cdot \lambda_1\right)}}^{2}, {\sin \left(\frac{1}{2} \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}}\right) \]
                  9. lower-*.f64N/A

                    \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\left(\phi_2 - \phi_1\right) \cdot \frac{-1}{2}\right)}^{2}}}{\sqrt{1 - \mathsf{fma}\left(\cos \phi_2 \cdot \cos \phi_1, {\sin \color{blue}{\left(\frac{1}{2} \cdot \lambda_1\right)}}^{2}, {\sin \left(\frac{1}{2} \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}}\right) \]
                  10. lower-pow.f64N/A

                    \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\left(\phi_2 - \phi_1\right) \cdot \frac{-1}{2}\right)}^{2}}}{\sqrt{1 - \mathsf{fma}\left(\cos \phi_2 \cdot \cos \phi_1, {\sin \left(\frac{1}{2} \cdot \lambda_1\right)}^{2}, \color{blue}{{\sin \left(\frac{1}{2} \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}}\right)}}\right) \]
                  11. lower-sin.f64N/A

                    \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\left(\phi_2 - \phi_1\right) \cdot \frac{-1}{2}\right)}^{2}}}{\sqrt{1 - \mathsf{fma}\left(\cos \phi_2 \cdot \cos \phi_1, {\sin \left(\frac{1}{2} \cdot \lambda_1\right)}^{2}, {\color{blue}{\sin \left(\frac{1}{2} \cdot \left(\phi_1 - \phi_2\right)\right)}}^{2}\right)}}\right) \]
                  12. lower-*.f64N/A

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

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

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

                Alternative 13: 30.1% accurate, 1.7× speedup?

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

                  1. Initial program 48.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. Add Preprocessing
                  3. Taylor expanded in lambda2 around 0

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

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

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

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

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

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

                        \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\left(\phi_2 - \phi_1\right) \cdot \frac{-1}{2}\right)}^{2}}}{\sqrt{1 - \color{blue}{\mathsf{fma}\left({\sin \left(\frac{1}{2} \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}, \cos \phi_1, {\sin \left(\frac{1}{2} \cdot \phi_1\right)}^{2}\right)}}}\right) \]
                      3. lower-pow.f64N/A

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

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

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

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

                        \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\left(\phi_2 - \phi_1\right) \cdot \frac{-1}{2}\right)}^{2}}}{\sqrt{1 - \mathsf{fma}\left({\sin \left(\frac{1}{2} \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}, \color{blue}{\cos \phi_1}, {\sin \left(\frac{1}{2} \cdot \phi_1\right)}^{2}\right)}}\right) \]
                      8. lower-pow.f64N/A

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

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

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

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

                    if -7.7999999999999999e-6 < phi1 < 1.32e-30

                    1. Initial program 78.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. Add Preprocessing
                    3. Taylor expanded in lambda2 around 0

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

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

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

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

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

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

                          \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\left(\phi_2 - \phi_1\right) \cdot \frac{-1}{2}\right)}^{2}}}{\sqrt{1 - \color{blue}{\mathsf{fma}\left({\sin \left(\frac{1}{2} \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}, \cos \phi_2, {\sin \left(\frac{-1}{2} \cdot \phi_2\right)}^{2}\right)}}}\right) \]
                        3. lower-pow.f64N/A

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

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

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

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

                          \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\left(\phi_2 - \phi_1\right) \cdot \frac{-1}{2}\right)}^{2}}}{\sqrt{1 - \mathsf{fma}\left({\sin \left(\frac{1}{2} \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}, \color{blue}{\cos \phi_2}, {\sin \left(\frac{-1}{2} \cdot \phi_2\right)}^{2}\right)}}\right) \]
                        8. lower-pow.f64N/A

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

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

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

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

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

                    Alternative 14: 27.8% accurate, 1.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      Alternative 15: 25.3% accurate, 1.7× speedup?

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

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

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

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

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

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

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

                            \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\left(\phi_2 - \phi_1\right) \cdot \frac{-1}{2}\right)}^{2}}}{\sqrt{1 - \color{blue}{\mathsf{fma}\left({\sin \left(\frac{1}{2} \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}, \cos \phi_1, {\sin \left(\frac{1}{2} \cdot \phi_1\right)}^{2}\right)}}}\right) \]
                          3. lower-pow.f64N/A

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

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

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

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

                            \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\left(\phi_2 - \phi_1\right) \cdot \frac{-1}{2}\right)}^{2}}}{\sqrt{1 - \mathsf{fma}\left({\sin \left(\frac{1}{2} \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}, \color{blue}{\cos \phi_1}, {\sin \left(\frac{1}{2} \cdot \phi_1\right)}^{2}\right)}}\right) \]
                          8. lower-pow.f64N/A

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

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

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

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

                        Reproduce

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