Equirectangular approximation to distance on a great circle

Percentage Accurate: 59.1% → 99.8%
Time: 21.5s
Alternatives: 13
Speedup: 3.0×

Specification

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

\\
\begin{array}{l}
t_0 := \left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\\
R \cdot \sqrt{t_0 \cdot t_0 + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\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 13 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: 59.1% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := \left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\\
R \cdot \sqrt{t_0 \cdot t_0 + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)}
\end{array}
\end{array}

Alternative 1: 99.8% accurate, 0.6× speedup?

\[\begin{array}{l} \\ R \cdot \mathsf{hypot}\left(\frac{\cos \left(0.5 \cdot \phi_1\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \sin \left(0.5 \cdot \phi_1\right) \cdot \sin \left(\phi_2 \cdot 0.5\right)}{\frac{1}{\lambda_1 - \lambda_2}}, \phi_1 - \phi_2\right) \end{array} \]
(FPCore (R lambda1 lambda2 phi1 phi2)
 :precision binary64
 (*
  R
  (hypot
   (/
    (-
     (* (cos (* 0.5 phi1)) (cos (* phi2 0.5)))
     (* (sin (* 0.5 phi1)) (sin (* phi2 0.5))))
    (/ 1.0 (- lambda1 lambda2)))
   (- phi1 phi2))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	return R * hypot((((cos((0.5 * phi1)) * cos((phi2 * 0.5))) - (sin((0.5 * phi1)) * sin((phi2 * 0.5)))) / (1.0 / (lambda1 - lambda2))), (phi1 - phi2));
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	return R * Math.hypot((((Math.cos((0.5 * phi1)) * Math.cos((phi2 * 0.5))) - (Math.sin((0.5 * phi1)) * Math.sin((phi2 * 0.5)))) / (1.0 / (lambda1 - lambda2))), (phi1 - phi2));
}
def code(R, lambda1, lambda2, phi1, phi2):
	return R * math.hypot((((math.cos((0.5 * phi1)) * math.cos((phi2 * 0.5))) - (math.sin((0.5 * phi1)) * math.sin((phi2 * 0.5)))) / (1.0 / (lambda1 - lambda2))), (phi1 - phi2))
function code(R, lambda1, lambda2, phi1, phi2)
	return Float64(R * hypot(Float64(Float64(Float64(cos(Float64(0.5 * phi1)) * cos(Float64(phi2 * 0.5))) - Float64(sin(Float64(0.5 * phi1)) * sin(Float64(phi2 * 0.5)))) / Float64(1.0 / Float64(lambda1 - lambda2))), Float64(phi1 - phi2)))
end
function tmp = code(R, lambda1, lambda2, phi1, phi2)
	tmp = R * hypot((((cos((0.5 * phi1)) * cos((phi2 * 0.5))) - (sin((0.5 * phi1)) * sin((phi2 * 0.5)))) / (1.0 / (lambda1 - lambda2))), (phi1 - phi2));
end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[Sqrt[N[(N[(N[(N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 / N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2 + N[(phi1 - phi2), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
R \cdot \mathsf{hypot}\left(\frac{\cos \left(0.5 \cdot \phi_1\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \sin \left(0.5 \cdot \phi_1\right) \cdot \sin \left(\phi_2 \cdot 0.5\right)}{\frac{1}{\lambda_1 - \lambda_2}}, \phi_1 - \phi_2\right)
\end{array}
Derivation
  1. Initial program 65.3%

    \[R \cdot \sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)} \]
  2. Step-by-step derivation
    1. hypot-def95.7%

      \[\leadsto R \cdot \color{blue}{\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
  3. Simplified95.7%

    \[\leadsto \color{blue}{R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
  4. Step-by-step derivation
    1. *-commutative95.7%

      \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\cos \left(\frac{\phi_1 + \phi_2}{2}\right) \cdot \left(\lambda_1 - \lambda_2\right)}, \phi_1 - \phi_2\right) \]
    2. flip--71.3%

      \[\leadsto R \cdot \mathsf{hypot}\left(\cos \left(\frac{\phi_1 + \phi_2}{2}\right) \cdot \color{blue}{\frac{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}{\lambda_1 + \lambda_2}}, \phi_1 - \phi_2\right) \]
    3. associate-*r/71.3%

      \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\frac{\cos \left(\frac{\phi_1 + \phi_2}{2}\right) \cdot \left(\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2\right)}{\lambda_1 + \lambda_2}}, \phi_1 - \phi_2\right) \]
    4. associate-/l*71.2%

      \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\frac{\cos \left(\frac{\phi_1 + \phi_2}{2}\right)}{\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}}}, \phi_1 - \phi_2\right) \]
    5. div-inv71.2%

      \[\leadsto R \cdot \mathsf{hypot}\left(\frac{\cos \color{blue}{\left(\left(\phi_1 + \phi_2\right) \cdot \frac{1}{2}\right)}}{\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}}, \phi_1 - \phi_2\right) \]
    6. metadata-eval71.2%

      \[\leadsto R \cdot \mathsf{hypot}\left(\frac{\cos \left(\left(\phi_1 + \phi_2\right) \cdot \color{blue}{0.5}\right)}{\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}}, \phi_1 - \phi_2\right) \]
    7. *-un-lft-identity71.2%

      \[\leadsto R \cdot \mathsf{hypot}\left(\frac{\cos \left(\left(\phi_1 + \phi_2\right) \cdot 0.5\right)}{\frac{\color{blue}{1 \cdot \left(\lambda_1 + \lambda_2\right)}}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}}, \phi_1 - \phi_2\right) \]
    8. associate-/l*71.3%

      \[\leadsto R \cdot \mathsf{hypot}\left(\frac{\cos \left(\left(\phi_1 + \phi_2\right) \cdot 0.5\right)}{\color{blue}{\frac{1}{\frac{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}{\lambda_1 + \lambda_2}}}}, \phi_1 - \phi_2\right) \]
    9. flip--95.7%

      \[\leadsto R \cdot \mathsf{hypot}\left(\frac{\cos \left(\left(\phi_1 + \phi_2\right) \cdot 0.5\right)}{\frac{1}{\color{blue}{\lambda_1 - \lambda_2}}}, \phi_1 - \phi_2\right) \]
  5. Applied egg-rr95.7%

    \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\frac{\cos \left(\left(\phi_1 + \phi_2\right) \cdot 0.5\right)}{\frac{1}{\lambda_1 - \lambda_2}}}, \phi_1 - \phi_2\right) \]
  6. Step-by-step derivation
    1. +-commutative95.7%

      \[\leadsto R \cdot \mathsf{hypot}\left(\frac{\cos \left(\color{blue}{\left(\phi_2 + \phi_1\right)} \cdot 0.5\right)}{\frac{1}{\lambda_1 - \lambda_2}}, \phi_1 - \phi_2\right) \]
    2. *-commutative95.7%

      \[\leadsto R \cdot \mathsf{hypot}\left(\frac{\cos \color{blue}{\left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)}}{\frac{1}{\lambda_1 - \lambda_2}}, \phi_1 - \phi_2\right) \]
    3. distribute-rgt-in95.7%

      \[\leadsto R \cdot \mathsf{hypot}\left(\frac{\cos \color{blue}{\left(\phi_2 \cdot 0.5 + \phi_1 \cdot 0.5\right)}}{\frac{1}{\lambda_1 - \lambda_2}}, \phi_1 - \phi_2\right) \]
    4. cos-sum99.8%

      \[\leadsto R \cdot \mathsf{hypot}\left(\frac{\color{blue}{\cos \left(\phi_2 \cdot 0.5\right) \cdot \cos \left(\phi_1 \cdot 0.5\right) - \sin \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right)}}{\frac{1}{\lambda_1 - \lambda_2}}, \phi_1 - \phi_2\right) \]
  7. Applied egg-rr99.8%

    \[\leadsto R \cdot \mathsf{hypot}\left(\frac{\color{blue}{\cos \left(\phi_2 \cdot 0.5\right) \cdot \cos \left(\phi_1 \cdot 0.5\right) - \sin \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right)}}{\frac{1}{\lambda_1 - \lambda_2}}, \phi_1 - \phi_2\right) \]
  8. Final simplification99.8%

    \[\leadsto R \cdot \mathsf{hypot}\left(\frac{\cos \left(0.5 \cdot \phi_1\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \sin \left(0.5 \cdot \phi_1\right) \cdot \sin \left(\phi_2 \cdot 0.5\right)}{\frac{1}{\lambda_1 - \lambda_2}}, \phi_1 - \phi_2\right) \]

Alternative 2: 95.9% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\lambda_1 \leq -1 \cdot 10^{+124}:\\ \;\;\;\;R \cdot \mathsf{hypot}\left(\lambda_1 \cdot \left(\cos \left(0.5 \cdot \phi_1\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \sin \left(0.5 \cdot \phi_1\right) \cdot \sin \left(\phi_2 \cdot 0.5\right)\right), \phi_1 - \phi_2\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_2 + \phi_1}{2}\right), \phi_1 - \phi_2\right)\\ \end{array} \end{array} \]
(FPCore (R lambda1 lambda2 phi1 phi2)
 :precision binary64
 (if (<= lambda1 -1e+124)
   (*
    R
    (hypot
     (*
      lambda1
      (-
       (* (cos (* 0.5 phi1)) (cos (* phi2 0.5)))
       (* (sin (* 0.5 phi1)) (sin (* phi2 0.5)))))
     (- phi1 phi2)))
   (*
    R
    (hypot
     (* (- lambda1 lambda2) (cos (/ (+ phi2 phi1) 2.0)))
     (- phi1 phi2)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	double tmp;
	if (lambda1 <= -1e+124) {
		tmp = R * hypot((lambda1 * ((cos((0.5 * phi1)) * cos((phi2 * 0.5))) - (sin((0.5 * phi1)) * sin((phi2 * 0.5))))), (phi1 - phi2));
	} else {
		tmp = R * hypot(((lambda1 - lambda2) * cos(((phi2 + phi1) / 2.0))), (phi1 - phi2));
	}
	return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	double tmp;
	if (lambda1 <= -1e+124) {
		tmp = R * Math.hypot((lambda1 * ((Math.cos((0.5 * phi1)) * Math.cos((phi2 * 0.5))) - (Math.sin((0.5 * phi1)) * Math.sin((phi2 * 0.5))))), (phi1 - phi2));
	} else {
		tmp = R * Math.hypot(((lambda1 - lambda2) * Math.cos(((phi2 + phi1) / 2.0))), (phi1 - phi2));
	}
	return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2):
	tmp = 0
	if lambda1 <= -1e+124:
		tmp = R * math.hypot((lambda1 * ((math.cos((0.5 * phi1)) * math.cos((phi2 * 0.5))) - (math.sin((0.5 * phi1)) * math.sin((phi2 * 0.5))))), (phi1 - phi2))
	else:
		tmp = R * math.hypot(((lambda1 - lambda2) * math.cos(((phi2 + phi1) / 2.0))), (phi1 - phi2))
	return tmp
function code(R, lambda1, lambda2, phi1, phi2)
	tmp = 0.0
	if (lambda1 <= -1e+124)
		tmp = Float64(R * hypot(Float64(lambda1 * Float64(Float64(cos(Float64(0.5 * phi1)) * cos(Float64(phi2 * 0.5))) - Float64(sin(Float64(0.5 * phi1)) * sin(Float64(phi2 * 0.5))))), Float64(phi1 - phi2)));
	else
		tmp = Float64(R * hypot(Float64(Float64(lambda1 - lambda2) * cos(Float64(Float64(phi2 + phi1) / 2.0))), Float64(phi1 - phi2)));
	end
	return tmp
end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
	tmp = 0.0;
	if (lambda1 <= -1e+124)
		tmp = R * hypot((lambda1 * ((cos((0.5 * phi1)) * cos((phi2 * 0.5))) - (sin((0.5 * phi1)) * sin((phi2 * 0.5))))), (phi1 - phi2));
	else
		tmp = R * hypot(((lambda1 - lambda2) * cos(((phi2 + phi1) / 2.0))), (phi1 - phi2));
	end
	tmp_2 = tmp;
end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, -1e+124], N[(R * N[Sqrt[N[(lambda1 * N[(N[(N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2 + N[(phi1 - phi2), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], N[(R * N[Sqrt[N[(N[(lambda1 - lambda2), $MachinePrecision] * N[Cos[N[(N[(phi2 + phi1), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] ^ 2 + N[(phi1 - phi2), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -1 \cdot 10^{+124}:\\
\;\;\;\;R \cdot \mathsf{hypot}\left(\lambda_1 \cdot \left(\cos \left(0.5 \cdot \phi_1\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \sin \left(0.5 \cdot \phi_1\right) \cdot \sin \left(\phi_2 \cdot 0.5\right)\right), \phi_1 - \phi_2\right)\\

\mathbf{else}:\\
\;\;\;\;R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_2 + \phi_1}{2}\right), \phi_1 - \phi_2\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if lambda1 < -9.99999999999999948e123

    1. Initial program 45.7%

      \[R \cdot \sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)} \]
    2. Step-by-step derivation
      1. hypot-def91.3%

        \[\leadsto R \cdot \color{blue}{\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    3. Simplified91.3%

      \[\leadsto \color{blue}{R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    4. Step-by-step derivation
      1. *-commutative91.3%

        \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\cos \left(\frac{\phi_1 + \phi_2}{2}\right) \cdot \left(\lambda_1 - \lambda_2\right)}, \phi_1 - \phi_2\right) \]
      2. flip--32.7%

        \[\leadsto R \cdot \mathsf{hypot}\left(\cos \left(\frac{\phi_1 + \phi_2}{2}\right) \cdot \color{blue}{\frac{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}{\lambda_1 + \lambda_2}}, \phi_1 - \phi_2\right) \]
      3. associate-*r/32.7%

        \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\frac{\cos \left(\frac{\phi_1 + \phi_2}{2}\right) \cdot \left(\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2\right)}{\lambda_1 + \lambda_2}}, \phi_1 - \phi_2\right) \]
      4. associate-/l*32.7%

        \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\frac{\cos \left(\frac{\phi_1 + \phi_2}{2}\right)}{\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}}}, \phi_1 - \phi_2\right) \]
      5. div-inv32.7%

        \[\leadsto R \cdot \mathsf{hypot}\left(\frac{\cos \color{blue}{\left(\left(\phi_1 + \phi_2\right) \cdot \frac{1}{2}\right)}}{\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}}, \phi_1 - \phi_2\right) \]
      6. metadata-eval32.7%

        \[\leadsto R \cdot \mathsf{hypot}\left(\frac{\cos \left(\left(\phi_1 + \phi_2\right) \cdot \color{blue}{0.5}\right)}{\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}}, \phi_1 - \phi_2\right) \]
      7. *-un-lft-identity32.7%

        \[\leadsto R \cdot \mathsf{hypot}\left(\frac{\cos \left(\left(\phi_1 + \phi_2\right) \cdot 0.5\right)}{\frac{\color{blue}{1 \cdot \left(\lambda_1 + \lambda_2\right)}}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}}, \phi_1 - \phi_2\right) \]
      8. associate-/l*32.7%

        \[\leadsto R \cdot \mathsf{hypot}\left(\frac{\cos \left(\left(\phi_1 + \phi_2\right) \cdot 0.5\right)}{\color{blue}{\frac{1}{\frac{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}{\lambda_1 + \lambda_2}}}}, \phi_1 - \phi_2\right) \]
      9. flip--91.3%

        \[\leadsto R \cdot \mathsf{hypot}\left(\frac{\cos \left(\left(\phi_1 + \phi_2\right) \cdot 0.5\right)}{\frac{1}{\color{blue}{\lambda_1 - \lambda_2}}}, \phi_1 - \phi_2\right) \]
    5. Applied egg-rr91.3%

      \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\frac{\cos \left(\left(\phi_1 + \phi_2\right) \cdot 0.5\right)}{\frac{1}{\lambda_1 - \lambda_2}}}, \phi_1 - \phi_2\right) \]
    6. Step-by-step derivation
      1. +-commutative91.3%

        \[\leadsto R \cdot \mathsf{hypot}\left(\frac{\cos \left(\color{blue}{\left(\phi_2 + \phi_1\right)} \cdot 0.5\right)}{\frac{1}{\lambda_1 - \lambda_2}}, \phi_1 - \phi_2\right) \]
      2. *-commutative91.3%

        \[\leadsto R \cdot \mathsf{hypot}\left(\frac{\cos \color{blue}{\left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)}}{\frac{1}{\lambda_1 - \lambda_2}}, \phi_1 - \phi_2\right) \]
      3. distribute-rgt-in91.3%

        \[\leadsto R \cdot \mathsf{hypot}\left(\frac{\cos \color{blue}{\left(\phi_2 \cdot 0.5 + \phi_1 \cdot 0.5\right)}}{\frac{1}{\lambda_1 - \lambda_2}}, \phi_1 - \phi_2\right) \]
      4. cos-sum99.7%

        \[\leadsto R \cdot \mathsf{hypot}\left(\frac{\color{blue}{\cos \left(\phi_2 \cdot 0.5\right) \cdot \cos \left(\phi_1 \cdot 0.5\right) - \sin \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right)}}{\frac{1}{\lambda_1 - \lambda_2}}, \phi_1 - \phi_2\right) \]
    7. Applied egg-rr99.7%

      \[\leadsto R \cdot \mathsf{hypot}\left(\frac{\color{blue}{\cos \left(\phi_2 \cdot 0.5\right) \cdot \cos \left(\phi_1 \cdot 0.5\right) - \sin \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right)}}{\frac{1}{\lambda_1 - \lambda_2}}, \phi_1 - \phi_2\right) \]
    8. Taylor expanded in lambda1 around inf 97.1%

      \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\lambda_1 \cdot \left(\cos \left(0.5 \cdot \phi_1\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \sin \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}, \phi_1 - \phi_2\right) \]

    if -9.99999999999999948e123 < lambda1

    1. Initial program 68.9%

      \[R \cdot \sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)} \]
    2. Step-by-step derivation
      1. hypot-def96.5%

        \[\leadsto R \cdot \color{blue}{\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    3. Simplified96.5%

      \[\leadsto \color{blue}{R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification96.6%

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

Alternative 3: 96.2% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\lambda_2 \leq 1.15 \cdot 10^{+257}:\\ \;\;\;\;R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_2 + \phi_1}{2}\right), \phi_1 - \phi_2\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \mathsf{hypot}\left(\lambda_2 \cdot \left(\sin \left(0.5 \cdot \phi_1\right) \cdot \sin \left(\phi_2 \cdot 0.5\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \cos \left(\phi_2 \cdot 0.5\right)\right), \phi_1 - \phi_2\right)\\ \end{array} \end{array} \]
(FPCore (R lambda1 lambda2 phi1 phi2)
 :precision binary64
 (if (<= lambda2 1.15e+257)
   (*
    R
    (hypot (* (- lambda1 lambda2) (cos (/ (+ phi2 phi1) 2.0))) (- phi1 phi2)))
   (*
    R
    (hypot
     (*
      lambda2
      (-
       (* (sin (* 0.5 phi1)) (sin (* phi2 0.5)))
       (* (cos (* 0.5 phi1)) (cos (* phi2 0.5)))))
     (- phi1 phi2)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	double tmp;
	if (lambda2 <= 1.15e+257) {
		tmp = R * hypot(((lambda1 - lambda2) * cos(((phi2 + phi1) / 2.0))), (phi1 - phi2));
	} else {
		tmp = R * hypot((lambda2 * ((sin((0.5 * phi1)) * sin((phi2 * 0.5))) - (cos((0.5 * phi1)) * cos((phi2 * 0.5))))), (phi1 - phi2));
	}
	return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	double tmp;
	if (lambda2 <= 1.15e+257) {
		tmp = R * Math.hypot(((lambda1 - lambda2) * Math.cos(((phi2 + phi1) / 2.0))), (phi1 - phi2));
	} else {
		tmp = R * Math.hypot((lambda2 * ((Math.sin((0.5 * phi1)) * Math.sin((phi2 * 0.5))) - (Math.cos((0.5 * phi1)) * Math.cos((phi2 * 0.5))))), (phi1 - phi2));
	}
	return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2):
	tmp = 0
	if lambda2 <= 1.15e+257:
		tmp = R * math.hypot(((lambda1 - lambda2) * math.cos(((phi2 + phi1) / 2.0))), (phi1 - phi2))
	else:
		tmp = R * math.hypot((lambda2 * ((math.sin((0.5 * phi1)) * math.sin((phi2 * 0.5))) - (math.cos((0.5 * phi1)) * math.cos((phi2 * 0.5))))), (phi1 - phi2))
	return tmp
function code(R, lambda1, lambda2, phi1, phi2)
	tmp = 0.0
	if (lambda2 <= 1.15e+257)
		tmp = Float64(R * hypot(Float64(Float64(lambda1 - lambda2) * cos(Float64(Float64(phi2 + phi1) / 2.0))), Float64(phi1 - phi2)));
	else
		tmp = Float64(R * hypot(Float64(lambda2 * Float64(Float64(sin(Float64(0.5 * phi1)) * sin(Float64(phi2 * 0.5))) - Float64(cos(Float64(0.5 * phi1)) * cos(Float64(phi2 * 0.5))))), Float64(phi1 - phi2)));
	end
	return tmp
end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
	tmp = 0.0;
	if (lambda2 <= 1.15e+257)
		tmp = R * hypot(((lambda1 - lambda2) * cos(((phi2 + phi1) / 2.0))), (phi1 - phi2));
	else
		tmp = R * hypot((lambda2 * ((sin((0.5 * phi1)) * sin((phi2 * 0.5))) - (cos((0.5 * phi1)) * cos((phi2 * 0.5))))), (phi1 - phi2));
	end
	tmp_2 = tmp;
end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda2, 1.15e+257], N[(R * N[Sqrt[N[(N[(lambda1 - lambda2), $MachinePrecision] * N[Cos[N[(N[(phi2 + phi1), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] ^ 2 + N[(phi1 - phi2), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], N[(R * N[Sqrt[N[(lambda2 * N[(N[(N[Sin[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2 + N[(phi1 - phi2), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq 1.15 \cdot 10^{+257}:\\
\;\;\;\;R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_2 + \phi_1}{2}\right), \phi_1 - \phi_2\right)\\

\mathbf{else}:\\
\;\;\;\;R \cdot \mathsf{hypot}\left(\lambda_2 \cdot \left(\sin \left(0.5 \cdot \phi_1\right) \cdot \sin \left(\phi_2 \cdot 0.5\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \cos \left(\phi_2 \cdot 0.5\right)\right), \phi_1 - \phi_2\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if lambda2 < 1.15e257

    1. Initial program 66.5%

      \[R \cdot \sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)} \]
    2. Step-by-step derivation
      1. hypot-def96.1%

        \[\leadsto R \cdot \color{blue}{\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    3. Simplified96.1%

      \[\leadsto \color{blue}{R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]

    if 1.15e257 < lambda2

    1. Initial program 42.2%

      \[R \cdot \sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)} \]
    2. Step-by-step derivation
      1. hypot-def88.4%

        \[\leadsto R \cdot \color{blue}{\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    3. Simplified88.4%

      \[\leadsto \color{blue}{R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    4. Step-by-step derivation
      1. *-commutative88.4%

        \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\cos \left(\frac{\phi_1 + \phi_2}{2}\right) \cdot \left(\lambda_1 - \lambda_2\right)}, \phi_1 - \phi_2\right) \]
      2. flip--26.5%

        \[\leadsto R \cdot \mathsf{hypot}\left(\cos \left(\frac{\phi_1 + \phi_2}{2}\right) \cdot \color{blue}{\frac{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}{\lambda_1 + \lambda_2}}, \phi_1 - \phi_2\right) \]
      3. associate-*r/26.5%

        \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\frac{\cos \left(\frac{\phi_1 + \phi_2}{2}\right) \cdot \left(\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2\right)}{\lambda_1 + \lambda_2}}, \phi_1 - \phi_2\right) \]
      4. associate-/l*26.5%

        \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\frac{\cos \left(\frac{\phi_1 + \phi_2}{2}\right)}{\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}}}, \phi_1 - \phi_2\right) \]
      5. div-inv26.5%

        \[\leadsto R \cdot \mathsf{hypot}\left(\frac{\cos \color{blue}{\left(\left(\phi_1 + \phi_2\right) \cdot \frac{1}{2}\right)}}{\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}}, \phi_1 - \phi_2\right) \]
      6. metadata-eval26.5%

        \[\leadsto R \cdot \mathsf{hypot}\left(\frac{\cos \left(\left(\phi_1 + \phi_2\right) \cdot \color{blue}{0.5}\right)}{\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}}, \phi_1 - \phi_2\right) \]
      7. *-un-lft-identity26.5%

        \[\leadsto R \cdot \mathsf{hypot}\left(\frac{\cos \left(\left(\phi_1 + \phi_2\right) \cdot 0.5\right)}{\frac{\color{blue}{1 \cdot \left(\lambda_1 + \lambda_2\right)}}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}}, \phi_1 - \phi_2\right) \]
      8. associate-/l*26.5%

        \[\leadsto R \cdot \mathsf{hypot}\left(\frac{\cos \left(\left(\phi_1 + \phi_2\right) \cdot 0.5\right)}{\color{blue}{\frac{1}{\frac{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}{\lambda_1 + \lambda_2}}}}, \phi_1 - \phi_2\right) \]
      9. flip--88.4%

        \[\leadsto R \cdot \mathsf{hypot}\left(\frac{\cos \left(\left(\phi_1 + \phi_2\right) \cdot 0.5\right)}{\frac{1}{\color{blue}{\lambda_1 - \lambda_2}}}, \phi_1 - \phi_2\right) \]
    5. Applied egg-rr88.4%

      \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\frac{\cos \left(\left(\phi_1 + \phi_2\right) \cdot 0.5\right)}{\frac{1}{\lambda_1 - \lambda_2}}}, \phi_1 - \phi_2\right) \]
    6. Step-by-step derivation
      1. +-commutative88.4%

        \[\leadsto R \cdot \mathsf{hypot}\left(\frac{\cos \left(\color{blue}{\left(\phi_2 + \phi_1\right)} \cdot 0.5\right)}{\frac{1}{\lambda_1 - \lambda_2}}, \phi_1 - \phi_2\right) \]
      2. *-commutative88.4%

        \[\leadsto R \cdot \mathsf{hypot}\left(\frac{\cos \color{blue}{\left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)}}{\frac{1}{\lambda_1 - \lambda_2}}, \phi_1 - \phi_2\right) \]
      3. distribute-rgt-in88.4%

        \[\leadsto R \cdot \mathsf{hypot}\left(\frac{\cos \color{blue}{\left(\phi_2 \cdot 0.5 + \phi_1 \cdot 0.5\right)}}{\frac{1}{\lambda_1 - \lambda_2}}, \phi_1 - \phi_2\right) \]
      4. cos-sum99.8%

        \[\leadsto R \cdot \mathsf{hypot}\left(\frac{\color{blue}{\cos \left(\phi_2 \cdot 0.5\right) \cdot \cos \left(\phi_1 \cdot 0.5\right) - \sin \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right)}}{\frac{1}{\lambda_1 - \lambda_2}}, \phi_1 - \phi_2\right) \]
    7. Applied egg-rr99.8%

      \[\leadsto R \cdot \mathsf{hypot}\left(\frac{\color{blue}{\cos \left(\phi_2 \cdot 0.5\right) \cdot \cos \left(\phi_1 \cdot 0.5\right) - \sin \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right)}}{\frac{1}{\lambda_1 - \lambda_2}}, \phi_1 - \phi_2\right) \]
    8. Taylor expanded in lambda1 around 0 99.9%

      \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{-1 \cdot \left(\lambda_2 \cdot \left(\cos \left(0.5 \cdot \phi_1\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \sin \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)\right)}, \phi_1 - \phi_2\right) \]
    9. Step-by-step derivation
      1. associate-*r*99.9%

        \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\left(-1 \cdot \lambda_2\right) \cdot \left(\cos \left(0.5 \cdot \phi_1\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \sin \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}, \phi_1 - \phi_2\right) \]
      2. neg-mul-199.9%

        \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\left(-\lambda_2\right)} \cdot \left(\cos \left(0.5 \cdot \phi_1\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \sin \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right), \phi_1 - \phi_2\right) \]
    10. Simplified99.9%

      \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\left(-\lambda_2\right) \cdot \left(\cos \left(0.5 \cdot \phi_1\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \sin \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}, \phi_1 - \phi_2\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification96.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\lambda_2 \leq 1.15 \cdot 10^{+257}:\\ \;\;\;\;R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_2 + \phi_1}{2}\right), \phi_1 - \phi_2\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \mathsf{hypot}\left(\lambda_2 \cdot \left(\sin \left(0.5 \cdot \phi_1\right) \cdot \sin \left(\phi_2 \cdot 0.5\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \cos \left(\phi_2 \cdot 0.5\right)\right), \phi_1 - \phi_2\right)\\ \end{array} \]

Alternative 4: 90.6% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\phi_2 \leq 0.019:\\ \;\;\;\;R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(0.5 \cdot \phi_1\right), \phi_1 - \phi_2\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \mathsf{hypot}\left(\lambda_2 \cdot \left(-\cos \left(\phi_2 \cdot 0.5\right)\right), \phi_1 - \phi_2\right)\\ \end{array} \end{array} \]
(FPCore (R lambda1 lambda2 phi1 phi2)
 :precision binary64
 (if (<= phi2 0.019)
   (* R (hypot (* (- lambda1 lambda2) (cos (* 0.5 phi1))) (- phi1 phi2)))
   (* R (hypot (* lambda2 (- (cos (* phi2 0.5)))) (- phi1 phi2)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	double tmp;
	if (phi2 <= 0.019) {
		tmp = R * hypot(((lambda1 - lambda2) * cos((0.5 * phi1))), (phi1 - phi2));
	} else {
		tmp = R * hypot((lambda2 * -cos((phi2 * 0.5))), (phi1 - phi2));
	}
	return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	double tmp;
	if (phi2 <= 0.019) {
		tmp = R * Math.hypot(((lambda1 - lambda2) * Math.cos((0.5 * phi1))), (phi1 - phi2));
	} else {
		tmp = R * Math.hypot((lambda2 * -Math.cos((phi2 * 0.5))), (phi1 - phi2));
	}
	return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2):
	tmp = 0
	if phi2 <= 0.019:
		tmp = R * math.hypot(((lambda1 - lambda2) * math.cos((0.5 * phi1))), (phi1 - phi2))
	else:
		tmp = R * math.hypot((lambda2 * -math.cos((phi2 * 0.5))), (phi1 - phi2))
	return tmp
function code(R, lambda1, lambda2, phi1, phi2)
	tmp = 0.0
	if (phi2 <= 0.019)
		tmp = Float64(R * hypot(Float64(Float64(lambda1 - lambda2) * cos(Float64(0.5 * phi1))), Float64(phi1 - phi2)));
	else
		tmp = Float64(R * hypot(Float64(lambda2 * Float64(-cos(Float64(phi2 * 0.5)))), Float64(phi1 - phi2)));
	end
	return tmp
end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
	tmp = 0.0;
	if (phi2 <= 0.019)
		tmp = R * hypot(((lambda1 - lambda2) * cos((0.5 * phi1))), (phi1 - phi2));
	else
		tmp = R * hypot((lambda2 * -cos((phi2 * 0.5))), (phi1 - phi2));
	end
	tmp_2 = tmp;
end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 0.019], N[(R * N[Sqrt[N[(N[(lambda1 - lambda2), $MachinePrecision] * N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] ^ 2 + N[(phi1 - phi2), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], N[(R * N[Sqrt[N[(lambda2 * (-N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] ^ 2 + N[(phi1 - phi2), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 0.019:\\
\;\;\;\;R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(0.5 \cdot \phi_1\right), \phi_1 - \phi_2\right)\\

\mathbf{else}:\\
\;\;\;\;R \cdot \mathsf{hypot}\left(\lambda_2 \cdot \left(-\cos \left(\phi_2 \cdot 0.5\right)\right), \phi_1 - \phi_2\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if phi2 < 0.0189999999999999995

    1. Initial program 68.9%

      \[R \cdot \sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)} \]
    2. Step-by-step derivation
      1. hypot-def95.4%

        \[\leadsto R \cdot \color{blue}{\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    3. Simplified95.4%

      \[\leadsto \color{blue}{R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    4. Taylor expanded in phi2 around 0 91.6%

      \[\leadsto R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{\cos \left(0.5 \cdot \phi_1\right)}, \phi_1 - \phi_2\right) \]

    if 0.0189999999999999995 < phi2

    1. Initial program 52.8%

      \[R \cdot \sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)} \]
    2. Step-by-step derivation
      1. hypot-def96.9%

        \[\leadsto R \cdot \color{blue}{\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    3. Simplified96.9%

      \[\leadsto \color{blue}{R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    4. Step-by-step derivation
      1. add-cbrt-cube96.8%

        \[\leadsto R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{\sqrt[3]{\left(\cos \left(\frac{\phi_1 + \phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)}}, \phi_1 - \phi_2\right) \]
      2. pow396.8%

        \[\leadsto R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \sqrt[3]{\color{blue}{{\cos \left(\frac{\phi_1 + \phi_2}{2}\right)}^{3}}}, \phi_1 - \phi_2\right) \]
      3. div-inv96.8%

        \[\leadsto R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \sqrt[3]{{\cos \color{blue}{\left(\left(\phi_1 + \phi_2\right) \cdot \frac{1}{2}\right)}}^{3}}, \phi_1 - \phi_2\right) \]
      4. metadata-eval96.8%

        \[\leadsto R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \sqrt[3]{{\cos \left(\left(\phi_1 + \phi_2\right) \cdot \color{blue}{0.5}\right)}^{3}}, \phi_1 - \phi_2\right) \]
    5. Applied egg-rr96.8%

      \[\leadsto R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{\sqrt[3]{{\cos \left(\left(\phi_1 + \phi_2\right) \cdot 0.5\right)}^{3}}}, \phi_1 - \phi_2\right) \]
    6. Taylor expanded in phi1 around 0 96.8%

      \[\leadsto R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \sqrt[3]{{\color{blue}{\cos \left(0.5 \cdot \phi_2\right)}}^{3}}, \phi_1 - \phi_2\right) \]
    7. Taylor expanded in lambda1 around 0 85.2%

      \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{-1 \cdot \left(\lambda_2 \cdot \cos \left(0.5 \cdot \phi_2\right)\right)}, \phi_1 - \phi_2\right) \]
    8. Step-by-step derivation
      1. mul-1-neg85.2%

        \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{-\lambda_2 \cdot \cos \left(0.5 \cdot \phi_2\right)}, \phi_1 - \phi_2\right) \]
      2. distribute-lft-neg-out85.2%

        \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\left(-\lambda_2\right) \cdot \cos \left(0.5 \cdot \phi_2\right)}, \phi_1 - \phi_2\right) \]
      3. *-commutative85.2%

        \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\cos \left(0.5 \cdot \phi_2\right) \cdot \left(-\lambda_2\right)}, \phi_1 - \phi_2\right) \]
    9. Simplified85.2%

      \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\cos \left(0.5 \cdot \phi_2\right) \cdot \left(-\lambda_2\right)}, \phi_1 - \phi_2\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification90.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\phi_2 \leq 0.019:\\ \;\;\;\;R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(0.5 \cdot \phi_1\right), \phi_1 - \phi_2\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \mathsf{hypot}\left(\lambda_2 \cdot \left(-\cos \left(\phi_2 \cdot 0.5\right)\right), \phi_1 - \phi_2\right)\\ \end{array} \]

Alternative 5: 93.0% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\phi_2 \leq 1.95 \cdot 10^{-8}:\\ \;\;\;\;R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(0.5 \cdot \phi_1\right), \phi_1 - \phi_2\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\phi_2 \cdot 0.5\right), \phi_1 - \phi_2\right)\\ \end{array} \end{array} \]
(FPCore (R lambda1 lambda2 phi1 phi2)
 :precision binary64
 (if (<= phi2 1.95e-8)
   (* R (hypot (* (- lambda1 lambda2) (cos (* 0.5 phi1))) (- phi1 phi2)))
   (* R (hypot (* (- lambda1 lambda2) (cos (* phi2 0.5))) (- phi1 phi2)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	double tmp;
	if (phi2 <= 1.95e-8) {
		tmp = R * hypot(((lambda1 - lambda2) * cos((0.5 * phi1))), (phi1 - phi2));
	} else {
		tmp = R * hypot(((lambda1 - lambda2) * cos((phi2 * 0.5))), (phi1 - phi2));
	}
	return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	double tmp;
	if (phi2 <= 1.95e-8) {
		tmp = R * Math.hypot(((lambda1 - lambda2) * Math.cos((0.5 * phi1))), (phi1 - phi2));
	} else {
		tmp = R * Math.hypot(((lambda1 - lambda2) * Math.cos((phi2 * 0.5))), (phi1 - phi2));
	}
	return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2):
	tmp = 0
	if phi2 <= 1.95e-8:
		tmp = R * math.hypot(((lambda1 - lambda2) * math.cos((0.5 * phi1))), (phi1 - phi2))
	else:
		tmp = R * math.hypot(((lambda1 - lambda2) * math.cos((phi2 * 0.5))), (phi1 - phi2))
	return tmp
function code(R, lambda1, lambda2, phi1, phi2)
	tmp = 0.0
	if (phi2 <= 1.95e-8)
		tmp = Float64(R * hypot(Float64(Float64(lambda1 - lambda2) * cos(Float64(0.5 * phi1))), Float64(phi1 - phi2)));
	else
		tmp = Float64(R * hypot(Float64(Float64(lambda1 - lambda2) * cos(Float64(phi2 * 0.5))), Float64(phi1 - phi2)));
	end
	return tmp
end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
	tmp = 0.0;
	if (phi2 <= 1.95e-8)
		tmp = R * hypot(((lambda1 - lambda2) * cos((0.5 * phi1))), (phi1 - phi2));
	else
		tmp = R * hypot(((lambda1 - lambda2) * cos((phi2 * 0.5))), (phi1 - phi2));
	end
	tmp_2 = tmp;
end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 1.95e-8], N[(R * N[Sqrt[N[(N[(lambda1 - lambda2), $MachinePrecision] * N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] ^ 2 + N[(phi1 - phi2), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], N[(R * N[Sqrt[N[(N[(lambda1 - lambda2), $MachinePrecision] * N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] ^ 2 + N[(phi1 - phi2), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 1.95 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(0.5 \cdot \phi_1\right), \phi_1 - \phi_2\right)\\

\mathbf{else}:\\
\;\;\;\;R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\phi_2 \cdot 0.5\right), \phi_1 - \phi_2\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if phi2 < 1.94999999999999992e-8

    1. Initial program 68.9%

      \[R \cdot \sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)} \]
    2. Step-by-step derivation
      1. hypot-def95.4%

        \[\leadsto R \cdot \color{blue}{\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    3. Simplified95.4%

      \[\leadsto \color{blue}{R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    4. Taylor expanded in phi2 around 0 91.6%

      \[\leadsto R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{\cos \left(0.5 \cdot \phi_1\right)}, \phi_1 - \phi_2\right) \]

    if 1.94999999999999992e-8 < phi2

    1. Initial program 52.8%

      \[R \cdot \sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)} \]
    2. Step-by-step derivation
      1. hypot-def96.9%

        \[\leadsto R \cdot \color{blue}{\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    3. Simplified96.9%

      \[\leadsto \color{blue}{R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    4. Taylor expanded in phi1 around 0 96.9%

      \[\leadsto R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{\cos \left(0.5 \cdot \phi_2\right)}, \phi_1 - \phi_2\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification92.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\phi_2 \leq 1.95 \cdot 10^{-8}:\\ \;\;\;\;R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(0.5 \cdot \phi_1\right), \phi_1 - \phi_2\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\phi_2 \cdot 0.5\right), \phi_1 - \phi_2\right)\\ \end{array} \]

Alternative 6: 95.9% accurate, 1.5× speedup?

\[\begin{array}{l} \\ R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_2 + \phi_1}{2}\right), \phi_1 - \phi_2\right) \end{array} \]
(FPCore (R lambda1 lambda2 phi1 phi2)
 :precision binary64
 (*
  R
  (hypot (* (- lambda1 lambda2) (cos (/ (+ phi2 phi1) 2.0))) (- phi1 phi2))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	return R * hypot(((lambda1 - lambda2) * cos(((phi2 + phi1) / 2.0))), (phi1 - phi2));
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	return R * Math.hypot(((lambda1 - lambda2) * Math.cos(((phi2 + phi1) / 2.0))), (phi1 - phi2));
}
def code(R, lambda1, lambda2, phi1, phi2):
	return R * math.hypot(((lambda1 - lambda2) * math.cos(((phi2 + phi1) / 2.0))), (phi1 - phi2))
function code(R, lambda1, lambda2, phi1, phi2)
	return Float64(R * hypot(Float64(Float64(lambda1 - lambda2) * cos(Float64(Float64(phi2 + phi1) / 2.0))), Float64(phi1 - phi2)))
end
function tmp = code(R, lambda1, lambda2, phi1, phi2)
	tmp = R * hypot(((lambda1 - lambda2) * cos(((phi2 + phi1) / 2.0))), (phi1 - phi2));
end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[Sqrt[N[(N[(lambda1 - lambda2), $MachinePrecision] * N[Cos[N[(N[(phi2 + phi1), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] ^ 2 + N[(phi1 - phi2), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_2 + \phi_1}{2}\right), \phi_1 - \phi_2\right)
\end{array}
Derivation
  1. Initial program 65.3%

    \[R \cdot \sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)} \]
  2. Step-by-step derivation
    1. hypot-def95.7%

      \[\leadsto R \cdot \color{blue}{\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
  3. Simplified95.7%

    \[\leadsto \color{blue}{R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
  4. Final simplification95.7%

    \[\leadsto R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_2 + \phi_1}{2}\right), \phi_1 - \phi_2\right) \]

Alternative 7: 80.8% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\lambda_1 \leq -2.2 \cdot 10^{-84}:\\ \;\;\;\;R \cdot \mathsf{hypot}\left(\lambda_1 - \lambda_2, \phi_1 - \phi_2\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \mathsf{hypot}\left(\lambda_2 \cdot \left(-\cos \left(\phi_2 \cdot 0.5\right)\right), \phi_1 - \phi_2\right)\\ \end{array} \end{array} \]
(FPCore (R lambda1 lambda2 phi1 phi2)
 :precision binary64
 (if (<= lambda1 -2.2e-84)
   (* R (hypot (- lambda1 lambda2) (- phi1 phi2)))
   (* R (hypot (* lambda2 (- (cos (* phi2 0.5)))) (- phi1 phi2)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	double tmp;
	if (lambda1 <= -2.2e-84) {
		tmp = R * hypot((lambda1 - lambda2), (phi1 - phi2));
	} else {
		tmp = R * hypot((lambda2 * -cos((phi2 * 0.5))), (phi1 - phi2));
	}
	return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	double tmp;
	if (lambda1 <= -2.2e-84) {
		tmp = R * Math.hypot((lambda1 - lambda2), (phi1 - phi2));
	} else {
		tmp = R * Math.hypot((lambda2 * -Math.cos((phi2 * 0.5))), (phi1 - phi2));
	}
	return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2):
	tmp = 0
	if lambda1 <= -2.2e-84:
		tmp = R * math.hypot((lambda1 - lambda2), (phi1 - phi2))
	else:
		tmp = R * math.hypot((lambda2 * -math.cos((phi2 * 0.5))), (phi1 - phi2))
	return tmp
function code(R, lambda1, lambda2, phi1, phi2)
	tmp = 0.0
	if (lambda1 <= -2.2e-84)
		tmp = Float64(R * hypot(Float64(lambda1 - lambda2), Float64(phi1 - phi2)));
	else
		tmp = Float64(R * hypot(Float64(lambda2 * Float64(-cos(Float64(phi2 * 0.5)))), Float64(phi1 - phi2)));
	end
	return tmp
end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
	tmp = 0.0;
	if (lambda1 <= -2.2e-84)
		tmp = R * hypot((lambda1 - lambda2), (phi1 - phi2));
	else
		tmp = R * hypot((lambda2 * -cos((phi2 * 0.5))), (phi1 - phi2));
	end
	tmp_2 = tmp;
end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, -2.2e-84], N[(R * N[Sqrt[N[(lambda1 - lambda2), $MachinePrecision] ^ 2 + N[(phi1 - phi2), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], N[(R * N[Sqrt[N[(lambda2 * (-N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] ^ 2 + N[(phi1 - phi2), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -2.2 \cdot 10^{-84}:\\
\;\;\;\;R \cdot \mathsf{hypot}\left(\lambda_1 - \lambda_2, \phi_1 - \phi_2\right)\\

\mathbf{else}:\\
\;\;\;\;R \cdot \mathsf{hypot}\left(\lambda_2 \cdot \left(-\cos \left(\phi_2 \cdot 0.5\right)\right), \phi_1 - \phi_2\right)\\


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

    1. Initial program 53.3%

      \[R \cdot \sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)} \]
    2. Step-by-step derivation
      1. hypot-def94.0%

        \[\leadsto R \cdot \color{blue}{\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    3. Simplified94.0%

      \[\leadsto \color{blue}{R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    4. Step-by-step derivation
      1. add-cbrt-cube93.9%

        \[\leadsto R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{\sqrt[3]{\left(\cos \left(\frac{\phi_1 + \phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)}}, \phi_1 - \phi_2\right) \]
      2. pow393.9%

        \[\leadsto R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \sqrt[3]{\color{blue}{{\cos \left(\frac{\phi_1 + \phi_2}{2}\right)}^{3}}}, \phi_1 - \phi_2\right) \]
      3. div-inv93.9%

        \[\leadsto R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \sqrt[3]{{\cos \color{blue}{\left(\left(\phi_1 + \phi_2\right) \cdot \frac{1}{2}\right)}}^{3}}, \phi_1 - \phi_2\right) \]
      4. metadata-eval93.9%

        \[\leadsto R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \sqrt[3]{{\cos \left(\left(\phi_1 + \phi_2\right) \cdot \color{blue}{0.5}\right)}^{3}}, \phi_1 - \phi_2\right) \]
    5. Applied egg-rr93.9%

      \[\leadsto R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{\sqrt[3]{{\cos \left(\left(\phi_1 + \phi_2\right) \cdot 0.5\right)}^{3}}}, \phi_1 - \phi_2\right) \]
    6. Taylor expanded in phi1 around 0 88.1%

      \[\leadsto R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \sqrt[3]{{\color{blue}{\cos \left(0.5 \cdot \phi_2\right)}}^{3}}, \phi_1 - \phi_2\right) \]
    7. Taylor expanded in phi2 around 0 82.1%

      \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\lambda_1 - \lambda_2}, \phi_1 - \phi_2\right) \]

    if -2.1999999999999999e-84 < lambda1

    1. Initial program 71.1%

      \[R \cdot \sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)} \]
    2. Step-by-step derivation
      1. hypot-def96.5%

        \[\leadsto R \cdot \color{blue}{\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    3. Simplified96.5%

      \[\leadsto \color{blue}{R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    4. Step-by-step derivation
      1. add-cbrt-cube96.5%

        \[\leadsto R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{\sqrt[3]{\left(\cos \left(\frac{\phi_1 + \phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)}}, \phi_1 - \phi_2\right) \]
      2. pow396.5%

        \[\leadsto R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \sqrt[3]{\color{blue}{{\cos \left(\frac{\phi_1 + \phi_2}{2}\right)}^{3}}}, \phi_1 - \phi_2\right) \]
      3. div-inv96.5%

        \[\leadsto R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \sqrt[3]{{\cos \color{blue}{\left(\left(\phi_1 + \phi_2\right) \cdot \frac{1}{2}\right)}}^{3}}, \phi_1 - \phi_2\right) \]
      4. metadata-eval96.5%

        \[\leadsto R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \sqrt[3]{{\cos \left(\left(\phi_1 + \phi_2\right) \cdot \color{blue}{0.5}\right)}^{3}}, \phi_1 - \phi_2\right) \]
    5. Applied egg-rr96.5%

      \[\leadsto R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{\sqrt[3]{{\cos \left(\left(\phi_1 + \phi_2\right) \cdot 0.5\right)}^{3}}}, \phi_1 - \phi_2\right) \]
    6. Taylor expanded in phi1 around 0 90.9%

      \[\leadsto R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \sqrt[3]{{\color{blue}{\cos \left(0.5 \cdot \phi_2\right)}}^{3}}, \phi_1 - \phi_2\right) \]
    7. Taylor expanded in lambda1 around 0 77.2%

      \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{-1 \cdot \left(\lambda_2 \cdot \cos \left(0.5 \cdot \phi_2\right)\right)}, \phi_1 - \phi_2\right) \]
    8. Step-by-step derivation
      1. mul-1-neg77.2%

        \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{-\lambda_2 \cdot \cos \left(0.5 \cdot \phi_2\right)}, \phi_1 - \phi_2\right) \]
      2. distribute-lft-neg-out77.2%

        \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\left(-\lambda_2\right) \cdot \cos \left(0.5 \cdot \phi_2\right)}, \phi_1 - \phi_2\right) \]
      3. *-commutative77.2%

        \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\cos \left(0.5 \cdot \phi_2\right) \cdot \left(-\lambda_2\right)}, \phi_1 - \phi_2\right) \]
    9. Simplified77.2%

      \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\cos \left(0.5 \cdot \phi_2\right) \cdot \left(-\lambda_2\right)}, \phi_1 - \phi_2\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification78.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\lambda_1 \leq -2.2 \cdot 10^{-84}:\\ \;\;\;\;R \cdot \mathsf{hypot}\left(\lambda_1 - \lambda_2, \phi_1 - \phi_2\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \mathsf{hypot}\left(\lambda_2 \cdot \left(-\cos \left(\phi_2 \cdot 0.5\right)\right), \phi_1 - \phi_2\right)\\ \end{array} \]

Alternative 8: 34.6% accurate, 3.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := R \cdot \left(\phi_2 - \phi_1\right)\\ \mathbf{if}\;\lambda_2 \leq 6.5 \cdot 10^{+126}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\lambda_2 \leq 5 \cdot 10^{+154}:\\ \;\;\;\;\lambda_2 \cdot \left(R \cdot \cos \left(\phi_2 \cdot 0.5\right)\right)\\ \mathbf{elif}\;\lambda_2 \leq 1.85 \cdot 10^{+183}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;R \cdot \lambda_2\\ \end{array} \end{array} \]
(FPCore (R lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (* R (- phi2 phi1))))
   (if (<= lambda2 6.5e+126)
     t_0
     (if (<= lambda2 5e+154)
       (* lambda2 (* R (cos (* phi2 0.5))))
       (if (<= lambda2 1.85e+183) t_0 (* R lambda2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = R * (phi2 - phi1);
	double tmp;
	if (lambda2 <= 6.5e+126) {
		tmp = t_0;
	} else if (lambda2 <= 5e+154) {
		tmp = lambda2 * (R * cos((phi2 * 0.5)));
	} else if (lambda2 <= 1.85e+183) {
		tmp = t_0;
	} else {
		tmp = R * lambda2;
	}
	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 = r * (phi2 - phi1)
    if (lambda2 <= 6.5d+126) then
        tmp = t_0
    else if (lambda2 <= 5d+154) then
        tmp = lambda2 * (r * cos((phi2 * 0.5d0)))
    else if (lambda2 <= 1.85d+183) then
        tmp = t_0
    else
        tmp = r * lambda2
    end if
    code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = R * (phi2 - phi1);
	double tmp;
	if (lambda2 <= 6.5e+126) {
		tmp = t_0;
	} else if (lambda2 <= 5e+154) {
		tmp = lambda2 * (R * Math.cos((phi2 * 0.5)));
	} else if (lambda2 <= 1.85e+183) {
		tmp = t_0;
	} else {
		tmp = R * lambda2;
	}
	return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2):
	t_0 = R * (phi2 - phi1)
	tmp = 0
	if lambda2 <= 6.5e+126:
		tmp = t_0
	elif lambda2 <= 5e+154:
		tmp = lambda2 * (R * math.cos((phi2 * 0.5)))
	elif lambda2 <= 1.85e+183:
		tmp = t_0
	else:
		tmp = R * lambda2
	return tmp
function code(R, lambda1, lambda2, phi1, phi2)
	t_0 = Float64(R * Float64(phi2 - phi1))
	tmp = 0.0
	if (lambda2 <= 6.5e+126)
		tmp = t_0;
	elseif (lambda2 <= 5e+154)
		tmp = Float64(lambda2 * Float64(R * cos(Float64(phi2 * 0.5))));
	elseif (lambda2 <= 1.85e+183)
		tmp = t_0;
	else
		tmp = Float64(R * lambda2);
	end
	return tmp
end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
	t_0 = R * (phi2 - phi1);
	tmp = 0.0;
	if (lambda2 <= 6.5e+126)
		tmp = t_0;
	elseif (lambda2 <= 5e+154)
		tmp = lambda2 * (R * cos((phi2 * 0.5)));
	elseif (lambda2 <= 1.85e+183)
		tmp = t_0;
	else
		tmp = R * lambda2;
	end
	tmp_2 = tmp;
end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(R * N[(phi2 - phi1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, 6.5e+126], t$95$0, If[LessEqual[lambda2, 5e+154], N[(lambda2 * N[(R * N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda2, 1.85e+183], t$95$0, N[(R * lambda2), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := R \cdot \left(\phi_2 - \phi_1\right)\\
\mathbf{if}\;\lambda_2 \leq 6.5 \cdot 10^{+126}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;\lambda_2 \leq 5 \cdot 10^{+154}:\\
\;\;\;\;\lambda_2 \cdot \left(R \cdot \cos \left(\phi_2 \cdot 0.5\right)\right)\\

\mathbf{elif}\;\lambda_2 \leq 1.85 \cdot 10^{+183}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;R \cdot \lambda_2\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if lambda2 < 6.5000000000000005e126 or 5.00000000000000004e154 < lambda2 < 1.8500000000000001e183

    1. Initial program 68.5%

      \[R \cdot \sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)} \]
    2. Step-by-step derivation
      1. hypot-def96.3%

        \[\leadsto R \cdot \color{blue}{\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    3. Simplified96.3%

      \[\leadsto \color{blue}{R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    4. Taylor expanded in phi1 around -inf 26.5%

      \[\leadsto R \cdot \color{blue}{\left(\phi_2 + -1 \cdot \phi_1\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg26.5%

        \[\leadsto R \cdot \left(\phi_2 + \color{blue}{\left(-\phi_1\right)}\right) \]
    6. Simplified26.5%

      \[\leadsto R \cdot \color{blue}{\left(\phi_2 + \left(-\phi_1\right)\right)} \]
    7. Taylor expanded in R around 0 26.5%

      \[\leadsto \color{blue}{R \cdot \left(\phi_2 - \phi_1\right)} \]

    if 6.5000000000000005e126 < lambda2 < 5.00000000000000004e154

    1. Initial program 62.9%

      \[R \cdot \sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)} \]
    2. Step-by-step derivation
      1. hypot-def85.5%

        \[\leadsto R \cdot \color{blue}{\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    3. Simplified85.5%

      \[\leadsto \color{blue}{R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    4. Taylor expanded in lambda2 around inf 63.2%

      \[\leadsto \color{blue}{R \cdot \left(\lambda_2 \cdot \cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)\right)} \]
    5. Step-by-step derivation
      1. *-commutative63.2%

        \[\leadsto \color{blue}{\left(\lambda_2 \cdot \cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)\right) \cdot R} \]
      2. +-commutative63.2%

        \[\leadsto \left(\lambda_2 \cdot \cos \left(0.5 \cdot \color{blue}{\left(\phi_2 + \phi_1\right)}\right)\right) \cdot R \]
    6. Simplified63.2%

      \[\leadsto \color{blue}{\left(\lambda_2 \cdot \cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)\right) \cdot R} \]
    7. Step-by-step derivation
      1. add-exp-log39.0%

        \[\leadsto \color{blue}{e^{\log \left(\left(\lambda_2 \cdot \cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)\right) \cdot R\right)}} \]
      2. *-commutative39.0%

        \[\leadsto e^{\log \left(\color{blue}{\left(\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right) \cdot \lambda_2\right)} \cdot R\right)} \]
      3. *-commutative39.0%

        \[\leadsto e^{\log \left(\left(\cos \color{blue}{\left(\left(\phi_2 + \phi_1\right) \cdot 0.5\right)} \cdot \lambda_2\right) \cdot R\right)} \]
      4. +-commutative39.0%

        \[\leadsto e^{\log \left(\left(\cos \left(\color{blue}{\left(\phi_1 + \phi_2\right)} \cdot 0.5\right) \cdot \lambda_2\right) \cdot R\right)} \]
      5. associate-*l*39.0%

        \[\leadsto e^{\log \color{blue}{\left(\cos \left(\left(\phi_1 + \phi_2\right) \cdot 0.5\right) \cdot \left(\lambda_2 \cdot R\right)\right)}} \]
      6. +-commutative39.0%

        \[\leadsto e^{\log \left(\cos \left(\color{blue}{\left(\phi_2 + \phi_1\right)} \cdot 0.5\right) \cdot \left(\lambda_2 \cdot R\right)\right)} \]
      7. *-commutative39.0%

        \[\leadsto e^{\log \left(\cos \color{blue}{\left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)} \cdot \left(\lambda_2 \cdot R\right)\right)} \]
      8. +-commutative39.0%

        \[\leadsto e^{\log \left(\cos \left(0.5 \cdot \color{blue}{\left(\phi_1 + \phi_2\right)}\right) \cdot \left(\lambda_2 \cdot R\right)\right)} \]
    8. Applied egg-rr39.0%

      \[\leadsto \color{blue}{e^{\log \left(\cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right) \cdot \left(\lambda_2 \cdot R\right)\right)}} \]
    9. Taylor expanded in phi1 around 0 38.5%

      \[\leadsto e^{\color{blue}{\log \left(R \cdot \left(\lambda_2 \cdot \cos \left(0.5 \cdot \phi_2\right)\right)\right)}} \]
    10. Step-by-step derivation
      1. add-exp-log62.8%

        \[\leadsto \color{blue}{R \cdot \left(\lambda_2 \cdot \cos \left(0.5 \cdot \phi_2\right)\right)} \]
      2. *-commutative62.8%

        \[\leadsto R \cdot \color{blue}{\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \lambda_2\right)} \]
      3. associate-*r*62.8%

        \[\leadsto \color{blue}{\left(R \cdot \cos \left(0.5 \cdot \phi_2\right)\right) \cdot \lambda_2} \]
    11. Applied egg-rr62.8%

      \[\leadsto \color{blue}{\left(R \cdot \cos \left(0.5 \cdot \phi_2\right)\right) \cdot \lambda_2} \]

    if 1.8500000000000001e183 < lambda2

    1. Initial program 36.9%

      \[R \cdot \sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)} \]
    2. Step-by-step derivation
      1. hypot-def93.6%

        \[\leadsto R \cdot \color{blue}{\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    3. Simplified93.6%

      \[\leadsto \color{blue}{R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    4. Taylor expanded in lambda2 around inf 68.6%

      \[\leadsto \color{blue}{R \cdot \left(\lambda_2 \cdot \cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)\right)} \]
    5. Step-by-step derivation
      1. *-commutative68.6%

        \[\leadsto \color{blue}{\left(\lambda_2 \cdot \cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)\right) \cdot R} \]
      2. +-commutative68.6%

        \[\leadsto \left(\lambda_2 \cdot \cos \left(0.5 \cdot \color{blue}{\left(\phi_2 + \phi_1\right)}\right)\right) \cdot R \]
    6. Simplified68.6%

      \[\leadsto \color{blue}{\left(\lambda_2 \cdot \cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)\right) \cdot R} \]
    7. Step-by-step derivation
      1. add-exp-log37.2%

        \[\leadsto \color{blue}{e^{\log \left(\left(\lambda_2 \cdot \cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)\right) \cdot R\right)}} \]
      2. *-commutative37.2%

        \[\leadsto e^{\log \left(\color{blue}{\left(\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right) \cdot \lambda_2\right)} \cdot R\right)} \]
      3. *-commutative37.2%

        \[\leadsto e^{\log \left(\left(\cos \color{blue}{\left(\left(\phi_2 + \phi_1\right) \cdot 0.5\right)} \cdot \lambda_2\right) \cdot R\right)} \]
      4. +-commutative37.2%

        \[\leadsto e^{\log \left(\left(\cos \left(\color{blue}{\left(\phi_1 + \phi_2\right)} \cdot 0.5\right) \cdot \lambda_2\right) \cdot R\right)} \]
      5. associate-*l*37.2%

        \[\leadsto e^{\log \color{blue}{\left(\cos \left(\left(\phi_1 + \phi_2\right) \cdot 0.5\right) \cdot \left(\lambda_2 \cdot R\right)\right)}} \]
      6. +-commutative37.2%

        \[\leadsto e^{\log \left(\cos \left(\color{blue}{\left(\phi_2 + \phi_1\right)} \cdot 0.5\right) \cdot \left(\lambda_2 \cdot R\right)\right)} \]
      7. *-commutative37.2%

        \[\leadsto e^{\log \left(\cos \color{blue}{\left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)} \cdot \left(\lambda_2 \cdot R\right)\right)} \]
      8. +-commutative37.2%

        \[\leadsto e^{\log \left(\cos \left(0.5 \cdot \color{blue}{\left(\phi_1 + \phi_2\right)}\right) \cdot \left(\lambda_2 \cdot R\right)\right)} \]
    8. Applied egg-rr37.2%

      \[\leadsto \color{blue}{e^{\log \left(\cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right) \cdot \left(\lambda_2 \cdot R\right)\right)}} \]
    9. Taylor expanded in phi1 around 0 30.9%

      \[\leadsto e^{\color{blue}{\log \left(R \cdot \left(\lambda_2 \cdot \cos \left(0.5 \cdot \phi_2\right)\right)\right)}} \]
    10. Taylor expanded in phi2 around 0 66.2%

      \[\leadsto \color{blue}{R \cdot \lambda_2} \]
    11. Step-by-step derivation
      1. *-commutative66.2%

        \[\leadsto \color{blue}{\lambda_2 \cdot R} \]
    12. Simplified66.2%

      \[\leadsto \color{blue}{\lambda_2 \cdot R} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification31.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\lambda_2 \leq 6.5 \cdot 10^{+126}:\\ \;\;\;\;R \cdot \left(\phi_2 - \phi_1\right)\\ \mathbf{elif}\;\lambda_2 \leq 5 \cdot 10^{+154}:\\ \;\;\;\;\lambda_2 \cdot \left(R \cdot \cos \left(\phi_2 \cdot 0.5\right)\right)\\ \mathbf{elif}\;\lambda_2 \leq 1.85 \cdot 10^{+183}:\\ \;\;\;\;R \cdot \left(\phi_2 - \phi_1\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \lambda_2\\ \end{array} \]

Alternative 9: 85.3% accurate, 3.0× speedup?

\[\begin{array}{l} \\ R \cdot \mathsf{hypot}\left(\lambda_1 - \lambda_2, \phi_1 - \phi_2\right) \end{array} \]
(FPCore (R lambda1 lambda2 phi1 phi2)
 :precision binary64
 (* R (hypot (- lambda1 lambda2) (- phi1 phi2))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	return R * hypot((lambda1 - lambda2), (phi1 - phi2));
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	return R * Math.hypot((lambda1 - lambda2), (phi1 - phi2));
}
def code(R, lambda1, lambda2, phi1, phi2):
	return R * math.hypot((lambda1 - lambda2), (phi1 - phi2))
function code(R, lambda1, lambda2, phi1, phi2)
	return Float64(R * hypot(Float64(lambda1 - lambda2), Float64(phi1 - phi2)))
end
function tmp = code(R, lambda1, lambda2, phi1, phi2)
	tmp = R * hypot((lambda1 - lambda2), (phi1 - phi2));
end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[Sqrt[N[(lambda1 - lambda2), $MachinePrecision] ^ 2 + N[(phi1 - phi2), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
R \cdot \mathsf{hypot}\left(\lambda_1 - \lambda_2, \phi_1 - \phi_2\right)
\end{array}
Derivation
  1. Initial program 65.3%

    \[R \cdot \sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)} \]
  2. Step-by-step derivation
    1. hypot-def95.7%

      \[\leadsto R \cdot \color{blue}{\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
  3. Simplified95.7%

    \[\leadsto \color{blue}{R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
  4. Step-by-step derivation
    1. add-cbrt-cube95.6%

      \[\leadsto R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{\sqrt[3]{\left(\cos \left(\frac{\phi_1 + \phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)}}, \phi_1 - \phi_2\right) \]
    2. pow395.6%

      \[\leadsto R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \sqrt[3]{\color{blue}{{\cos \left(\frac{\phi_1 + \phi_2}{2}\right)}^{3}}}, \phi_1 - \phi_2\right) \]
    3. div-inv95.6%

      \[\leadsto R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \sqrt[3]{{\cos \color{blue}{\left(\left(\phi_1 + \phi_2\right) \cdot \frac{1}{2}\right)}}^{3}}, \phi_1 - \phi_2\right) \]
    4. metadata-eval95.6%

      \[\leadsto R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \sqrt[3]{{\cos \left(\left(\phi_1 + \phi_2\right) \cdot \color{blue}{0.5}\right)}^{3}}, \phi_1 - \phi_2\right) \]
  5. Applied egg-rr95.6%

    \[\leadsto R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{\sqrt[3]{{\cos \left(\left(\phi_1 + \phi_2\right) \cdot 0.5\right)}^{3}}}, \phi_1 - \phi_2\right) \]
  6. Taylor expanded in phi1 around 0 90.0%

    \[\leadsto R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \sqrt[3]{{\color{blue}{\cos \left(0.5 \cdot \phi_2\right)}}^{3}}, \phi_1 - \phi_2\right) \]
  7. Taylor expanded in phi2 around 0 84.5%

    \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\lambda_1 - \lambda_2}, \phi_1 - \phi_2\right) \]
  8. Final simplification84.5%

    \[\leadsto R \cdot \mathsf{hypot}\left(\lambda_1 - \lambda_2, \phi_1 - \phi_2\right) \]

Alternative 10: 34.7% accurate, 29.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\lambda_2 \leq 7 \cdot 10^{+120} \lor \neg \left(\lambda_2 \leq 6.5 \cdot 10^{+153}\right) \land \lambda_2 \leq 1.85 \cdot 10^{+183}:\\ \;\;\;\;R \cdot \left(\phi_2 - \phi_1\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \lambda_2\\ \end{array} \end{array} \]
(FPCore (R lambda1 lambda2 phi1 phi2)
 :precision binary64
 (if (or (<= lambda2 7e+120)
         (and (not (<= lambda2 6.5e+153)) (<= lambda2 1.85e+183)))
   (* R (- phi2 phi1))
   (* R lambda2)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	double tmp;
	if ((lambda2 <= 7e+120) || (!(lambda2 <= 6.5e+153) && (lambda2 <= 1.85e+183))) {
		tmp = R * (phi2 - phi1);
	} else {
		tmp = R * lambda2;
	}
	return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
    real(8), intent (in) :: r
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    real(8) :: tmp
    if ((lambda2 <= 7d+120) .or. (.not. (lambda2 <= 6.5d+153)) .and. (lambda2 <= 1.85d+183)) then
        tmp = r * (phi2 - phi1)
    else
        tmp = r * lambda2
    end if
    code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	double tmp;
	if ((lambda2 <= 7e+120) || (!(lambda2 <= 6.5e+153) && (lambda2 <= 1.85e+183))) {
		tmp = R * (phi2 - phi1);
	} else {
		tmp = R * lambda2;
	}
	return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2):
	tmp = 0
	if (lambda2 <= 7e+120) or (not (lambda2 <= 6.5e+153) and (lambda2 <= 1.85e+183)):
		tmp = R * (phi2 - phi1)
	else:
		tmp = R * lambda2
	return tmp
function code(R, lambda1, lambda2, phi1, phi2)
	tmp = 0.0
	if ((lambda2 <= 7e+120) || (!(lambda2 <= 6.5e+153) && (lambda2 <= 1.85e+183)))
		tmp = Float64(R * Float64(phi2 - phi1));
	else
		tmp = Float64(R * lambda2);
	end
	return tmp
end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
	tmp = 0.0;
	if ((lambda2 <= 7e+120) || (~((lambda2 <= 6.5e+153)) && (lambda2 <= 1.85e+183)))
		tmp = R * (phi2 - phi1);
	else
		tmp = R * lambda2;
	end
	tmp_2 = tmp;
end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[lambda2, 7e+120], And[N[Not[LessEqual[lambda2, 6.5e+153]], $MachinePrecision], LessEqual[lambda2, 1.85e+183]]], N[(R * N[(phi2 - phi1), $MachinePrecision]), $MachinePrecision], N[(R * lambda2), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq 7 \cdot 10^{+120} \lor \neg \left(\lambda_2 \leq 6.5 \cdot 10^{+153}\right) \land \lambda_2 \leq 1.85 \cdot 10^{+183}:\\
\;\;\;\;R \cdot \left(\phi_2 - \phi_1\right)\\

\mathbf{else}:\\
\;\;\;\;R \cdot \lambda_2\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if lambda2 < 7.00000000000000015e120 or 6.49999999999999972e153 < lambda2 < 1.8500000000000001e183

    1. Initial program 68.5%

      \[R \cdot \sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)} \]
    2. Step-by-step derivation
      1. hypot-def96.3%

        \[\leadsto R \cdot \color{blue}{\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    3. Simplified96.3%

      \[\leadsto \color{blue}{R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    4. Taylor expanded in phi1 around -inf 26.5%

      \[\leadsto R \cdot \color{blue}{\left(\phi_2 + -1 \cdot \phi_1\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg26.5%

        \[\leadsto R \cdot \left(\phi_2 + \color{blue}{\left(-\phi_1\right)}\right) \]
    6. Simplified26.5%

      \[\leadsto R \cdot \color{blue}{\left(\phi_2 + \left(-\phi_1\right)\right)} \]
    7. Taylor expanded in R around 0 26.5%

      \[\leadsto \color{blue}{R \cdot \left(\phi_2 - \phi_1\right)} \]

    if 7.00000000000000015e120 < lambda2 < 6.49999999999999972e153 or 1.8500000000000001e183 < lambda2

    1. Initial program 44.0%

      \[R \cdot \sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)} \]
    2. Step-by-step derivation
      1. hypot-def91.4%

        \[\leadsto R \cdot \color{blue}{\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    3. Simplified91.4%

      \[\leadsto \color{blue}{R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    4. Taylor expanded in lambda2 around inf 67.1%

      \[\leadsto \color{blue}{R \cdot \left(\lambda_2 \cdot \cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)\right)} \]
    5. Step-by-step derivation
      1. *-commutative67.1%

        \[\leadsto \color{blue}{\left(\lambda_2 \cdot \cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)\right) \cdot R} \]
      2. +-commutative67.1%

        \[\leadsto \left(\lambda_2 \cdot \cos \left(0.5 \cdot \color{blue}{\left(\phi_2 + \phi_1\right)}\right)\right) \cdot R \]
    6. Simplified67.1%

      \[\leadsto \color{blue}{\left(\lambda_2 \cdot \cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)\right) \cdot R} \]
    7. Step-by-step derivation
      1. add-exp-log37.7%

        \[\leadsto \color{blue}{e^{\log \left(\left(\lambda_2 \cdot \cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)\right) \cdot R\right)}} \]
      2. *-commutative37.7%

        \[\leadsto e^{\log \left(\color{blue}{\left(\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right) \cdot \lambda_2\right)} \cdot R\right)} \]
      3. *-commutative37.7%

        \[\leadsto e^{\log \left(\left(\cos \color{blue}{\left(\left(\phi_2 + \phi_1\right) \cdot 0.5\right)} \cdot \lambda_2\right) \cdot R\right)} \]
      4. +-commutative37.7%

        \[\leadsto e^{\log \left(\left(\cos \left(\color{blue}{\left(\phi_1 + \phi_2\right)} \cdot 0.5\right) \cdot \lambda_2\right) \cdot R\right)} \]
      5. associate-*l*37.7%

        \[\leadsto e^{\log \color{blue}{\left(\cos \left(\left(\phi_1 + \phi_2\right) \cdot 0.5\right) \cdot \left(\lambda_2 \cdot R\right)\right)}} \]
      6. +-commutative37.7%

        \[\leadsto e^{\log \left(\cos \left(\color{blue}{\left(\phi_2 + \phi_1\right)} \cdot 0.5\right) \cdot \left(\lambda_2 \cdot R\right)\right)} \]
      7. *-commutative37.7%

        \[\leadsto e^{\log \left(\cos \color{blue}{\left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)} \cdot \left(\lambda_2 \cdot R\right)\right)} \]
      8. +-commutative37.7%

        \[\leadsto e^{\log \left(\cos \left(0.5 \cdot \color{blue}{\left(\phi_1 + \phi_2\right)}\right) \cdot \left(\lambda_2 \cdot R\right)\right)} \]
    8. Applied egg-rr37.7%

      \[\leadsto \color{blue}{e^{\log \left(\cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right) \cdot \left(\lambda_2 \cdot R\right)\right)}} \]
    9. Taylor expanded in phi1 around 0 33.0%

      \[\leadsto e^{\color{blue}{\log \left(R \cdot \left(\lambda_2 \cdot \cos \left(0.5 \cdot \phi_2\right)\right)\right)}} \]
    10. Taylor expanded in phi2 around 0 64.4%

      \[\leadsto \color{blue}{R \cdot \lambda_2} \]
    11. Step-by-step derivation
      1. *-commutative64.4%

        \[\leadsto \color{blue}{\lambda_2 \cdot R} \]
    12. Simplified64.4%

      \[\leadsto \color{blue}{\lambda_2 \cdot R} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification31.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\lambda_2 \leq 7 \cdot 10^{+120} \lor \neg \left(\lambda_2 \leq 6.5 \cdot 10^{+153}\right) \land \lambda_2 \leq 1.85 \cdot 10^{+183}:\\ \;\;\;\;R \cdot \left(\phi_2 - \phi_1\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \lambda_2\\ \end{array} \]

Alternative 11: 27.9% accurate, 46.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\phi_2 \leq 7.5 \cdot 10^{-257}:\\ \;\;\;\;R \cdot \left(-\phi_1\right)\\ \mathbf{elif}\;\phi_2 \leq 5000000000:\\ \;\;\;\;R \cdot \lambda_2\\ \mathbf{else}:\\ \;\;\;\;R \cdot \phi_2\\ \end{array} \end{array} \]
(FPCore (R lambda1 lambda2 phi1 phi2)
 :precision binary64
 (if (<= phi2 7.5e-257)
   (* R (- phi1))
   (if (<= phi2 5000000000.0) (* R lambda2) (* R phi2))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	double tmp;
	if (phi2 <= 7.5e-257) {
		tmp = R * -phi1;
	} else if (phi2 <= 5000000000.0) {
		tmp = R * lambda2;
	} else {
		tmp = R * phi2;
	}
	return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
    real(8), intent (in) :: r
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    real(8) :: tmp
    if (phi2 <= 7.5d-257) then
        tmp = r * -phi1
    else if (phi2 <= 5000000000.0d0) then
        tmp = r * lambda2
    else
        tmp = r * phi2
    end if
    code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	double tmp;
	if (phi2 <= 7.5e-257) {
		tmp = R * -phi1;
	} else if (phi2 <= 5000000000.0) {
		tmp = R * lambda2;
	} else {
		tmp = R * phi2;
	}
	return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2):
	tmp = 0
	if phi2 <= 7.5e-257:
		tmp = R * -phi1
	elif phi2 <= 5000000000.0:
		tmp = R * lambda2
	else:
		tmp = R * phi2
	return tmp
function code(R, lambda1, lambda2, phi1, phi2)
	tmp = 0.0
	if (phi2 <= 7.5e-257)
		tmp = Float64(R * Float64(-phi1));
	elseif (phi2 <= 5000000000.0)
		tmp = Float64(R * lambda2);
	else
		tmp = Float64(R * phi2);
	end
	return tmp
end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
	tmp = 0.0;
	if (phi2 <= 7.5e-257)
		tmp = R * -phi1;
	elseif (phi2 <= 5000000000.0)
		tmp = R * lambda2;
	else
		tmp = R * phi2;
	end
	tmp_2 = tmp;
end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 7.5e-257], N[(R * (-phi1)), $MachinePrecision], If[LessEqual[phi2, 5000000000.0], N[(R * lambda2), $MachinePrecision], N[(R * phi2), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 7.5 \cdot 10^{-257}:\\
\;\;\;\;R \cdot \left(-\phi_1\right)\\

\mathbf{elif}\;\phi_2 \leq 5000000000:\\
\;\;\;\;R \cdot \lambda_2\\

\mathbf{else}:\\
\;\;\;\;R \cdot \phi_2\\


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

    1. Initial program 68.4%

      \[R \cdot \sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)} \]
    2. Step-by-step derivation
      1. hypot-def93.8%

        \[\leadsto R \cdot \color{blue}{\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    3. Simplified93.8%

      \[\leadsto \color{blue}{R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    4. Taylor expanded in phi1 around -inf 13.3%

      \[\leadsto \color{blue}{-1 \cdot \left(R \cdot \phi_1\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg13.3%

        \[\leadsto \color{blue}{-R \cdot \phi_1} \]
      2. *-commutative13.3%

        \[\leadsto -\color{blue}{\phi_1 \cdot R} \]
      3. distribute-rgt-neg-in13.3%

        \[\leadsto \color{blue}{\phi_1 \cdot \left(-R\right)} \]
    6. Simplified13.3%

      \[\leadsto \color{blue}{\phi_1 \cdot \left(-R\right)} \]

    if 7.4999999999999995e-257 < phi2 < 5e9

    1. Initial program 68.5%

      \[R \cdot \sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)} \]
    2. Step-by-step derivation
      1. hypot-def99.9%

        \[\leadsto R \cdot \color{blue}{\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    4. Taylor expanded in lambda2 around inf 29.8%

      \[\leadsto \color{blue}{R \cdot \left(\lambda_2 \cdot \cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)\right)} \]
    5. Step-by-step derivation
      1. *-commutative29.8%

        \[\leadsto \color{blue}{\left(\lambda_2 \cdot \cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)\right) \cdot R} \]
      2. +-commutative29.8%

        \[\leadsto \left(\lambda_2 \cdot \cos \left(0.5 \cdot \color{blue}{\left(\phi_2 + \phi_1\right)}\right)\right) \cdot R \]
    6. Simplified29.8%

      \[\leadsto \color{blue}{\left(\lambda_2 \cdot \cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)\right) \cdot R} \]
    7. Step-by-step derivation
      1. add-exp-log13.7%

        \[\leadsto \color{blue}{e^{\log \left(\left(\lambda_2 \cdot \cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)\right) \cdot R\right)}} \]
      2. *-commutative13.7%

        \[\leadsto e^{\log \left(\color{blue}{\left(\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right) \cdot \lambda_2\right)} \cdot R\right)} \]
      3. *-commutative13.7%

        \[\leadsto e^{\log \left(\left(\cos \color{blue}{\left(\left(\phi_2 + \phi_1\right) \cdot 0.5\right)} \cdot \lambda_2\right) \cdot R\right)} \]
      4. +-commutative13.7%

        \[\leadsto e^{\log \left(\left(\cos \left(\color{blue}{\left(\phi_1 + \phi_2\right)} \cdot 0.5\right) \cdot \lambda_2\right) \cdot R\right)} \]
      5. associate-*l*13.7%

        \[\leadsto e^{\log \color{blue}{\left(\cos \left(\left(\phi_1 + \phi_2\right) \cdot 0.5\right) \cdot \left(\lambda_2 \cdot R\right)\right)}} \]
      6. +-commutative13.7%

        \[\leadsto e^{\log \left(\cos \left(\color{blue}{\left(\phi_2 + \phi_1\right)} \cdot 0.5\right) \cdot \left(\lambda_2 \cdot R\right)\right)} \]
      7. *-commutative13.7%

        \[\leadsto e^{\log \left(\cos \color{blue}{\left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)} \cdot \left(\lambda_2 \cdot R\right)\right)} \]
      8. +-commutative13.7%

        \[\leadsto e^{\log \left(\cos \left(0.5 \cdot \color{blue}{\left(\phi_1 + \phi_2\right)}\right) \cdot \left(\lambda_2 \cdot R\right)\right)} \]
    8. Applied egg-rr13.7%

      \[\leadsto \color{blue}{e^{\log \left(\cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right) \cdot \left(\lambda_2 \cdot R\right)\right)}} \]
    9. Taylor expanded in phi1 around 0 11.3%

      \[\leadsto e^{\color{blue}{\log \left(R \cdot \left(\lambda_2 \cdot \cos \left(0.5 \cdot \phi_2\right)\right)\right)}} \]
    10. Taylor expanded in phi2 around 0 22.6%

      \[\leadsto \color{blue}{R \cdot \lambda_2} \]
    11. Step-by-step derivation
      1. *-commutative22.6%

        \[\leadsto \color{blue}{\lambda_2 \cdot R} \]
    12. Simplified22.6%

      \[\leadsto \color{blue}{\lambda_2 \cdot R} \]

    if 5e9 < phi2

    1. Initial program 53.7%

      \[R \cdot \sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)} \]
    2. Step-by-step derivation
      1. hypot-def96.8%

        \[\leadsto R \cdot \color{blue}{\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    3. Simplified96.8%

      \[\leadsto \color{blue}{R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    4. Taylor expanded in phi2 around inf 56.8%

      \[\leadsto \color{blue}{R \cdot \phi_2} \]
    5. Step-by-step derivation
      1. *-commutative56.8%

        \[\leadsto \color{blue}{\phi_2 \cdot R} \]
    6. Simplified56.8%

      \[\leadsto \color{blue}{\phi_2 \cdot R} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification24.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\phi_2 \leq 7.5 \cdot 10^{-257}:\\ \;\;\;\;R \cdot \left(-\phi_1\right)\\ \mathbf{elif}\;\phi_2 \leq 5000000000:\\ \;\;\;\;R \cdot \lambda_2\\ \mathbf{else}:\\ \;\;\;\;R \cdot \phi_2\\ \end{array} \]

Alternative 12: 25.8% accurate, 65.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\phi_2 \leq 3900000000:\\ \;\;\;\;R \cdot \lambda_2\\ \mathbf{else}:\\ \;\;\;\;R \cdot \phi_2\\ \end{array} \end{array} \]
(FPCore (R lambda1 lambda2 phi1 phi2)
 :precision binary64
 (if (<= phi2 3900000000.0) (* R lambda2) (* R phi2)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	double tmp;
	if (phi2 <= 3900000000.0) {
		tmp = R * lambda2;
	} else {
		tmp = R * phi2;
	}
	return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
    real(8), intent (in) :: r
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    real(8) :: tmp
    if (phi2 <= 3900000000.0d0) then
        tmp = r * lambda2
    else
        tmp = r * phi2
    end if
    code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	double tmp;
	if (phi2 <= 3900000000.0) {
		tmp = R * lambda2;
	} else {
		tmp = R * phi2;
	}
	return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2):
	tmp = 0
	if phi2 <= 3900000000.0:
		tmp = R * lambda2
	else:
		tmp = R * phi2
	return tmp
function code(R, lambda1, lambda2, phi1, phi2)
	tmp = 0.0
	if (phi2 <= 3900000000.0)
		tmp = Float64(R * lambda2);
	else
		tmp = Float64(R * phi2);
	end
	return tmp
end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
	tmp = 0.0;
	if (phi2 <= 3900000000.0)
		tmp = R * lambda2;
	else
		tmp = R * phi2;
	end
	tmp_2 = tmp;
end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 3900000000.0], N[(R * lambda2), $MachinePrecision], N[(R * phi2), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 3900000000:\\
\;\;\;\;R \cdot \lambda_2\\

\mathbf{else}:\\
\;\;\;\;R \cdot \phi_2\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if phi2 < 3.9e9

    1. Initial program 68.4%

      \[R \cdot \sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)} \]
    2. Step-by-step derivation
      1. hypot-def95.4%

        \[\leadsto R \cdot \color{blue}{\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    3. Simplified95.4%

      \[\leadsto \color{blue}{R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    4. Taylor expanded in lambda2 around inf 19.4%

      \[\leadsto \color{blue}{R \cdot \left(\lambda_2 \cdot \cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)\right)} \]
    5. Step-by-step derivation
      1. *-commutative19.4%

        \[\leadsto \color{blue}{\left(\lambda_2 \cdot \cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)\right) \cdot R} \]
      2. +-commutative19.4%

        \[\leadsto \left(\lambda_2 \cdot \cos \left(0.5 \cdot \color{blue}{\left(\phi_2 + \phi_1\right)}\right)\right) \cdot R \]
    6. Simplified19.4%

      \[\leadsto \color{blue}{\left(\lambda_2 \cdot \cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)\right) \cdot R} \]
    7. Step-by-step derivation
      1. add-exp-log10.5%

        \[\leadsto \color{blue}{e^{\log \left(\left(\lambda_2 \cdot \cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)\right) \cdot R\right)}} \]
      2. *-commutative10.5%

        \[\leadsto e^{\log \left(\color{blue}{\left(\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right) \cdot \lambda_2\right)} \cdot R\right)} \]
      3. *-commutative10.5%

        \[\leadsto e^{\log \left(\left(\cos \color{blue}{\left(\left(\phi_2 + \phi_1\right) \cdot 0.5\right)} \cdot \lambda_2\right) \cdot R\right)} \]
      4. +-commutative10.5%

        \[\leadsto e^{\log \left(\left(\cos \left(\color{blue}{\left(\phi_1 + \phi_2\right)} \cdot 0.5\right) \cdot \lambda_2\right) \cdot R\right)} \]
      5. associate-*l*10.5%

        \[\leadsto e^{\log \color{blue}{\left(\cos \left(\left(\phi_1 + \phi_2\right) \cdot 0.5\right) \cdot \left(\lambda_2 \cdot R\right)\right)}} \]
      6. +-commutative10.5%

        \[\leadsto e^{\log \left(\cos \left(\color{blue}{\left(\phi_2 + \phi_1\right)} \cdot 0.5\right) \cdot \left(\lambda_2 \cdot R\right)\right)} \]
      7. *-commutative10.5%

        \[\leadsto e^{\log \left(\cos \color{blue}{\left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)} \cdot \left(\lambda_2 \cdot R\right)\right)} \]
      8. +-commutative10.5%

        \[\leadsto e^{\log \left(\cos \left(0.5 \cdot \color{blue}{\left(\phi_1 + \phi_2\right)}\right) \cdot \left(\lambda_2 \cdot R\right)\right)} \]
    8. Applied egg-rr10.5%

      \[\leadsto \color{blue}{e^{\log \left(\cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right) \cdot \left(\lambda_2 \cdot R\right)\right)}} \]
    9. Taylor expanded in phi1 around 0 8.4%

      \[\leadsto e^{\color{blue}{\log \left(R \cdot \left(\lambda_2 \cdot \cos \left(0.5 \cdot \phi_2\right)\right)\right)}} \]
    10. Taylor expanded in phi2 around 0 15.8%

      \[\leadsto \color{blue}{R \cdot \lambda_2} \]
    11. Step-by-step derivation
      1. *-commutative15.8%

        \[\leadsto \color{blue}{\lambda_2 \cdot R} \]
    12. Simplified15.8%

      \[\leadsto \color{blue}{\lambda_2 \cdot R} \]

    if 3.9e9 < phi2

    1. Initial program 53.7%

      \[R \cdot \sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)} \]
    2. Step-by-step derivation
      1. hypot-def96.8%

        \[\leadsto R \cdot \color{blue}{\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    3. Simplified96.8%

      \[\leadsto \color{blue}{R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    4. Taylor expanded in phi2 around inf 56.8%

      \[\leadsto \color{blue}{R \cdot \phi_2} \]
    5. Step-by-step derivation
      1. *-commutative56.8%

        \[\leadsto \color{blue}{\phi_2 \cdot R} \]
    6. Simplified56.8%

      \[\leadsto \color{blue}{\phi_2 \cdot R} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification24.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\phi_2 \leq 3900000000:\\ \;\;\;\;R \cdot \lambda_2\\ \mathbf{else}:\\ \;\;\;\;R \cdot \phi_2\\ \end{array} \]

Alternative 13: 13.4% accurate, 109.7× speedup?

\[\begin{array}{l} \\ R \cdot \lambda_2 \end{array} \]
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R lambda2))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	return R * lambda2;
}
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 * lambda2
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	return R * lambda2;
}
def code(R, lambda1, lambda2, phi1, phi2):
	return R * lambda2
function code(R, lambda1, lambda2, phi1, phi2)
	return Float64(R * lambda2)
end
function tmp = code(R, lambda1, lambda2, phi1, phi2)
	tmp = R * lambda2;
end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * lambda2), $MachinePrecision]
\begin{array}{l}

\\
R \cdot \lambda_2
\end{array}
Derivation
  1. Initial program 65.3%

    \[R \cdot \sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)} \]
  2. Step-by-step derivation
    1. hypot-def95.7%

      \[\leadsto R \cdot \color{blue}{\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
  3. Simplified95.7%

    \[\leadsto \color{blue}{R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
  4. Taylor expanded in lambda2 around inf 19.8%

    \[\leadsto \color{blue}{R \cdot \left(\lambda_2 \cdot \cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)\right)} \]
  5. Step-by-step derivation
    1. *-commutative19.8%

      \[\leadsto \color{blue}{\left(\lambda_2 \cdot \cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)\right) \cdot R} \]
    2. +-commutative19.8%

      \[\leadsto \left(\lambda_2 \cdot \cos \left(0.5 \cdot \color{blue}{\left(\phi_2 + \phi_1\right)}\right)\right) \cdot R \]
  6. Simplified19.8%

    \[\leadsto \color{blue}{\left(\lambda_2 \cdot \cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)\right) \cdot R} \]
  7. Step-by-step derivation
    1. add-exp-log10.7%

      \[\leadsto \color{blue}{e^{\log \left(\left(\lambda_2 \cdot \cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)\right) \cdot R\right)}} \]
    2. *-commutative10.7%

      \[\leadsto e^{\log \left(\color{blue}{\left(\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right) \cdot \lambda_2\right)} \cdot R\right)} \]
    3. *-commutative10.7%

      \[\leadsto e^{\log \left(\left(\cos \color{blue}{\left(\left(\phi_2 + \phi_1\right) \cdot 0.5\right)} \cdot \lambda_2\right) \cdot R\right)} \]
    4. +-commutative10.7%

      \[\leadsto e^{\log \left(\left(\cos \left(\color{blue}{\left(\phi_1 + \phi_2\right)} \cdot 0.5\right) \cdot \lambda_2\right) \cdot R\right)} \]
    5. associate-*l*10.7%

      \[\leadsto e^{\log \color{blue}{\left(\cos \left(\left(\phi_1 + \phi_2\right) \cdot 0.5\right) \cdot \left(\lambda_2 \cdot R\right)\right)}} \]
    6. +-commutative10.7%

      \[\leadsto e^{\log \left(\cos \left(\color{blue}{\left(\phi_2 + \phi_1\right)} \cdot 0.5\right) \cdot \left(\lambda_2 \cdot R\right)\right)} \]
    7. *-commutative10.7%

      \[\leadsto e^{\log \left(\cos \color{blue}{\left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)} \cdot \left(\lambda_2 \cdot R\right)\right)} \]
    8. +-commutative10.7%

      \[\leadsto e^{\log \left(\cos \left(0.5 \cdot \color{blue}{\left(\phi_1 + \phi_2\right)}\right) \cdot \left(\lambda_2 \cdot R\right)\right)} \]
  8. Applied egg-rr10.7%

    \[\leadsto \color{blue}{e^{\log \left(\cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right) \cdot \left(\lambda_2 \cdot R\right)\right)}} \]
  9. Taylor expanded in phi1 around 0 9.1%

    \[\leadsto e^{\color{blue}{\log \left(R \cdot \left(\lambda_2 \cdot \cos \left(0.5 \cdot \phi_2\right)\right)\right)}} \]
  10. Taylor expanded in phi2 around 0 14.8%

    \[\leadsto \color{blue}{R \cdot \lambda_2} \]
  11. Step-by-step derivation
    1. *-commutative14.8%

      \[\leadsto \color{blue}{\lambda_2 \cdot R} \]
  12. Simplified14.8%

    \[\leadsto \color{blue}{\lambda_2 \cdot R} \]
  13. Final simplification14.8%

    \[\leadsto R \cdot \lambda_2 \]

Reproduce

?
herbie shell --seed 2023326 
(FPCore (R lambda1 lambda2 phi1 phi2)
  :name "Equirectangular approximation to distance on a great circle"
  :precision binary64
  (* R (sqrt (+ (* (* (- lambda1 lambda2) (cos (/ (+ phi1 phi2) 2.0))) (* (- lambda1 lambda2) (cos (/ (+ phi1 phi2) 2.0)))) (* (- phi1 phi2) (- phi1 phi2))))))