Equirectangular approximation to distance on a great circle

Percentage Accurate: 60.2% → 99.9%
Time: 21.9s
Alternatives: 22
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 22 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: 60.2% 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.9% accurate, 0.5× speedup?

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

\\
R \cdot \mathsf{hypot}\left(\mathsf{fma}\left(\sin \left(\frac{\phi_2}{2}\right), \sin \left(\frac{\phi_1}{2}\right) \cdot \left(\lambda_2 - \lambda_1\right), \cos \left(\frac{\phi_2}{2}\right) \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right)\right), \phi_1 - \phi_2\right)
\end{array}
Derivation
  1. Initial program 54.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. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
    2. hypot-defineN/A

      \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
    3. hypot-lowering-hypot.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
    4. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
    5. --lowering--.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
    6. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
    7. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
    8. +-lowering-+.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
    9. --lowering--.f6494.4%

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
  3. Simplified94.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. Add Preprocessing
  5. Step-by-step derivation
    1. clear-numN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{1}{\frac{2}{\phi_1 + \phi_2}}\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    2. associate-/r/N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{1}{2} \cdot \left(\phi_1 + \phi_2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    3. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{1}{2} \cdot \left(\phi_1 + \phi_2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    4. +-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{1}{2} \cdot \left(\phi_2 + \phi_1\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    5. distribute-lft-inN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{1}{2} \cdot \phi_2 + \frac{1}{2} \cdot \phi_1\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    6. cos-sumN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \left(\cos \left(\frac{1}{2} \cdot \phi_2\right) \cdot \cos \left(\frac{1}{2} \cdot \phi_1\right) - \sin \left(\frac{1}{2} \cdot \phi_2\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_1\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    7. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \left(\cos \left(\frac{1}{2} \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot \frac{1}{2}\right) - \sin \left(\frac{1}{2} \cdot \phi_2\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_1\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    8. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \left(\cos \left(\frac{1}{2} \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot \frac{1}{2}\right) - \sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_1\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    9. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \left(\cos \left(\frac{1}{2} \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot \frac{1}{2}\right) - \sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    10. fmm-defN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \left(\mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot \phi_2\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right), \mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    11. fma-lowering-fma.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\cos \left(\frac{1}{2} \cdot \phi_2\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    12. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\left(\frac{1}{2} \cdot \phi_2\right)\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    13. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\left(\phi_2 \cdot \frac{1}{2}\right)\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    14. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\left(\phi_2 \cdot \frac{1}{2}\right)\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    15. div-invN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\left(\frac{\phi_2}{2}\right)\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    16. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    17. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right), \mathsf{cos.f64}\left(\left(\phi_1 \cdot \frac{1}{2}\right)\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    18. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right), \mathsf{cos.f64}\left(\left(\phi_1 \cdot \frac{1}{2}\right)\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    19. div-invN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1}{2}\right)\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    20. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_1, 2\right)\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
  6. Applied egg-rr99.8%

    \[\leadsto R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{\mathsf{fma}\left(\cos \left(\frac{\phi_2}{2}\right), \cos \left(\frac{\phi_1}{2}\right), -\sin \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right)\right)}, \phi_1 - \phi_2\right) \]
  7. Step-by-step derivation
    1. distribute-rgt-inN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\cos \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right) \cdot \left(\lambda_1 - \lambda_2\right) + \left(\mathsf{neg}\left(\sin \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right)\right)\right) \cdot \left(\lambda_1 - \lambda_2\right)\right), \mathsf{\_.f64}\left(\color{blue}{\phi_1}, \phi_2\right)\right)\right) \]
    2. +-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\mathsf{neg}\left(\sin \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right)\right)\right) \cdot \left(\lambda_1 - \lambda_2\right) + \left(\cos \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right) \cdot \left(\lambda_1 - \lambda_2\right)\right), \mathsf{\_.f64}\left(\color{blue}{\phi_1}, \phi_2\right)\right)\right) \]
    3. distribute-rgt-neg-inN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\sin \left(\frac{\phi_2}{2}\right) \cdot \left(\mathsf{neg}\left(\sin \left(\frac{\phi_1}{2}\right)\right)\right)\right) \cdot \left(\lambda_1 - \lambda_2\right) + \left(\cos \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right) \cdot \left(\lambda_1 - \lambda_2\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    4. associate-*l*N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\sin \left(\frac{\phi_2}{2}\right) \cdot \left(\left(\mathsf{neg}\left(\sin \left(\frac{\phi_1}{2}\right)\right)\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) + \left(\cos \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right) \cdot \left(\lambda_1 - \lambda_2\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    5. fma-defineN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\mathsf{fma}\left(\sin \left(\frac{\phi_2}{2}\right), \left(\mathsf{neg}\left(\sin \left(\frac{\phi_1}{2}\right)\right)\right) \cdot \left(\lambda_1 - \lambda_2\right), \left(\cos \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right) \cdot \left(\lambda_1 - \lambda_2\right)\right)\right), \mathsf{\_.f64}\left(\color{blue}{\phi_1}, \phi_2\right)\right)\right) \]
    6. fma-lowering-fma.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{fma.f64}\left(\sin \left(\frac{\phi_2}{2}\right), \left(\left(\mathsf{neg}\left(\sin \left(\frac{\phi_1}{2}\right)\right)\right) \cdot \left(\lambda_1 - \lambda_2\right)\right), \left(\left(\cos \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right) \cdot \left(\lambda_1 - \lambda_2\right)\right)\right), \mathsf{\_.f64}\left(\color{blue}{\phi_1}, \phi_2\right)\right)\right) \]
  8. Applied egg-rr99.8%

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

    \[\leadsto R \cdot \mathsf{hypot}\left(\mathsf{fma}\left(\sin \left(\frac{\phi_2}{2}\right), \sin \left(\frac{\phi_1}{2}\right) \cdot \left(\lambda_2 - \lambda_1\right), \cos \left(\frac{\phi_2}{2}\right) \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right)\right), \phi_1 - \phi_2\right) \]
  10. Add Preprocessing

Alternative 2: 99.9% accurate, 0.5× speedup?

\[\begin{array}{l} \\ R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \mathsf{fma}\left(0 - \sin \left(\frac{\phi_2}{2}\right), \sin \left(\frac{\phi_1}{2}\right), \cos \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right), \phi_1 - \phi_2\right) \end{array} \]
(FPCore (R lambda1 lambda2 phi1 phi2)
 :precision binary64
 (*
  R
  (hypot
   (*
    (- lambda1 lambda2)
    (fma
     (- 0.0 (sin (/ phi2 2.0)))
     (sin (/ phi1 2.0))
     (* (cos (/ phi2 2.0)) (cos (/ phi1 2.0)))))
   (- phi1 phi2))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	return R * hypot(((lambda1 - lambda2) * fma((0.0 - sin((phi2 / 2.0))), sin((phi1 / 2.0)), (cos((phi2 / 2.0)) * cos((phi1 / 2.0))))), (phi1 - phi2));
}
function code(R, lambda1, lambda2, phi1, phi2)
	return Float64(R * hypot(Float64(Float64(lambda1 - lambda2) * fma(Float64(0.0 - sin(Float64(phi2 / 2.0))), sin(Float64(phi1 / 2.0)), Float64(cos(Float64(phi2 / 2.0)) * cos(Float64(phi1 / 2.0))))), Float64(phi1 - phi2)))
end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[Sqrt[N[(N[(lambda1 - lambda2), $MachinePrecision] * N[(N[(0.0 - N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] + N[(N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision]), $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 \mathsf{fma}\left(0 - \sin \left(\frac{\phi_2}{2}\right), \sin \left(\frac{\phi_1}{2}\right), \cos \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right), \phi_1 - \phi_2\right)
\end{array}
Derivation
  1. Initial program 54.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. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
    2. hypot-defineN/A

      \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
    3. hypot-lowering-hypot.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
    4. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
    5. --lowering--.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
    6. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
    7. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
    8. +-lowering-+.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
    9. --lowering--.f6494.4%

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
  3. Simplified94.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. Add Preprocessing
  5. Step-by-step derivation
    1. clear-numN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{1}{\frac{2}{\phi_1 + \phi_2}}\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    2. associate-/r/N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{1}{2} \cdot \left(\phi_1 + \phi_2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    3. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{1}{2} \cdot \left(\phi_1 + \phi_2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    4. +-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{1}{2} \cdot \left(\phi_2 + \phi_1\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    5. distribute-lft-inN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{1}{2} \cdot \phi_2 + \frac{1}{2} \cdot \phi_1\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    6. cos-sumN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \left(\cos \left(\frac{1}{2} \cdot \phi_2\right) \cdot \cos \left(\frac{1}{2} \cdot \phi_1\right) - \sin \left(\frac{1}{2} \cdot \phi_2\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_1\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    7. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \left(\cos \left(\frac{1}{2} \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot \frac{1}{2}\right) - \sin \left(\frac{1}{2} \cdot \phi_2\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_1\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    8. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \left(\cos \left(\frac{1}{2} \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot \frac{1}{2}\right) - \sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_1\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    9. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \left(\cos \left(\frac{1}{2} \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot \frac{1}{2}\right) - \sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    10. fmm-defN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \left(\mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot \phi_2\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right), \mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    11. fma-lowering-fma.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\cos \left(\frac{1}{2} \cdot \phi_2\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    12. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\left(\frac{1}{2} \cdot \phi_2\right)\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    13. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\left(\phi_2 \cdot \frac{1}{2}\right)\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    14. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\left(\phi_2 \cdot \frac{1}{2}\right)\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    15. div-invN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\left(\frac{\phi_2}{2}\right)\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    16. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    17. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right), \mathsf{cos.f64}\left(\left(\phi_1 \cdot \frac{1}{2}\right)\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    18. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right), \mathsf{cos.f64}\left(\left(\phi_1 \cdot \frac{1}{2}\right)\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    19. div-invN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1}{2}\right)\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    20. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_1, 2\right)\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
  6. Applied egg-rr99.8%

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

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \left(\left(\mathsf{neg}\left(\sin \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right)\right)\right) + \cos \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    2. distribute-lft-neg-inN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \left(\left(\mathsf{neg}\left(\sin \left(\frac{\phi_2}{2}\right)\right)\right) \cdot \sin \left(\frac{\phi_1}{2}\right) + \cos \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    3. fma-defineN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \left(\mathsf{fma}\left(\mathsf{neg}\left(\sin \left(\frac{\phi_2}{2}\right)\right), \sin \left(\frac{\phi_1}{2}\right), \cos \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    4. fma-lowering-fma.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(\sin \left(\frac{\phi_2}{2}\right)\right)\right), \sin \left(\frac{\phi_1}{2}\right), \left(\cos \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    5. neg-sub0N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\left(0 - \sin \left(\frac{\phi_2}{2}\right)\right), \sin \left(\frac{\phi_1}{2}\right), \left(\cos \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    6. --lowering--.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(0, \sin \left(\frac{\phi_2}{2}\right)\right), \sin \left(\frac{\phi_1}{2}\right), \left(\cos \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    7. sin-lowering-sin.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{sin.f64}\left(\left(\frac{\phi_2}{2}\right)\right)\right), \sin \left(\frac{\phi_1}{2}\right), \left(\cos \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    8. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{sin.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right)\right), \sin \left(\frac{\phi_1}{2}\right), \left(\cos \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    9. sin-lowering-sin.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{sin.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right)\right), \mathsf{sin.f64}\left(\left(\frac{\phi_1}{2}\right)\right), \left(\cos \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    10. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{sin.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right)\right), \mathsf{sin.f64}\left(\mathsf{/.f64}\left(\phi_1, 2\right)\right), \left(\cos \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    11. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{sin.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right)\right), \mathsf{sin.f64}\left(\mathsf{/.f64}\left(\phi_1, 2\right)\right), \left(\cos \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    12. div-invN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{sin.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right)\right), \mathsf{sin.f64}\left(\mathsf{/.f64}\left(\phi_1, 2\right)\right), \left(\cos \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\phi_2 \cdot \frac{1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    13. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{sin.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right)\right), \mathsf{sin.f64}\left(\mathsf{/.f64}\left(\phi_1, 2\right)\right), \left(\cos \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\phi_2 \cdot \frac{1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    14. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{sin.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right)\right), \mathsf{sin.f64}\left(\mathsf{/.f64}\left(\phi_1, 2\right)\right), \left(\cos \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    15. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{sin.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right)\right), \mathsf{sin.f64}\left(\mathsf{/.f64}\left(\phi_1, 2\right)\right), \mathsf{*.f64}\left(\cos \left(\frac{\phi_1}{2}\right), \cos \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    16. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{sin.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right)\right), \mathsf{sin.f64}\left(\mathsf{/.f64}\left(\phi_1, 2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\left(\frac{\phi_1}{2}\right)\right), \cos \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    17. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{sin.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right)\right), \mathsf{sin.f64}\left(\mathsf{/.f64}\left(\phi_1, 2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_1, 2\right)\right), \cos \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    18. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{sin.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right)\right), \mathsf{sin.f64}\left(\mathsf{/.f64}\left(\phi_1, 2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_1, 2\right)\right), \cos \left(\phi_2 \cdot \frac{1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    19. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{sin.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right)\right), \mathsf{sin.f64}\left(\mathsf{/.f64}\left(\phi_1, 2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_1, 2\right)\right), \cos \left(\phi_2 \cdot \frac{1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    20. div-invN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{sin.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right)\right), \mathsf{sin.f64}\left(\mathsf{/.f64}\left(\phi_1, 2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_1, 2\right)\right), \cos \left(\frac{\phi_2}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
  8. Applied egg-rr99.8%

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

    \[\leadsto R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \mathsf{fma}\left(0 - \sin \left(\frac{\phi_2}{2}\right), \sin \left(\frac{\phi_1}{2}\right), \cos \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right), \phi_1 - \phi_2\right) \]
  10. Add Preprocessing

Alternative 3: 99.9% accurate, 0.5× speedup?

\[\begin{array}{l} \\ R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \mathsf{fma}\left(\cos \left(\frac{\phi_2}{2}\right), \cos \left(\frac{\phi_1}{2}\right), \sin \left(\frac{\phi_2}{2}\right) \cdot \left(0 - \sin \left(\frac{\phi_1}{2}\right)\right)\right), \phi_1 - \phi_2\right) \end{array} \]
(FPCore (R lambda1 lambda2 phi1 phi2)
 :precision binary64
 (*
  R
  (hypot
   (*
    (- lambda1 lambda2)
    (fma
     (cos (/ phi2 2.0))
     (cos (/ phi1 2.0))
     (* (sin (/ phi2 2.0)) (- 0.0 (sin (/ phi1 2.0))))))
   (- phi1 phi2))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	return R * hypot(((lambda1 - lambda2) * fma(cos((phi2 / 2.0)), cos((phi1 / 2.0)), (sin((phi2 / 2.0)) * (0.0 - sin((phi1 / 2.0)))))), (phi1 - phi2));
}
function code(R, lambda1, lambda2, phi1, phi2)
	return Float64(R * hypot(Float64(Float64(lambda1 - lambda2) * fma(cos(Float64(phi2 / 2.0)), cos(Float64(phi1 / 2.0)), Float64(sin(Float64(phi2 / 2.0)) * Float64(0.0 - sin(Float64(phi1 / 2.0)))))), Float64(phi1 - phi2)))
end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[Sqrt[N[(N[(lambda1 - lambda2), $MachinePrecision] * N[(N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] + N[(N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision] * N[(0.0 - N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $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 \mathsf{fma}\left(\cos \left(\frac{\phi_2}{2}\right), \cos \left(\frac{\phi_1}{2}\right), \sin \left(\frac{\phi_2}{2}\right) \cdot \left(0 - \sin \left(\frac{\phi_1}{2}\right)\right)\right), \phi_1 - \phi_2\right)
\end{array}
Derivation
  1. Initial program 54.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. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
    2. hypot-defineN/A

      \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
    3. hypot-lowering-hypot.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
    4. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
    5. --lowering--.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
    6. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
    7. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
    8. +-lowering-+.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
    9. --lowering--.f6494.4%

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
  3. Simplified94.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. Add Preprocessing
  5. Step-by-step derivation
    1. clear-numN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{1}{\frac{2}{\phi_1 + \phi_2}}\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    2. associate-/r/N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{1}{2} \cdot \left(\phi_1 + \phi_2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    3. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{1}{2} \cdot \left(\phi_1 + \phi_2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    4. +-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{1}{2} \cdot \left(\phi_2 + \phi_1\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    5. distribute-lft-inN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{1}{2} \cdot \phi_2 + \frac{1}{2} \cdot \phi_1\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    6. cos-sumN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \left(\cos \left(\frac{1}{2} \cdot \phi_2\right) \cdot \cos \left(\frac{1}{2} \cdot \phi_1\right) - \sin \left(\frac{1}{2} \cdot \phi_2\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_1\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    7. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \left(\cos \left(\frac{1}{2} \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot \frac{1}{2}\right) - \sin \left(\frac{1}{2} \cdot \phi_2\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_1\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    8. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \left(\cos \left(\frac{1}{2} \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot \frac{1}{2}\right) - \sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_1\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    9. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \left(\cos \left(\frac{1}{2} \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot \frac{1}{2}\right) - \sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    10. fmm-defN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \left(\mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot \phi_2\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right), \mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    11. fma-lowering-fma.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\cos \left(\frac{1}{2} \cdot \phi_2\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    12. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\left(\frac{1}{2} \cdot \phi_2\right)\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    13. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\left(\phi_2 \cdot \frac{1}{2}\right)\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    14. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\left(\phi_2 \cdot \frac{1}{2}\right)\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    15. div-invN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\left(\frac{\phi_2}{2}\right)\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    16. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    17. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right), \mathsf{cos.f64}\left(\left(\phi_1 \cdot \frac{1}{2}\right)\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    18. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right), \mathsf{cos.f64}\left(\left(\phi_1 \cdot \frac{1}{2}\right)\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    19. div-invN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1}{2}\right)\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    20. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_1, 2\right)\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
  6. Applied egg-rr99.8%

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

    \[\leadsto R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \mathsf{fma}\left(\cos \left(\frac{\phi_2}{2}\right), \cos \left(\frac{\phi_1}{2}\right), \sin \left(\frac{\phi_2}{2}\right) \cdot \left(0 - \sin \left(\frac{\phi_1}{2}\right)\right)\right), \phi_1 - \phi_2\right) \]
  8. Add Preprocessing

Alternative 4: 99.9% accurate, 0.6× speedup?

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

\\
R \cdot \mathsf{hypot}\left(\cos \left(\frac{\phi_2}{2}\right) \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right) + \sin \left(\frac{\phi_2}{2}\right) \cdot \left(\sin \left(\frac{\phi_1}{2}\right) \cdot \left(\lambda_2 - \lambda_1\right)\right), \phi_1 - \phi_2\right)
\end{array}
Derivation
  1. Initial program 54.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. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
    2. hypot-defineN/A

      \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
    3. hypot-lowering-hypot.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
    4. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
    5. --lowering--.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
    6. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
    7. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
    8. +-lowering-+.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
    9. --lowering--.f6494.4%

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
  3. Simplified94.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. Add Preprocessing
  5. Step-by-step derivation
    1. clear-numN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{1}{\frac{2}{\phi_1 + \phi_2}}\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    2. associate-/r/N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{1}{2} \cdot \left(\phi_1 + \phi_2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    3. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{1}{2} \cdot \left(\phi_1 + \phi_2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    4. +-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{1}{2} \cdot \left(\phi_2 + \phi_1\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    5. distribute-lft-inN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{1}{2} \cdot \phi_2 + \frac{1}{2} \cdot \phi_1\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    6. cos-sumN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \left(\cos \left(\frac{1}{2} \cdot \phi_2\right) \cdot \cos \left(\frac{1}{2} \cdot \phi_1\right) - \sin \left(\frac{1}{2} \cdot \phi_2\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_1\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    7. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \left(\cos \left(\frac{1}{2} \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot \frac{1}{2}\right) - \sin \left(\frac{1}{2} \cdot \phi_2\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_1\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    8. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \left(\cos \left(\frac{1}{2} \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot \frac{1}{2}\right) - \sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_1\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    9. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \left(\cos \left(\frac{1}{2} \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot \frac{1}{2}\right) - \sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    10. fmm-defN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \left(\mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot \phi_2\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right), \mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    11. fma-lowering-fma.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\cos \left(\frac{1}{2} \cdot \phi_2\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    12. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\left(\frac{1}{2} \cdot \phi_2\right)\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    13. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\left(\phi_2 \cdot \frac{1}{2}\right)\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    14. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\left(\phi_2 \cdot \frac{1}{2}\right)\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    15. div-invN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\left(\frac{\phi_2}{2}\right)\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    16. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    17. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right), \mathsf{cos.f64}\left(\left(\phi_1 \cdot \frac{1}{2}\right)\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    18. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right), \mathsf{cos.f64}\left(\left(\phi_1 \cdot \frac{1}{2}\right)\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    19. div-invN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1}{2}\right)\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    20. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_1, 2\right)\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
  6. Applied egg-rr99.8%

    \[\leadsto R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{\mathsf{fma}\left(\cos \left(\frac{\phi_2}{2}\right), \cos \left(\frac{\phi_1}{2}\right), -\sin \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right)\right)}, \phi_1 - \phi_2\right) \]
  7. Step-by-step derivation
    1. distribute-rgt-inN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\cos \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right) \cdot \left(\lambda_1 - \lambda_2\right) + \left(\mathsf{neg}\left(\sin \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right)\right)\right) \cdot \left(\lambda_1 - \lambda_2\right)\right), \mathsf{\_.f64}\left(\color{blue}{\phi_1}, \phi_2\right)\right)\right) \]
    2. +-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\mathsf{neg}\left(\sin \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right)\right)\right) \cdot \left(\lambda_1 - \lambda_2\right) + \left(\cos \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right) \cdot \left(\lambda_1 - \lambda_2\right)\right), \mathsf{\_.f64}\left(\color{blue}{\phi_1}, \phi_2\right)\right)\right) \]
    3. distribute-rgt-neg-inN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\sin \left(\frac{\phi_2}{2}\right) \cdot \left(\mathsf{neg}\left(\sin \left(\frac{\phi_1}{2}\right)\right)\right)\right) \cdot \left(\lambda_1 - \lambda_2\right) + \left(\cos \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right) \cdot \left(\lambda_1 - \lambda_2\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    4. associate-*l*N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\sin \left(\frac{\phi_2}{2}\right) \cdot \left(\left(\mathsf{neg}\left(\sin \left(\frac{\phi_1}{2}\right)\right)\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) + \left(\cos \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right) \cdot \left(\lambda_1 - \lambda_2\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    5. fma-defineN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\mathsf{fma}\left(\sin \left(\frac{\phi_2}{2}\right), \left(\mathsf{neg}\left(\sin \left(\frac{\phi_1}{2}\right)\right)\right) \cdot \left(\lambda_1 - \lambda_2\right), \left(\cos \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right) \cdot \left(\lambda_1 - \lambda_2\right)\right)\right), \mathsf{\_.f64}\left(\color{blue}{\phi_1}, \phi_2\right)\right)\right) \]
    6. fma-lowering-fma.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{fma.f64}\left(\sin \left(\frac{\phi_2}{2}\right), \left(\left(\mathsf{neg}\left(\sin \left(\frac{\phi_1}{2}\right)\right)\right) \cdot \left(\lambda_1 - \lambda_2\right)\right), \left(\left(\cos \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right) \cdot \left(\lambda_1 - \lambda_2\right)\right)\right), \mathsf{\_.f64}\left(\color{blue}{\phi_1}, \phi_2\right)\right)\right) \]
  8. Applied egg-rr99.8%

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

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\cos \left(\frac{\phi_2}{2}\right) \cdot \left(\cos \left(\frac{\phi_1}{2}\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) + \sin \left(\frac{\phi_2}{2}\right) \cdot \left(\mathsf{neg}\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\right), \mathsf{\_.f64}\left(\color{blue}{\phi_1}, \phi_2\right)\right)\right) \]
    2. distribute-rgt-neg-outN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\cos \left(\frac{\phi_2}{2}\right) \cdot \left(\cos \left(\frac{\phi_1}{2}\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) + \left(\mathsf{neg}\left(\sin \left(\frac{\phi_2}{2}\right) \cdot \left(\sin \left(\frac{\phi_1}{2}\right) \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    3. unsub-negN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\cos \left(\frac{\phi_2}{2}\right) \cdot \left(\cos \left(\frac{\phi_1}{2}\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) - \sin \left(\frac{\phi_2}{2}\right) \cdot \left(\sin \left(\frac{\phi_1}{2}\right) \cdot \left(\lambda_1 - \lambda_2\right)\right)\right), \mathsf{\_.f64}\left(\color{blue}{\phi_1}, \phi_2\right)\right)\right) \]
    4. --lowering--.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{\_.f64}\left(\left(\cos \left(\frac{\phi_2}{2}\right) \cdot \left(\cos \left(\frac{\phi_1}{2}\right) \cdot \left(\lambda_1 - \lambda_2\right)\right)\right), \left(\sin \left(\frac{\phi_2}{2}\right) \cdot \left(\sin \left(\frac{\phi_1}{2}\right) \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\right), \mathsf{\_.f64}\left(\color{blue}{\phi_1}, \phi_2\right)\right)\right) \]
    5. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\cos \left(\frac{\phi_2}{2}\right), \left(\cos \left(\frac{\phi_1}{2}\right) \cdot \left(\lambda_1 - \lambda_2\right)\right)\right), \left(\sin \left(\frac{\phi_2}{2}\right) \cdot \left(\sin \left(\frac{\phi_1}{2}\right) \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    6. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\left(\frac{\phi_2}{2}\right)\right), \left(\cos \left(\frac{\phi_1}{2}\right) \cdot \left(\lambda_1 - \lambda_2\right)\right)\right), \left(\sin \left(\frac{\phi_2}{2}\right) \cdot \left(\sin \left(\frac{\phi_1}{2}\right) \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    7. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right), \left(\cos \left(\frac{\phi_1}{2}\right) \cdot \left(\lambda_1 - \lambda_2\right)\right)\right), \left(\sin \left(\frac{\phi_2}{2}\right) \cdot \left(\sin \left(\frac{\phi_1}{2}\right) \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    8. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right), \left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right)\right), \left(\sin \left(\frac{\phi_2}{2}\right) \cdot \left(\sin \left(\frac{\phi_1}{2}\right) \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    9. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right), \mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1}{2}\right)\right)\right), \left(\sin \left(\frac{\phi_2}{2}\right) \cdot \left(\sin \left(\frac{\phi_1}{2}\right) \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    10. --lowering--.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right), \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1}{2}\right)\right)\right), \left(\sin \left(\frac{\phi_2}{2}\right) \cdot \left(\sin \left(\frac{\phi_1}{2}\right) \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    11. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right), \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1}{2}\right)\right)\right)\right), \left(\sin \left(\frac{\phi_2}{2}\right) \cdot \left(\sin \left(\frac{\phi_1}{2}\right) \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    12. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right), \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_1, 2\right)\right)\right)\right), \left(\sin \left(\frac{\phi_2}{2}\right) \cdot \left(\sin \left(\frac{\phi_1}{2}\right) \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    13. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right), \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_1, 2\right)\right)\right)\right), \mathsf{*.f64}\left(\sin \left(\frac{\phi_2}{2}\right), \left(\sin \left(\frac{\phi_1}{2}\right) \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
  10. Applied egg-rr99.8%

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

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

Alternative 5: 96.3% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\lambda_2 \leq 10^{+182}:\\ \;\;\;\;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(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\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 1e+182)
   (*
    R
    (hypot (* (- lambda1 lambda2) (cos (/ (+ phi2 phi1) 2.0))) (- phi1 phi2)))
   (*
    R
    (hypot
     (*
      lambda2
      (-
       (* (sin (* phi1 0.5)) (sin (* phi2 0.5)))
       (* (cos (* phi1 0.5)) (cos (* phi2 0.5)))))
     (- phi1 phi2)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	double tmp;
	if (lambda2 <= 1e+182) {
		tmp = R * hypot(((lambda1 - lambda2) * cos(((phi2 + phi1) / 2.0))), (phi1 - phi2));
	} else {
		tmp = R * hypot((lambda2 * ((sin((phi1 * 0.5)) * sin((phi2 * 0.5))) - (cos((phi1 * 0.5)) * 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 <= 1e+182) {
		tmp = R * Math.hypot(((lambda1 - lambda2) * Math.cos(((phi2 + phi1) / 2.0))), (phi1 - phi2));
	} else {
		tmp = R * Math.hypot((lambda2 * ((Math.sin((phi1 * 0.5)) * Math.sin((phi2 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.cos((phi2 * 0.5))))), (phi1 - phi2));
	}
	return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2):
	tmp = 0
	if lambda2 <= 1e+182:
		tmp = R * math.hypot(((lambda1 - lambda2) * math.cos(((phi2 + phi1) / 2.0))), (phi1 - phi2))
	else:
		tmp = R * math.hypot((lambda2 * ((math.sin((phi1 * 0.5)) * math.sin((phi2 * 0.5))) - (math.cos((phi1 * 0.5)) * math.cos((phi2 * 0.5))))), (phi1 - phi2))
	return tmp
function code(R, lambda1, lambda2, phi1, phi2)
	tmp = 0.0
	if (lambda2 <= 1e+182)
		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(phi1 * 0.5)) * sin(Float64(phi2 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * 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 <= 1e+182)
		tmp = R * hypot(((lambda1 - lambda2) * cos(((phi2 + phi1) / 2.0))), (phi1 - phi2));
	else
		tmp = R * hypot((lambda2 * ((sin((phi1 * 0.5)) * sin((phi2 * 0.5))) - (cos((phi1 * 0.5)) * cos((phi2 * 0.5))))), (phi1 - phi2));
	end
	tmp_2 = tmp;
end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda2, 1e+182], 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[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $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 10^{+182}:\\
\;\;\;\;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(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\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.0000000000000001e182

    1. Initial program 56.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. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
      2. hypot-defineN/A

        \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
      3. hypot-lowering-hypot.f64N/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
      5. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
      6. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
      8. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
      9. --lowering--.f6495.0%

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
    3. Simplified95.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. Add Preprocessing

    if 1.0000000000000001e182 < lambda2

    1. Initial program 45.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. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
      2. hypot-defineN/A

        \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
      3. hypot-lowering-hypot.f64N/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
      5. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
      6. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
      8. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
      9. --lowering--.f6489.0%

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
    3. Simplified89.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. Add Preprocessing
    5. Step-by-step derivation
      1. clear-numN/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{1}{\frac{2}{\phi_1 + \phi_2}}\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
      2. associate-/r/N/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{1}{2} \cdot \left(\phi_1 + \phi_2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
      3. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{1}{2} \cdot \left(\phi_1 + \phi_2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
      4. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{1}{2} \cdot \left(\phi_2 + \phi_1\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
      5. distribute-lft-inN/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{1}{2} \cdot \phi_2 + \frac{1}{2} \cdot \phi_1\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
      6. cos-sumN/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \left(\cos \left(\frac{1}{2} \cdot \phi_2\right) \cdot \cos \left(\frac{1}{2} \cdot \phi_1\right) - \sin \left(\frac{1}{2} \cdot \phi_2\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_1\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
      7. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \left(\cos \left(\frac{1}{2} \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot \frac{1}{2}\right) - \sin \left(\frac{1}{2} \cdot \phi_2\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_1\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
      8. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \left(\cos \left(\frac{1}{2} \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot \frac{1}{2}\right) - \sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_1\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
      9. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \left(\cos \left(\frac{1}{2} \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot \frac{1}{2}\right) - \sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
      10. fmm-defN/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \left(\mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot \phi_2\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right), \mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
      11. fma-lowering-fma.f64N/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\cos \left(\frac{1}{2} \cdot \phi_2\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
      12. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\left(\frac{1}{2} \cdot \phi_2\right)\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
      13. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\left(\phi_2 \cdot \frac{1}{2}\right)\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
      14. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\left(\phi_2 \cdot \frac{1}{2}\right)\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
      15. div-invN/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\left(\frac{\phi_2}{2}\right)\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
      16. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
      17. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right), \mathsf{cos.f64}\left(\left(\phi_1 \cdot \frac{1}{2}\right)\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
      18. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right), \mathsf{cos.f64}\left(\left(\phi_1 \cdot \frac{1}{2}\right)\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
      19. div-invN/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1}{2}\right)\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
      20. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_1, 2\right)\right), \left(\mathsf{neg}\left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    6. Applied egg-rr99.6%

      \[\leadsto R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{\mathsf{fma}\left(\cos \left(\frac{\phi_2}{2}\right), \cos \left(\frac{\phi_1}{2}\right), -\sin \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right)\right)}, \phi_1 - \phi_2\right) \]
    7. Step-by-step derivation
      1. distribute-rgt-inN/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\cos \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right) \cdot \left(\lambda_1 - \lambda_2\right) + \left(\mathsf{neg}\left(\sin \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right)\right)\right) \cdot \left(\lambda_1 - \lambda_2\right)\right), \mathsf{\_.f64}\left(\color{blue}{\phi_1}, \phi_2\right)\right)\right) \]
      2. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\mathsf{neg}\left(\sin \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right)\right)\right) \cdot \left(\lambda_1 - \lambda_2\right) + \left(\cos \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right) \cdot \left(\lambda_1 - \lambda_2\right)\right), \mathsf{\_.f64}\left(\color{blue}{\phi_1}, \phi_2\right)\right)\right) \]
      3. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\sin \left(\frac{\phi_2}{2}\right) \cdot \left(\mathsf{neg}\left(\sin \left(\frac{\phi_1}{2}\right)\right)\right)\right) \cdot \left(\lambda_1 - \lambda_2\right) + \left(\cos \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right) \cdot \left(\lambda_1 - \lambda_2\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
      4. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\sin \left(\frac{\phi_2}{2}\right) \cdot \left(\left(\mathsf{neg}\left(\sin \left(\frac{\phi_1}{2}\right)\right)\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) + \left(\cos \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right) \cdot \left(\lambda_1 - \lambda_2\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
      5. fma-defineN/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\mathsf{fma}\left(\sin \left(\frac{\phi_2}{2}\right), \left(\mathsf{neg}\left(\sin \left(\frac{\phi_1}{2}\right)\right)\right) \cdot \left(\lambda_1 - \lambda_2\right), \left(\cos \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right) \cdot \left(\lambda_1 - \lambda_2\right)\right)\right), \mathsf{\_.f64}\left(\color{blue}{\phi_1}, \phi_2\right)\right)\right) \]
      6. fma-lowering-fma.f64N/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{fma.f64}\left(\sin \left(\frac{\phi_2}{2}\right), \left(\left(\mathsf{neg}\left(\sin \left(\frac{\phi_1}{2}\right)\right)\right) \cdot \left(\lambda_1 - \lambda_2\right)\right), \left(\left(\cos \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right) \cdot \left(\lambda_1 - \lambda_2\right)\right)\right), \mathsf{\_.f64}\left(\color{blue}{\phi_1}, \phi_2\right)\right)\right) \]
    8. Applied egg-rr99.6%

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

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\color{blue}{\left(-1 \cdot \left(\lambda_2 \cdot \left(\cos \left(\frac{1}{2} \cdot \phi_1\right) \cdot \cos \left(\frac{1}{2} \cdot \phi_2\right)\right)\right) + \lambda_2 \cdot \left(\sin \left(\frac{1}{2} \cdot \phi_1\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)}, \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    10. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\mathsf{neg}\left(\lambda_2 \cdot \left(\cos \left(\frac{1}{2} \cdot \phi_1\right) \cdot \cos \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right) + \lambda_2 \cdot \left(\sin \left(\frac{1}{2} \cdot \phi_1\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
      2. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\lambda_2 \cdot \left(\mathsf{neg}\left(\cos \left(\frac{1}{2} \cdot \phi_1\right) \cdot \cos \left(\frac{1}{2} \cdot \phi_2\right)\right)\right) + \lambda_2 \cdot \left(\sin \left(\frac{1}{2} \cdot \phi_1\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
      3. mul-1-negN/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\lambda_2 \cdot \left(-1 \cdot \left(\cos \left(\frac{1}{2} \cdot \phi_1\right) \cdot \cos \left(\frac{1}{2} \cdot \phi_2\right)\right)\right) + \lambda_2 \cdot \left(\sin \left(\frac{1}{2} \cdot \phi_1\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
      4. distribute-lft-inN/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\lambda_2 \cdot \left(-1 \cdot \left(\cos \left(\frac{1}{2} \cdot \phi_1\right) \cdot \cos \left(\frac{1}{2} \cdot \phi_2\right)\right) + \sin \left(\frac{1}{2} \cdot \phi_1\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right), \mathsf{\_.f64}\left(\color{blue}{\phi_1}, \phi_2\right)\right)\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\lambda_2, \left(-1 \cdot \left(\cos \left(\frac{1}{2} \cdot \phi_1\right) \cdot \cos \left(\frac{1}{2} \cdot \phi_2\right)\right) + \sin \left(\frac{1}{2} \cdot \phi_1\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right), \mathsf{\_.f64}\left(\color{blue}{\phi_1}, \phi_2\right)\right)\right) \]
      6. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\lambda_2, \left(\sin \left(\frac{1}{2} \cdot \phi_1\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right) + -1 \cdot \left(\cos \left(\frac{1}{2} \cdot \phi_1\right) \cdot \cos \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
      7. mul-1-negN/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\lambda_2, \left(\sin \left(\frac{1}{2} \cdot \phi_1\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right) + \left(\mathsf{neg}\left(\cos \left(\frac{1}{2} \cdot \phi_1\right) \cdot \cos \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
      8. unsub-negN/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\lambda_2, \left(\sin \left(\frac{1}{2} \cdot \phi_1\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right) - \cos \left(\frac{1}{2} \cdot \phi_1\right) \cdot \cos \left(\frac{1}{2} \cdot \phi_2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
      9. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\lambda_2, \mathsf{\_.f64}\left(\left(\sin \left(\frac{1}{2} \cdot \phi_1\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right), \left(\cos \left(\frac{1}{2} \cdot \phi_1\right) \cdot \cos \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    11. Simplified87.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\lambda_2 \leq 10^{+182}:\\ \;\;\;\;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(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right)\right), \phi_1 - \phi_2\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 99.9% accurate, 0.6× speedup?

\[\begin{array}{l} \\ R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \left(\cos \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right) - \sin \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right)\right), \phi_1 - \phi_2\right) \end{array} \]
(FPCore (R lambda1 lambda2 phi1 phi2)
 :precision binary64
 (*
  R
  (hypot
   (*
    (- lambda1 lambda2)
    (-
     (* (cos (/ phi2 2.0)) (cos (/ phi1 2.0)))
     (* (sin (/ phi2 2.0)) (sin (/ phi1 2.0)))))
   (- phi1 phi2))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	return R * hypot(((lambda1 - lambda2) * ((cos((phi2 / 2.0)) * cos((phi1 / 2.0))) - (sin((phi2 / 2.0)) * sin((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 / 2.0)) * Math.cos((phi1 / 2.0))) - (Math.sin((phi2 / 2.0)) * Math.sin((phi1 / 2.0))))), (phi1 - phi2));
}
def code(R, lambda1, lambda2, phi1, phi2):
	return R * math.hypot(((lambda1 - lambda2) * ((math.cos((phi2 / 2.0)) * math.cos((phi1 / 2.0))) - (math.sin((phi2 / 2.0)) * math.sin((phi1 / 2.0))))), (phi1 - phi2))
function code(R, lambda1, lambda2, phi1, phi2)
	return Float64(R * hypot(Float64(Float64(lambda1 - lambda2) * Float64(Float64(cos(Float64(phi2 / 2.0)) * cos(Float64(phi1 / 2.0))) - Float64(sin(Float64(phi2 / 2.0)) * sin(Float64(phi1 / 2.0))))), Float64(phi1 - phi2)))
end
function tmp = code(R, lambda1, lambda2, phi1, phi2)
	tmp = R * hypot(((lambda1 - lambda2) * ((cos((phi2 / 2.0)) * cos((phi1 / 2.0))) - (sin((phi2 / 2.0)) * sin((phi1 / 2.0))))), (phi1 - phi2));
end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[Sqrt[N[(N[(lambda1 - lambda2), $MachinePrecision] * N[(N[(N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision]), $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 \left(\cos \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right) - \sin \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right)\right), \phi_1 - \phi_2\right)
\end{array}
Derivation
  1. Initial program 54.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. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
    2. hypot-defineN/A

      \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
    3. hypot-lowering-hypot.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
    4. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
    5. --lowering--.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
    6. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
    7. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
    8. +-lowering-+.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
    9. --lowering--.f6494.4%

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
  3. Simplified94.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. Add Preprocessing
  5. Step-by-step derivation
    1. clear-numN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{1}{\frac{2}{\phi_1 + \phi_2}}\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    2. associate-/r/N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{1}{2} \cdot \left(\phi_1 + \phi_2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    3. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{1}{2} \cdot \left(\phi_1 + \phi_2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    4. +-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{1}{2} \cdot \left(\phi_2 + \phi_1\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    5. distribute-rgt-inN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\phi_2 \cdot \frac{1}{2} + \phi_1 \cdot \frac{1}{2}\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    6. cos-sumN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \left(\cos \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \cos \left(\phi_1 \cdot \frac{1}{2}\right) - \sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    7. --lowering--.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{\_.f64}\left(\left(\cos \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \cos \left(\phi_1 \cdot \frac{1}{2}\right)\right), \left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    8. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{\_.f64}\left(\left(\cos \left(\frac{1}{2} \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot \frac{1}{2}\right)\right), \left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    9. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\cos \left(\frac{1}{2} \cdot \phi_2\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right)\right), \left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    10. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\left(\frac{1}{2} \cdot \phi_2\right)\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right)\right), \left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    11. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\left(\phi_2 \cdot \frac{1}{2}\right)\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right)\right), \left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    12. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\left(\phi_2 \cdot \frac{1}{2}\right)\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right)\right), \left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    13. div-invN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\left(\frac{\phi_2}{2}\right)\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right)\right), \left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    14. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right), \cos \left(\phi_1 \cdot \frac{1}{2}\right)\right), \left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    15. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right), \mathsf{cos.f64}\left(\left(\phi_1 \cdot \frac{1}{2}\right)\right)\right), \left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    16. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right), \mathsf{cos.f64}\left(\left(\phi_1 \cdot \frac{1}{2}\right)\right)\right), \left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    17. div-invN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1}{2}\right)\right)\right), \left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    18. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_1, 2\right)\right)\right), \left(\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    19. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_1, 2\right)\right)\right), \left(\sin \left(\frac{1}{2} \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    20. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_2, 2\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\phi_1, 2\right)\right)\right), \mathsf{*.f64}\left(\sin \left(\frac{1}{2} \cdot \phi_2\right), \sin \left(\phi_1 \cdot \frac{1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
  6. Applied egg-rr99.8%

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

Alternative 7: 93.3% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 0.052:\\
\;\;\;\;R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1}{2}\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}{2}\right), \phi_1 - \phi_2\right)\\


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

    1. Initial program 59.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. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
      2. hypot-defineN/A

        \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
      3. hypot-lowering-hypot.f64N/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
      5. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
      6. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
      8. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
      9. --lowering--.f6496.6%

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
    3. Simplified96.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. Add Preprocessing
    5. Taylor expanded in phi1 around inf

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\color{blue}{\phi_1}, 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    6. Step-by-step derivation
      1. Simplified92.4%

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

      if 0.0519999999999999976 < phi2

      1. Initial program 41.6%

        \[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. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
        2. hypot-defineN/A

          \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
        3. hypot-lowering-hypot.f64N/A

          \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
        4. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
        5. --lowering--.f64N/A

          \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
        6. cos-lowering-cos.f64N/A

          \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
        7. /-lowering-/.f64N/A

          \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
        8. +-lowering-+.f64N/A

          \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
        9. --lowering--.f6487.6%

          \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
      3. Simplified87.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. Add Preprocessing
      5. Taylor expanded in phi1 around 0

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\color{blue}{\phi_2}, 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
      6. Step-by-step derivation
        1. Simplified87.4%

          \[\leadsto R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\color{blue}{\phi_2}}{2}\right), \phi_1 - \phi_2\right) \]
      7. Recombined 2 regimes into one program.
      8. Add Preprocessing

      Alternative 8: 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 54.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. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
        2. hypot-defineN/A

          \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
        3. hypot-lowering-hypot.f64N/A

          \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
        4. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
        5. --lowering--.f64N/A

          \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
        6. cos-lowering-cos.f64N/A

          \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
        7. /-lowering-/.f64N/A

          \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
        8. +-lowering-+.f64N/A

          \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
        9. --lowering--.f6494.4%

          \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
      3. Simplified94.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. Add Preprocessing
      5. Final simplification94.4%

        \[\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) \]
      6. Add Preprocessing

      Alternative 9: 90.8% accurate, 1.6× speedup?

      \[\begin{array}{l} \\ R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1}{2}\right), \phi_1 - \phi_2\right) \end{array} \]
      (FPCore (R lambda1 lambda2 phi1 phi2)
       :precision binary64
       (* R (hypot (* (- lambda1 lambda2) (cos (/ phi1 2.0))) (- phi1 phi2))))
      double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
      	return R * hypot(((lambda1 - lambda2) * cos((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((phi1 / 2.0))), (phi1 - phi2));
      }
      
      def code(R, lambda1, lambda2, phi1, phi2):
      	return R * math.hypot(((lambda1 - lambda2) * math.cos((phi1 / 2.0))), (phi1 - phi2))
      
      function code(R, lambda1, lambda2, phi1, phi2)
      	return Float64(R * hypot(Float64(Float64(lambda1 - lambda2) * cos(Float64(phi1 / 2.0))), Float64(phi1 - phi2)))
      end
      
      function tmp = code(R, lambda1, lambda2, phi1, phi2)
      	tmp = R * hypot(((lambda1 - lambda2) * cos((phi1 / 2.0))), (phi1 - phi2));
      end
      
      code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[Sqrt[N[(N[(lambda1 - lambda2), $MachinePrecision] * N[Cos[N[(phi1 / 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_1}{2}\right), \phi_1 - \phi_2\right)
      \end{array}
      
      Derivation
      1. Initial program 54.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. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
        2. hypot-defineN/A

          \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
        3. hypot-lowering-hypot.f64N/A

          \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
        4. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
        5. --lowering--.f64N/A

          \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
        6. cos-lowering-cos.f64N/A

          \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
        7. /-lowering-/.f64N/A

          \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
        8. +-lowering-+.f64N/A

          \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
        9. --lowering--.f6494.4%

          \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
      3. Simplified94.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. Add Preprocessing
      5. Taylor expanded in phi1 around inf

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\color{blue}{\phi_1}, 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
      6. Step-by-step derivation
        1. Simplified88.4%

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

        Alternative 10: 73.9% accurate, 3.0× speedup?

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

          1. Initial program 58.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. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
            2. hypot-defineN/A

              \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
            3. hypot-lowering-hypot.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
            4. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
            5. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            6. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            8. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            9. --lowering--.f6496.3%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\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. Add Preprocessing
          5. Taylor expanded in phi1 around 0

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \color{blue}{\left(\cos \left(\frac{1}{2} \cdot \phi_2\right) + \frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)}\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          6. Step-by-step derivation
            1. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\cos \left(\frac{1}{2} \cdot \phi_2\right), \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            2. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\left(\frac{1}{2} \cdot \phi_2\right)\right), \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            3. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            4. *-commutativeN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right) \cdot \frac{-1}{2}\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            5. *-commutativeN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\left(\sin \left(\frac{1}{2} \cdot \phi_2\right) \cdot \phi_1\right) \cdot \frac{-1}{2}\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            6. associate-*l*N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\sin \left(\frac{1}{2} \cdot \phi_2\right) \cdot \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            7. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\sin \left(\frac{1}{2} \cdot \phi_2\right), \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            8. sin-lowering-sin.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\left(\frac{1}{2} \cdot \phi_2\right)\right), \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            9. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            10. *-lowering-*.f6482.9%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\phi_1, \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          7. Simplified82.9%

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

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

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\sqrt{{\phi_1}^{2} + {\left(\lambda_1 - \lambda_2\right)}^{2}}\right)}\right) \]
            2. unpow2N/A

              \[\leadsto \mathsf{*.f64}\left(R, \left(\sqrt{\phi_1 \cdot \phi_1 + {\left(\lambda_1 - \lambda_2\right)}^{2}}\right)\right) \]
            3. unpow2N/A

              \[\leadsto \mathsf{*.f64}\left(R, \left(\sqrt{\phi_1 \cdot \phi_1 + \left(\lambda_1 - \lambda_2\right) \cdot \left(\lambda_1 - \lambda_2\right)}\right)\right) \]
            4. hypot-defineN/A

              \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\phi_1, \color{blue}{\lambda_1 - \lambda_2}\right)\right)\right) \]
            5. hypot-lowering-hypot.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\phi_1, \color{blue}{\left(\lambda_1 - \lambda_2\right)}\right)\right) \]
            6. --lowering--.f6469.8%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\phi_1, \mathsf{\_.f64}\left(\lambda_1, \color{blue}{\lambda_2}\right)\right)\right) \]
          10. Simplified69.8%

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

          if 2.1499999999999999e23 < phi2

          1. Initial program 40.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. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
            2. hypot-defineN/A

              \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
            3. hypot-lowering-hypot.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
            4. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
            5. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            6. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            8. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            9. --lowering--.f6487.7%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
          3. Simplified87.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. Add Preprocessing
          5. Taylor expanded in phi1 around 0

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \color{blue}{\left(\cos \left(\frac{1}{2} \cdot \phi_2\right) + \frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)}\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          6. Step-by-step derivation
            1. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\cos \left(\frac{1}{2} \cdot \phi_2\right), \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            2. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\left(\frac{1}{2} \cdot \phi_2\right)\right), \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            3. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            4. *-commutativeN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right) \cdot \frac{-1}{2}\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            5. *-commutativeN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\left(\sin \left(\frac{1}{2} \cdot \phi_2\right) \cdot \phi_1\right) \cdot \frac{-1}{2}\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            6. associate-*l*N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\sin \left(\frac{1}{2} \cdot \phi_2\right) \cdot \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            7. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\sin \left(\frac{1}{2} \cdot \phi_2\right), \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            8. sin-lowering-sin.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\left(\frac{1}{2} \cdot \phi_2\right)\right), \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            9. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            10. *-lowering-*.f6475.7%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\phi_1, \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          7. Simplified75.7%

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

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\color{blue}{\left(\lambda_1 - \lambda_2\right)}, \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          9. Step-by-step derivation
            1. --lowering--.f6477.5%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{\_.f64}\left(\color{blue}{\phi_1}, \phi_2\right)\right)\right) \]
          10. Simplified77.5%

            \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\lambda_1 - \lambda_2}, \phi_1 - \phi_2\right) \]
          11. Taylor expanded in lambda2 around 0

            \[\leadsto \color{blue}{R \cdot \sqrt{{\lambda_1}^{2} + {\left(\phi_1 - \phi_2\right)}^{2}}} \]
          12. Step-by-step derivation
            1. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\sqrt{{\lambda_1}^{2} + {\left(\phi_1 - \phi_2\right)}^{2}}\right)}\right) \]
            2. unpow2N/A

              \[\leadsto \mathsf{*.f64}\left(R, \left(\sqrt{\lambda_1 \cdot \lambda_1 + {\left(\phi_1 - \phi_2\right)}^{2}}\right)\right) \]
            3. unpow2N/A

              \[\leadsto \mathsf{*.f64}\left(R, \left(\sqrt{\lambda_1 \cdot \lambda_1 + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)}\right)\right) \]
            4. hypot-defineN/A

              \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\lambda_1, \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
            5. hypot-lowering-hypot.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\lambda_1, \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
            6. --lowering--.f6476.1%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\lambda_1, \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
          13. Simplified76.1%

            \[\leadsto \color{blue}{R \cdot \mathsf{hypot}\left(\lambda_1, \phi_1 - \phi_2\right)} \]
        3. Recombined 2 regimes into one program.
        4. Add Preprocessing

        Alternative 11: 74.1% accurate, 3.0× speedup?

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

          1. Initial program 56.6%

            \[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. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
            2. hypot-defineN/A

              \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
            3. hypot-lowering-hypot.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
            4. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
            5. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            6. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            8. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            9. --lowering--.f6494.9%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
          3. Simplified94.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. Add Preprocessing
          5. Taylor expanded in phi1 around 0

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \color{blue}{\left(\cos \left(\frac{1}{2} \cdot \phi_2\right) + \frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)}\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          6. Step-by-step derivation
            1. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\cos \left(\frac{1}{2} \cdot \phi_2\right), \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            2. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\left(\frac{1}{2} \cdot \phi_2\right)\right), \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            3. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            4. *-commutativeN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right) \cdot \frac{-1}{2}\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            5. *-commutativeN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\left(\sin \left(\frac{1}{2} \cdot \phi_2\right) \cdot \phi_1\right) \cdot \frac{-1}{2}\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            6. associate-*l*N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\sin \left(\frac{1}{2} \cdot \phi_2\right) \cdot \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            7. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\sin \left(\frac{1}{2} \cdot \phi_2\right), \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            8. sin-lowering-sin.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\left(\frac{1}{2} \cdot \phi_2\right)\right), \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            9. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            10. *-lowering-*.f6482.5%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\phi_1, \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          7. Simplified82.5%

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

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\color{blue}{\left(\lambda_1 - \lambda_2\right)}, \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          9. Step-by-step derivation
            1. --lowering--.f6485.7%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{\_.f64}\left(\color{blue}{\phi_1}, \phi_2\right)\right)\right) \]
          10. Simplified85.7%

            \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\lambda_1 - \lambda_2}, \phi_1 - \phi_2\right) \]
          11. Taylor expanded in lambda2 around 0

            \[\leadsto \color{blue}{R \cdot \sqrt{{\lambda_1}^{2} + {\left(\phi_1 - \phi_2\right)}^{2}}} \]
          12. Step-by-step derivation
            1. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\sqrt{{\lambda_1}^{2} + {\left(\phi_1 - \phi_2\right)}^{2}}\right)}\right) \]
            2. unpow2N/A

              \[\leadsto \mathsf{*.f64}\left(R, \left(\sqrt{\lambda_1 \cdot \lambda_1 + {\left(\phi_1 - \phi_2\right)}^{2}}\right)\right) \]
            3. unpow2N/A

              \[\leadsto \mathsf{*.f64}\left(R, \left(\sqrt{\lambda_1 \cdot \lambda_1 + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)}\right)\right) \]
            4. hypot-defineN/A

              \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\lambda_1, \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
            5. hypot-lowering-hypot.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\lambda_1, \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
            6. --lowering--.f6473.7%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\lambda_1, \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
          13. Simplified73.7%

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

          if 5.50000000000000017e150 < lambda2

          1. Initial program 41.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. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
            2. hypot-defineN/A

              \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
            3. hypot-lowering-hypot.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
            4. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
            5. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            6. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            8. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            9. --lowering--.f6490.1%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
          3. Simplified90.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)} \]
          4. Add Preprocessing
          5. Taylor expanded in phi1 around 0

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \color{blue}{\left(\cos \left(\frac{1}{2} \cdot \phi_2\right) + \frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)}\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          6. Step-by-step derivation
            1. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\cos \left(\frac{1}{2} \cdot \phi_2\right), \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            2. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\left(\frac{1}{2} \cdot \phi_2\right)\right), \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            3. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            4. *-commutativeN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right) \cdot \frac{-1}{2}\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            5. *-commutativeN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\left(\sin \left(\frac{1}{2} \cdot \phi_2\right) \cdot \phi_1\right) \cdot \frac{-1}{2}\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            6. associate-*l*N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\sin \left(\frac{1}{2} \cdot \phi_2\right) \cdot \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            7. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\sin \left(\frac{1}{2} \cdot \phi_2\right), \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            8. sin-lowering-sin.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\left(\frac{1}{2} \cdot \phi_2\right)\right), \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            9. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            10. *-lowering-*.f6472.0%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\phi_1, \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          7. Simplified72.0%

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

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\color{blue}{\left(\lambda_1 - \lambda_2\right)}, \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          9. Step-by-step derivation
            1. --lowering--.f6462.4%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{\_.f64}\left(\color{blue}{\phi_1}, \phi_2\right)\right)\right) \]
          10. Simplified62.4%

            \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\lambda_1 - \lambda_2}, \phi_1 - \phi_2\right) \]
          11. Taylor expanded in lambda2 around inf

            \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\lambda_2 \cdot \left(1 + -1 \cdot \frac{\lambda_1}{\lambda_2}\right)\right)}\right) \]
          12. Step-by-step derivation
            1. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\lambda_2, \color{blue}{\left(1 + -1 \cdot \frac{\lambda_1}{\lambda_2}\right)}\right)\right) \]
            2. mul-1-negN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\lambda_2, \left(1 + \left(\mathsf{neg}\left(\frac{\lambda_1}{\lambda_2}\right)\right)\right)\right)\right) \]
            3. unsub-negN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\lambda_2, \left(1 - \color{blue}{\frac{\lambda_1}{\lambda_2}}\right)\right)\right) \]
            4. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\lambda_2, \mathsf{\_.f64}\left(1, \color{blue}{\left(\frac{\lambda_1}{\lambda_2}\right)}\right)\right)\right) \]
            5. /-lowering-/.f6440.1%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\lambda_2, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(\lambda_1, \color{blue}{\lambda_2}\right)\right)\right)\right) \]
          13. Simplified40.1%

            \[\leadsto R \cdot \color{blue}{\left(\lambda_2 \cdot \left(1 - \frac{\lambda_1}{\lambda_2}\right)\right)} \]
        3. Recombined 2 regimes into one program.
        4. Add Preprocessing

        Alternative 12: 85.4% 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 54.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. *-lowering-*.f64N/A

            \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
          2. hypot-defineN/A

            \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
          3. hypot-lowering-hypot.f64N/A

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
          4. *-lowering-*.f64N/A

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
          5. --lowering--.f64N/A

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
          6. cos-lowering-cos.f64N/A

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
          7. /-lowering-/.f64N/A

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
          8. +-lowering-+.f64N/A

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
          9. --lowering--.f6494.4%

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
        3. Simplified94.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. Add Preprocessing
        5. Taylor expanded in phi1 around 0

          \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \color{blue}{\left(\cos \left(\frac{1}{2} \cdot \phi_2\right) + \frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)}\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
        6. Step-by-step derivation
          1. +-lowering-+.f64N/A

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\cos \left(\frac{1}{2} \cdot \phi_2\right), \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          2. cos-lowering-cos.f64N/A

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\left(\frac{1}{2} \cdot \phi_2\right)\right), \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          3. *-lowering-*.f64N/A

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          4. *-commutativeN/A

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right) \cdot \frac{-1}{2}\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          5. *-commutativeN/A

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\left(\sin \left(\frac{1}{2} \cdot \phi_2\right) \cdot \phi_1\right) \cdot \frac{-1}{2}\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          6. associate-*l*N/A

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\sin \left(\frac{1}{2} \cdot \phi_2\right) \cdot \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          7. *-lowering-*.f64N/A

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\sin \left(\frac{1}{2} \cdot \phi_2\right), \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          8. sin-lowering-sin.f64N/A

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\left(\frac{1}{2} \cdot \phi_2\right)\right), \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          9. *-lowering-*.f64N/A

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          10. *-lowering-*.f6481.3%

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\phi_1, \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
        7. Simplified81.3%

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

          \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\color{blue}{\left(\lambda_1 - \lambda_2\right)}, \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
        9. Step-by-step derivation
          1. --lowering--.f6483.1%

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{\_.f64}\left(\color{blue}{\phi_1}, \phi_2\right)\right)\right) \]
        10. Simplified83.1%

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

        Alternative 13: 32.5% accurate, 10.0× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\phi_1 \leq -3 \cdot 10^{+17}:\\ \;\;\;\;\phi_1 \cdot \left(\frac{R \cdot \phi_2}{\phi_1} - R\right)\\ \mathbf{elif}\;\phi_1 \leq 2.55 \cdot 10^{-204}:\\ \;\;\;\;\lambda_1 \cdot \left(\frac{R \cdot \lambda_2 + \frac{-0.5 \cdot \left(R \cdot \left(\left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)\right)\right)}{\lambda_1}}{\lambda_1} - R\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \phi_2\\ \end{array} \end{array} \]
        (FPCore (R lambda1 lambda2 phi1 phi2)
         :precision binary64
         (if (<= phi1 -3e+17)
           (* phi1 (- (/ (* R phi2) phi1) R))
           (if (<= phi1 2.55e-204)
             (*
              lambda1
              (-
               (/
                (+
                 (* R lambda2)
                 (/ (* -0.5 (* R (* (- phi1 phi2) (- phi1 phi2)))) lambda1))
                lambda1)
               R))
             (* R phi2))))
        double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
        	double tmp;
        	if (phi1 <= -3e+17) {
        		tmp = phi1 * (((R * phi2) / phi1) - R);
        	} else if (phi1 <= 2.55e-204) {
        		tmp = lambda1 * ((((R * lambda2) + ((-0.5 * (R * ((phi1 - phi2) * (phi1 - phi2)))) / lambda1)) / lambda1) - R);
        	} 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 (phi1 <= (-3d+17)) then
                tmp = phi1 * (((r * phi2) / phi1) - r)
            else if (phi1 <= 2.55d-204) then
                tmp = lambda1 * ((((r * lambda2) + (((-0.5d0) * (r * ((phi1 - phi2) * (phi1 - phi2)))) / lambda1)) / lambda1) - r)
            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 (phi1 <= -3e+17) {
        		tmp = phi1 * (((R * phi2) / phi1) - R);
        	} else if (phi1 <= 2.55e-204) {
        		tmp = lambda1 * ((((R * lambda2) + ((-0.5 * (R * ((phi1 - phi2) * (phi1 - phi2)))) / lambda1)) / lambda1) - R);
        	} else {
        		tmp = R * phi2;
        	}
        	return tmp;
        }
        
        def code(R, lambda1, lambda2, phi1, phi2):
        	tmp = 0
        	if phi1 <= -3e+17:
        		tmp = phi1 * (((R * phi2) / phi1) - R)
        	elif phi1 <= 2.55e-204:
        		tmp = lambda1 * ((((R * lambda2) + ((-0.5 * (R * ((phi1 - phi2) * (phi1 - phi2)))) / lambda1)) / lambda1) - R)
        	else:
        		tmp = R * phi2
        	return tmp
        
        function code(R, lambda1, lambda2, phi1, phi2)
        	tmp = 0.0
        	if (phi1 <= -3e+17)
        		tmp = Float64(phi1 * Float64(Float64(Float64(R * phi2) / phi1) - R));
        	elseif (phi1 <= 2.55e-204)
        		tmp = Float64(lambda1 * Float64(Float64(Float64(Float64(R * lambda2) + Float64(Float64(-0.5 * Float64(R * Float64(Float64(phi1 - phi2) * Float64(phi1 - phi2)))) / lambda1)) / lambda1) - R));
        	else
        		tmp = Float64(R * phi2);
        	end
        	return tmp
        end
        
        function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
        	tmp = 0.0;
        	if (phi1 <= -3e+17)
        		tmp = phi1 * (((R * phi2) / phi1) - R);
        	elseif (phi1 <= 2.55e-204)
        		tmp = lambda1 * ((((R * lambda2) + ((-0.5 * (R * ((phi1 - phi2) * (phi1 - phi2)))) / lambda1)) / lambda1) - R);
        	else
        		tmp = R * phi2;
        	end
        	tmp_2 = tmp;
        end
        
        code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -3e+17], N[(phi1 * N[(N[(N[(R * phi2), $MachinePrecision] / phi1), $MachinePrecision] - R), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 2.55e-204], N[(lambda1 * N[(N[(N[(N[(R * lambda2), $MachinePrecision] + N[(N[(-0.5 * N[(R * N[(N[(phi1 - phi2), $MachinePrecision] * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / lambda1), $MachinePrecision]), $MachinePrecision] / lambda1), $MachinePrecision] - R), $MachinePrecision]), $MachinePrecision], N[(R * phi2), $MachinePrecision]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;\phi_1 \leq -3 \cdot 10^{+17}:\\
        \;\;\;\;\phi_1 \cdot \left(\frac{R \cdot \phi_2}{\phi_1} - R\right)\\
        
        \mathbf{elif}\;\phi_1 \leq 2.55 \cdot 10^{-204}:\\
        \;\;\;\;\lambda_1 \cdot \left(\frac{R \cdot \lambda_2 + \frac{-0.5 \cdot \left(R \cdot \left(\left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)\right)\right)}{\lambda_1}}{\lambda_1} - R\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;R \cdot \phi_2\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if phi1 < -3e17

          1. Initial program 55.6%

            \[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. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
            2. hypot-defineN/A

              \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
            3. hypot-lowering-hypot.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
            4. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
            5. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            6. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            8. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            9. --lowering--.f6489.1%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
          3. Simplified89.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)} \]
          4. Add Preprocessing
          5. Taylor expanded in phi1 around -inf

            \[\leadsto \color{blue}{-1 \cdot \left(\phi_1 \cdot \left(R + -1 \cdot \frac{R \cdot \phi_2}{\phi_1}\right)\right)} \]
          6. Step-by-step derivation
            1. mul-1-negN/A

              \[\leadsto \mathsf{neg}\left(\phi_1 \cdot \left(R + -1 \cdot \frac{R \cdot \phi_2}{\phi_1}\right)\right) \]
            2. neg-sub0N/A

              \[\leadsto 0 - \color{blue}{\phi_1 \cdot \left(R + -1 \cdot \frac{R \cdot \phi_2}{\phi_1}\right)} \]
            3. --lowering--.f64N/A

              \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{\left(\phi_1 \cdot \left(R + -1 \cdot \frac{R \cdot \phi_2}{\phi_1}\right)\right)}\right) \]
            4. *-lowering-*.f64N/A

              \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(\phi_1, \color{blue}{\left(R + -1 \cdot \frac{R \cdot \phi_2}{\phi_1}\right)}\right)\right) \]
            5. mul-1-negN/A

              \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(\phi_1, \left(R + \left(\mathsf{neg}\left(\frac{R \cdot \phi_2}{\phi_1}\right)\right)\right)\right)\right) \]
            6. unsub-negN/A

              \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(\phi_1, \left(R - \color{blue}{\frac{R \cdot \phi_2}{\phi_1}}\right)\right)\right) \]
            7. --lowering--.f64N/A

              \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(\phi_1, \mathsf{\_.f64}\left(R, \color{blue}{\left(\frac{R \cdot \phi_2}{\phi_1}\right)}\right)\right)\right) \]
            8. /-lowering-/.f64N/A

              \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(\phi_1, \mathsf{\_.f64}\left(R, \mathsf{/.f64}\left(\left(R \cdot \phi_2\right), \color{blue}{\phi_1}\right)\right)\right)\right) \]
            9. *-lowering-*.f6460.2%

              \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(\phi_1, \mathsf{\_.f64}\left(R, \mathsf{/.f64}\left(\mathsf{*.f64}\left(R, \phi_2\right), \phi_1\right)\right)\right)\right) \]
          7. Simplified60.2%

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

          if -3e17 < phi1 < 2.55000000000000014e-204

          1. Initial program 60.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. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
            2. hypot-defineN/A

              \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
            3. hypot-lowering-hypot.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
            4. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
            5. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            6. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            8. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            9. --lowering--.f6499.2%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
          3. Simplified99.2%

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

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \color{blue}{\left(\cos \left(\frac{1}{2} \cdot \phi_2\right) + \frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)}\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          6. Step-by-step derivation
            1. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\cos \left(\frac{1}{2} \cdot \phi_2\right), \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            2. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\left(\frac{1}{2} \cdot \phi_2\right)\right), \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            3. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            4. *-commutativeN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right) \cdot \frac{-1}{2}\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            5. *-commutativeN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\left(\sin \left(\frac{1}{2} \cdot \phi_2\right) \cdot \phi_1\right) \cdot \frac{-1}{2}\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            6. associate-*l*N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\sin \left(\frac{1}{2} \cdot \phi_2\right) \cdot \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            7. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\sin \left(\frac{1}{2} \cdot \phi_2\right), \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            8. sin-lowering-sin.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\left(\frac{1}{2} \cdot \phi_2\right)\right), \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            9. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            10. *-lowering-*.f6498.4%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\phi_1, \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          7. Simplified98.4%

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

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\color{blue}{\left(\lambda_1 - \lambda_2\right)}, \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          9. Step-by-step derivation
            1. --lowering--.f6486.1%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{\_.f64}\left(\color{blue}{\phi_1}, \phi_2\right)\right)\right) \]
          10. Simplified86.1%

            \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\lambda_1 - \lambda_2}, \phi_1 - \phi_2\right) \]
          11. Taylor expanded in lambda1 around -inf

            \[\leadsto \color{blue}{-1 \cdot \left(\lambda_1 \cdot \left(R + -1 \cdot \frac{\frac{-1}{2} \cdot \frac{R \cdot {\left(\phi_1 - \phi_2\right)}^{2}}{\lambda_1} + R \cdot \lambda_2}{\lambda_1}\right)\right)} \]
          12. Step-by-step derivation
            1. mul-1-negN/A

              \[\leadsto \mathsf{neg}\left(\lambda_1 \cdot \left(R + -1 \cdot \frac{\frac{-1}{2} \cdot \frac{R \cdot {\left(\phi_1 - \phi_2\right)}^{2}}{\lambda_1} + R \cdot \lambda_2}{\lambda_1}\right)\right) \]
            2. *-commutativeN/A

              \[\leadsto \mathsf{neg}\left(\left(R + -1 \cdot \frac{\frac{-1}{2} \cdot \frac{R \cdot {\left(\phi_1 - \phi_2\right)}^{2}}{\lambda_1} + R \cdot \lambda_2}{\lambda_1}\right) \cdot \lambda_1\right) \]
            3. distribute-rgt-neg-inN/A

              \[\leadsto \left(R + -1 \cdot \frac{\frac{-1}{2} \cdot \frac{R \cdot {\left(\phi_1 - \phi_2\right)}^{2}}{\lambda_1} + R \cdot \lambda_2}{\lambda_1}\right) \cdot \color{blue}{\left(\mathsf{neg}\left(\lambda_1\right)\right)} \]
            4. mul-1-negN/A

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

              \[\leadsto \mathsf{*.f64}\left(\left(R + -1 \cdot \frac{\frac{-1}{2} \cdot \frac{R \cdot {\left(\phi_1 - \phi_2\right)}^{2}}{\lambda_1} + R \cdot \lambda_2}{\lambda_1}\right), \color{blue}{\left(-1 \cdot \lambda_1\right)}\right) \]
          13. Simplified25.8%

            \[\leadsto \color{blue}{\left(R - \frac{\lambda_2 \cdot R + \frac{-0.5 \cdot \left(R \cdot \left(\left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)\right)\right)}{\lambda_1}}{\lambda_1}\right) \cdot \left(0 - \lambda_1\right)} \]

          if 2.55000000000000014e-204 < phi1

          1. Initial program 50.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. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
            2. hypot-defineN/A

              \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
            3. hypot-lowering-hypot.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
            4. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
            5. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            6. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            8. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            9. --lowering--.f6493.7%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
          3. Simplified93.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. Add Preprocessing
          5. Taylor expanded in phi2 around inf

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

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\phi_2}\right) \]
          7. Simplified12.5%

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

          \[\leadsto \begin{array}{l} \mathbf{if}\;\phi_1 \leq -3 \cdot 10^{+17}:\\ \;\;\;\;\phi_1 \cdot \left(\frac{R \cdot \phi_2}{\phi_1} - R\right)\\ \mathbf{elif}\;\phi_1 \leq 2.55 \cdot 10^{-204}:\\ \;\;\;\;\lambda_1 \cdot \left(\frac{R \cdot \lambda_2 + \frac{-0.5 \cdot \left(R \cdot \left(\left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)\right)\right)}{\lambda_1}}{\lambda_1} - R\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \phi_2\\ \end{array} \]
        5. Add Preprocessing

        Alternative 14: 32.7% accurate, 10.6× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\phi_1 \leq -4.2 \cdot 10^{+17}:\\ \;\;\;\;\phi_1 \cdot \left(\frac{R \cdot \phi_2}{\phi_1} - R\right)\\ \mathbf{elif}\;\phi_1 \leq 3.3 \cdot 10^{-204}:\\ \;\;\;\;R \cdot \left(\lambda_1 \cdot \left(\frac{\lambda_2 + \frac{-0.5 \cdot \left(\left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)\right)}{\lambda_1}}{\lambda_1} + -1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \phi_2\\ \end{array} \end{array} \]
        (FPCore (R lambda1 lambda2 phi1 phi2)
         :precision binary64
         (if (<= phi1 -4.2e+17)
           (* phi1 (- (/ (* R phi2) phi1) R))
           (if (<= phi1 3.3e-204)
             (*
              R
              (*
               lambda1
               (+
                (/
                 (+ lambda2 (/ (* -0.5 (* (- phi1 phi2) (- phi1 phi2))) lambda1))
                 lambda1)
                -1.0)))
             (* R phi2))))
        double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
        	double tmp;
        	if (phi1 <= -4.2e+17) {
        		tmp = phi1 * (((R * phi2) / phi1) - R);
        	} else if (phi1 <= 3.3e-204) {
        		tmp = R * (lambda1 * (((lambda2 + ((-0.5 * ((phi1 - phi2) * (phi1 - phi2))) / lambda1)) / lambda1) + -1.0));
        	} 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 (phi1 <= (-4.2d+17)) then
                tmp = phi1 * (((r * phi2) / phi1) - r)
            else if (phi1 <= 3.3d-204) then
                tmp = r * (lambda1 * (((lambda2 + (((-0.5d0) * ((phi1 - phi2) * (phi1 - phi2))) / lambda1)) / lambda1) + (-1.0d0)))
            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 (phi1 <= -4.2e+17) {
        		tmp = phi1 * (((R * phi2) / phi1) - R);
        	} else if (phi1 <= 3.3e-204) {
        		tmp = R * (lambda1 * (((lambda2 + ((-0.5 * ((phi1 - phi2) * (phi1 - phi2))) / lambda1)) / lambda1) + -1.0));
        	} else {
        		tmp = R * phi2;
        	}
        	return tmp;
        }
        
        def code(R, lambda1, lambda2, phi1, phi2):
        	tmp = 0
        	if phi1 <= -4.2e+17:
        		tmp = phi1 * (((R * phi2) / phi1) - R)
        	elif phi1 <= 3.3e-204:
        		tmp = R * (lambda1 * (((lambda2 + ((-0.5 * ((phi1 - phi2) * (phi1 - phi2))) / lambda1)) / lambda1) + -1.0))
        	else:
        		tmp = R * phi2
        	return tmp
        
        function code(R, lambda1, lambda2, phi1, phi2)
        	tmp = 0.0
        	if (phi1 <= -4.2e+17)
        		tmp = Float64(phi1 * Float64(Float64(Float64(R * phi2) / phi1) - R));
        	elseif (phi1 <= 3.3e-204)
        		tmp = Float64(R * Float64(lambda1 * Float64(Float64(Float64(lambda2 + Float64(Float64(-0.5 * Float64(Float64(phi1 - phi2) * Float64(phi1 - phi2))) / lambda1)) / lambda1) + -1.0)));
        	else
        		tmp = Float64(R * phi2);
        	end
        	return tmp
        end
        
        function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
        	tmp = 0.0;
        	if (phi1 <= -4.2e+17)
        		tmp = phi1 * (((R * phi2) / phi1) - R);
        	elseif (phi1 <= 3.3e-204)
        		tmp = R * (lambda1 * (((lambda2 + ((-0.5 * ((phi1 - phi2) * (phi1 - phi2))) / lambda1)) / lambda1) + -1.0));
        	else
        		tmp = R * phi2;
        	end
        	tmp_2 = tmp;
        end
        
        code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -4.2e+17], N[(phi1 * N[(N[(N[(R * phi2), $MachinePrecision] / phi1), $MachinePrecision] - R), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 3.3e-204], N[(R * N[(lambda1 * N[(N[(N[(lambda2 + N[(N[(-0.5 * N[(N[(phi1 - phi2), $MachinePrecision] * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / lambda1), $MachinePrecision]), $MachinePrecision] / lambda1), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * phi2), $MachinePrecision]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;\phi_1 \leq -4.2 \cdot 10^{+17}:\\
        \;\;\;\;\phi_1 \cdot \left(\frac{R \cdot \phi_2}{\phi_1} - R\right)\\
        
        \mathbf{elif}\;\phi_1 \leq 3.3 \cdot 10^{-204}:\\
        \;\;\;\;R \cdot \left(\lambda_1 \cdot \left(\frac{\lambda_2 + \frac{-0.5 \cdot \left(\left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)\right)}{\lambda_1}}{\lambda_1} + -1\right)\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;R \cdot \phi_2\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if phi1 < -4.2e17

          1. Initial program 55.6%

            \[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. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
            2. hypot-defineN/A

              \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
            3. hypot-lowering-hypot.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
            4. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
            5. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            6. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            8. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            9. --lowering--.f6489.1%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
          3. Simplified89.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)} \]
          4. Add Preprocessing
          5. Taylor expanded in phi1 around -inf

            \[\leadsto \color{blue}{-1 \cdot \left(\phi_1 \cdot \left(R + -1 \cdot \frac{R \cdot \phi_2}{\phi_1}\right)\right)} \]
          6. Step-by-step derivation
            1. mul-1-negN/A

              \[\leadsto \mathsf{neg}\left(\phi_1 \cdot \left(R + -1 \cdot \frac{R \cdot \phi_2}{\phi_1}\right)\right) \]
            2. neg-sub0N/A

              \[\leadsto 0 - \color{blue}{\phi_1 \cdot \left(R + -1 \cdot \frac{R \cdot \phi_2}{\phi_1}\right)} \]
            3. --lowering--.f64N/A

              \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{\left(\phi_1 \cdot \left(R + -1 \cdot \frac{R \cdot \phi_2}{\phi_1}\right)\right)}\right) \]
            4. *-lowering-*.f64N/A

              \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(\phi_1, \color{blue}{\left(R + -1 \cdot \frac{R \cdot \phi_2}{\phi_1}\right)}\right)\right) \]
            5. mul-1-negN/A

              \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(\phi_1, \left(R + \left(\mathsf{neg}\left(\frac{R \cdot \phi_2}{\phi_1}\right)\right)\right)\right)\right) \]
            6. unsub-negN/A

              \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(\phi_1, \left(R - \color{blue}{\frac{R \cdot \phi_2}{\phi_1}}\right)\right)\right) \]
            7. --lowering--.f64N/A

              \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(\phi_1, \mathsf{\_.f64}\left(R, \color{blue}{\left(\frac{R \cdot \phi_2}{\phi_1}\right)}\right)\right)\right) \]
            8. /-lowering-/.f64N/A

              \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(\phi_1, \mathsf{\_.f64}\left(R, \mathsf{/.f64}\left(\left(R \cdot \phi_2\right), \color{blue}{\phi_1}\right)\right)\right)\right) \]
            9. *-lowering-*.f6460.2%

              \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(\phi_1, \mathsf{\_.f64}\left(R, \mathsf{/.f64}\left(\mathsf{*.f64}\left(R, \phi_2\right), \phi_1\right)\right)\right)\right) \]
          7. Simplified60.2%

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

          if -4.2e17 < phi1 < 3.30000000000000009e-204

          1. Initial program 60.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. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
            2. hypot-defineN/A

              \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
            3. hypot-lowering-hypot.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
            4. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
            5. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            6. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            8. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            9. --lowering--.f6499.2%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
          3. Simplified99.2%

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

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \color{blue}{\left(\cos \left(\frac{1}{2} \cdot \phi_2\right) + \frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)}\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          6. Step-by-step derivation
            1. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\cos \left(\frac{1}{2} \cdot \phi_2\right), \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            2. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\left(\frac{1}{2} \cdot \phi_2\right)\right), \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            3. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            4. *-commutativeN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right) \cdot \frac{-1}{2}\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            5. *-commutativeN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\left(\sin \left(\frac{1}{2} \cdot \phi_2\right) \cdot \phi_1\right) \cdot \frac{-1}{2}\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            6. associate-*l*N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\sin \left(\frac{1}{2} \cdot \phi_2\right) \cdot \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            7. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\sin \left(\frac{1}{2} \cdot \phi_2\right), \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            8. sin-lowering-sin.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\left(\frac{1}{2} \cdot \phi_2\right)\right), \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            9. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            10. *-lowering-*.f6498.4%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\phi_1, \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          7. Simplified98.4%

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

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\color{blue}{\left(\lambda_1 - \lambda_2\right)}, \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          9. Step-by-step derivation
            1. --lowering--.f6486.1%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{\_.f64}\left(\color{blue}{\phi_1}, \phi_2\right)\right)\right) \]
          10. Simplified86.1%

            \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\lambda_1 - \lambda_2}, \phi_1 - \phi_2\right) \]
          11. Taylor expanded in lambda1 around -inf

            \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(-1 \cdot \left(\lambda_1 \cdot \left(1 + -1 \cdot \frac{\lambda_2 + \frac{-1}{2} \cdot \frac{{\left(\phi_1 - \phi_2\right)}^{2}}{\lambda_1}}{\lambda_1}\right)\right)\right)}\right) \]
          12. Step-by-step derivation
            1. associate-*r*N/A

              \[\leadsto \mathsf{*.f64}\left(R, \left(\left(-1 \cdot \lambda_1\right) \cdot \color{blue}{\left(1 + -1 \cdot \frac{\lambda_2 + \frac{-1}{2} \cdot \frac{{\left(\phi_1 - \phi_2\right)}^{2}}{\lambda_1}}{\lambda_1}\right)}\right)\right) \]
            2. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\left(-1 \cdot \lambda_1\right), \color{blue}{\left(1 + -1 \cdot \frac{\lambda_2 + \frac{-1}{2} \cdot \frac{{\left(\phi_1 - \phi_2\right)}^{2}}{\lambda_1}}{\lambda_1}\right)}\right)\right) \]
            3. mul-1-negN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\left(\mathsf{neg}\left(\lambda_1\right)\right), \left(\color{blue}{1} + -1 \cdot \frac{\lambda_2 + \frac{-1}{2} \cdot \frac{{\left(\phi_1 - \phi_2\right)}^{2}}{\lambda_1}}{\lambda_1}\right)\right)\right) \]
            4. neg-sub0N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\left(0 - \lambda_1\right), \left(\color{blue}{1} + -1 \cdot \frac{\lambda_2 + \frac{-1}{2} \cdot \frac{{\left(\phi_1 - \phi_2\right)}^{2}}{\lambda_1}}{\lambda_1}\right)\right)\right) \]
            5. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, \lambda_1\right), \left(\color{blue}{1} + -1 \cdot \frac{\lambda_2 + \frac{-1}{2} \cdot \frac{{\left(\phi_1 - \phi_2\right)}^{2}}{\lambda_1}}{\lambda_1}\right)\right)\right) \]
            6. mul-1-negN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, \lambda_1\right), \left(1 + \left(\mathsf{neg}\left(\frac{\lambda_2 + \frac{-1}{2} \cdot \frac{{\left(\phi_1 - \phi_2\right)}^{2}}{\lambda_1}}{\lambda_1}\right)\right)\right)\right)\right) \]
            7. unsub-negN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, \lambda_1\right), \left(1 - \color{blue}{\frac{\lambda_2 + \frac{-1}{2} \cdot \frac{{\left(\phi_1 - \phi_2\right)}^{2}}{\lambda_1}}{\lambda_1}}\right)\right)\right) \]
            8. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, \lambda_1\right), \mathsf{\_.f64}\left(1, \color{blue}{\left(\frac{\lambda_2 + \frac{-1}{2} \cdot \frac{{\left(\phi_1 - \phi_2\right)}^{2}}{\lambda_1}}{\lambda_1}\right)}\right)\right)\right) \]
            9. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, \lambda_1\right), \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(\left(\lambda_2 + \frac{-1}{2} \cdot \frac{{\left(\phi_1 - \phi_2\right)}^{2}}{\lambda_1}\right), \color{blue}{\lambda_1}\right)\right)\right)\right) \]
            10. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, \lambda_1\right), \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\lambda_2, \left(\frac{-1}{2} \cdot \frac{{\left(\phi_1 - \phi_2\right)}^{2}}{\lambda_1}\right)\right), \lambda_1\right)\right)\right)\right) \]
            11. associate-*r/N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, \lambda_1\right), \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\lambda_2, \left(\frac{\frac{-1}{2} \cdot {\left(\phi_1 - \phi_2\right)}^{2}}{\lambda_1}\right)\right), \lambda_1\right)\right)\right)\right) \]
            12. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, \lambda_1\right), \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\lambda_2, \mathsf{/.f64}\left(\left(\frac{-1}{2} \cdot {\left(\phi_1 - \phi_2\right)}^{2}\right), \lambda_1\right)\right), \lambda_1\right)\right)\right)\right) \]
            13. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, \lambda_1\right), \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\lambda_2, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{-1}{2}, \left({\left(\phi_1 - \phi_2\right)}^{2}\right)\right), \lambda_1\right)\right), \lambda_1\right)\right)\right)\right) \]
            14. unpow2N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, \lambda_1\right), \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\lambda_2, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{-1}{2}, \left(\left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)\right)\right), \lambda_1\right)\right), \lambda_1\right)\right)\right)\right) \]
            15. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, \lambda_1\right), \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\lambda_2, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(\left(\phi_1 - \phi_2\right), \left(\phi_1 - \phi_2\right)\right)\right), \lambda_1\right)\right), \lambda_1\right)\right)\right)\right) \]
            16. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, \lambda_1\right), \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\lambda_2, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\phi_1, \phi_2\right), \left(\phi_1 - \phi_2\right)\right)\right), \lambda_1\right)\right), \lambda_1\right)\right)\right)\right) \]
            17. --lowering--.f6428.0%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, \lambda_1\right), \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\lambda_2, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\phi_1, \phi_2\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right), \lambda_1\right)\right), \lambda_1\right)\right)\right)\right) \]
          13. Simplified28.0%

            \[\leadsto R \cdot \color{blue}{\left(\left(0 - \lambda_1\right) \cdot \left(1 - \frac{\lambda_2 + \frac{-0.5 \cdot \left(\left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)\right)}{\lambda_1}}{\lambda_1}\right)\right)} \]

          if 3.30000000000000009e-204 < phi1

          1. Initial program 50.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. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
            2. hypot-defineN/A

              \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
            3. hypot-lowering-hypot.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
            4. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
            5. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            6. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            8. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            9. --lowering--.f6493.7%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
          3. Simplified93.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. Add Preprocessing
          5. Taylor expanded in phi2 around inf

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

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\phi_2}\right) \]
          7. Simplified12.5%

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

          \[\leadsto \begin{array}{l} \mathbf{if}\;\phi_1 \leq -4.2 \cdot 10^{+17}:\\ \;\;\;\;\phi_1 \cdot \left(\frac{R \cdot \phi_2}{\phi_1} - R\right)\\ \mathbf{elif}\;\phi_1 \leq 3.3 \cdot 10^{-204}:\\ \;\;\;\;R \cdot \left(\lambda_1 \cdot \left(\frac{\lambda_2 + \frac{-0.5 \cdot \left(\left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)\right)}{\lambda_1}}{\lambda_1} + -1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \phi_2\\ \end{array} \]
        5. Add Preprocessing

        Alternative 15: 32.5% accurate, 17.3× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\phi_1 \leq -3.2 \cdot 10^{+17}:\\ \;\;\;\;\phi_1 \cdot \left(\frac{R \cdot \phi_2}{\phi_1} - R\right)\\ \mathbf{elif}\;\phi_1 \leq 3.5 \cdot 10^{-204}:\\ \;\;\;\;\lambda_2 \cdot \left(R - \frac{R \cdot \lambda_1}{\lambda_2}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \phi_2\\ \end{array} \end{array} \]
        (FPCore (R lambda1 lambda2 phi1 phi2)
         :precision binary64
         (if (<= phi1 -3.2e+17)
           (* phi1 (- (/ (* R phi2) phi1) R))
           (if (<= phi1 3.5e-204)
             (* lambda2 (- R (/ (* R lambda1) lambda2)))
             (* R phi2))))
        double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
        	double tmp;
        	if (phi1 <= -3.2e+17) {
        		tmp = phi1 * (((R * phi2) / phi1) - R);
        	} else if (phi1 <= 3.5e-204) {
        		tmp = lambda2 * (R - ((R * lambda1) / 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 (phi1 <= (-3.2d+17)) then
                tmp = phi1 * (((r * phi2) / phi1) - r)
            else if (phi1 <= 3.5d-204) then
                tmp = lambda2 * (r - ((r * lambda1) / 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 (phi1 <= -3.2e+17) {
        		tmp = phi1 * (((R * phi2) / phi1) - R);
        	} else if (phi1 <= 3.5e-204) {
        		tmp = lambda2 * (R - ((R * lambda1) / lambda2));
        	} else {
        		tmp = R * phi2;
        	}
        	return tmp;
        }
        
        def code(R, lambda1, lambda2, phi1, phi2):
        	tmp = 0
        	if phi1 <= -3.2e+17:
        		tmp = phi1 * (((R * phi2) / phi1) - R)
        	elif phi1 <= 3.5e-204:
        		tmp = lambda2 * (R - ((R * lambda1) / lambda2))
        	else:
        		tmp = R * phi2
        	return tmp
        
        function code(R, lambda1, lambda2, phi1, phi2)
        	tmp = 0.0
        	if (phi1 <= -3.2e+17)
        		tmp = Float64(phi1 * Float64(Float64(Float64(R * phi2) / phi1) - R));
        	elseif (phi1 <= 3.5e-204)
        		tmp = Float64(lambda2 * Float64(R - Float64(Float64(R * lambda1) / lambda2)));
        	else
        		tmp = Float64(R * phi2);
        	end
        	return tmp
        end
        
        function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
        	tmp = 0.0;
        	if (phi1 <= -3.2e+17)
        		tmp = phi1 * (((R * phi2) / phi1) - R);
        	elseif (phi1 <= 3.5e-204)
        		tmp = lambda2 * (R - ((R * lambda1) / lambda2));
        	else
        		tmp = R * phi2;
        	end
        	tmp_2 = tmp;
        end
        
        code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -3.2e+17], N[(phi1 * N[(N[(N[(R * phi2), $MachinePrecision] / phi1), $MachinePrecision] - R), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 3.5e-204], N[(lambda2 * N[(R - N[(N[(R * lambda1), $MachinePrecision] / lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * phi2), $MachinePrecision]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;\phi_1 \leq -3.2 \cdot 10^{+17}:\\
        \;\;\;\;\phi_1 \cdot \left(\frac{R \cdot \phi_2}{\phi_1} - R\right)\\
        
        \mathbf{elif}\;\phi_1 \leq 3.5 \cdot 10^{-204}:\\
        \;\;\;\;\lambda_2 \cdot \left(R - \frac{R \cdot \lambda_1}{\lambda_2}\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;R \cdot \phi_2\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if phi1 < -3.2e17

          1. Initial program 55.6%

            \[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. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
            2. hypot-defineN/A

              \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
            3. hypot-lowering-hypot.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
            4. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
            5. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            6. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            8. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            9. --lowering--.f6489.1%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
          3. Simplified89.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)} \]
          4. Add Preprocessing
          5. Taylor expanded in phi1 around -inf

            \[\leadsto \color{blue}{-1 \cdot \left(\phi_1 \cdot \left(R + -1 \cdot \frac{R \cdot \phi_2}{\phi_1}\right)\right)} \]
          6. Step-by-step derivation
            1. mul-1-negN/A

              \[\leadsto \mathsf{neg}\left(\phi_1 \cdot \left(R + -1 \cdot \frac{R \cdot \phi_2}{\phi_1}\right)\right) \]
            2. neg-sub0N/A

              \[\leadsto 0 - \color{blue}{\phi_1 \cdot \left(R + -1 \cdot \frac{R \cdot \phi_2}{\phi_1}\right)} \]
            3. --lowering--.f64N/A

              \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{\left(\phi_1 \cdot \left(R + -1 \cdot \frac{R \cdot \phi_2}{\phi_1}\right)\right)}\right) \]
            4. *-lowering-*.f64N/A

              \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(\phi_1, \color{blue}{\left(R + -1 \cdot \frac{R \cdot \phi_2}{\phi_1}\right)}\right)\right) \]
            5. mul-1-negN/A

              \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(\phi_1, \left(R + \left(\mathsf{neg}\left(\frac{R \cdot \phi_2}{\phi_1}\right)\right)\right)\right)\right) \]
            6. unsub-negN/A

              \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(\phi_1, \left(R - \color{blue}{\frac{R \cdot \phi_2}{\phi_1}}\right)\right)\right) \]
            7. --lowering--.f64N/A

              \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(\phi_1, \mathsf{\_.f64}\left(R, \color{blue}{\left(\frac{R \cdot \phi_2}{\phi_1}\right)}\right)\right)\right) \]
            8. /-lowering-/.f64N/A

              \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(\phi_1, \mathsf{\_.f64}\left(R, \mathsf{/.f64}\left(\left(R \cdot \phi_2\right), \color{blue}{\phi_1}\right)\right)\right)\right) \]
            9. *-lowering-*.f6460.2%

              \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(\phi_1, \mathsf{\_.f64}\left(R, \mathsf{/.f64}\left(\mathsf{*.f64}\left(R, \phi_2\right), \phi_1\right)\right)\right)\right) \]
          7. Simplified60.2%

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

          if -3.2e17 < phi1 < 3.50000000000000027e-204

          1. Initial program 60.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. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
            2. hypot-defineN/A

              \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
            3. hypot-lowering-hypot.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
            4. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
            5. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            6. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            8. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            9. --lowering--.f6499.2%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
          3. Simplified99.2%

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

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \color{blue}{\left(\cos \left(\frac{1}{2} \cdot \phi_2\right) + \frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)}\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          6. Step-by-step derivation
            1. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\cos \left(\frac{1}{2} \cdot \phi_2\right), \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            2. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\left(\frac{1}{2} \cdot \phi_2\right)\right), \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            3. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            4. *-commutativeN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right) \cdot \frac{-1}{2}\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            5. *-commutativeN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\left(\sin \left(\frac{1}{2} \cdot \phi_2\right) \cdot \phi_1\right) \cdot \frac{-1}{2}\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            6. associate-*l*N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\sin \left(\frac{1}{2} \cdot \phi_2\right) \cdot \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            7. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\sin \left(\frac{1}{2} \cdot \phi_2\right), \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            8. sin-lowering-sin.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\left(\frac{1}{2} \cdot \phi_2\right)\right), \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            9. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            10. *-lowering-*.f6498.4%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\phi_1, \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          7. Simplified98.4%

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

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\color{blue}{\left(\lambda_1 - \lambda_2\right)}, \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          9. Step-by-step derivation
            1. --lowering--.f6486.1%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{\_.f64}\left(\color{blue}{\phi_1}, \phi_2\right)\right)\right) \]
          10. Simplified86.1%

            \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\lambda_1 - \lambda_2}, \phi_1 - \phi_2\right) \]
          11. Taylor expanded in lambda2 around inf

            \[\leadsto \color{blue}{\lambda_2 \cdot \left(R + -1 \cdot \frac{R \cdot \lambda_1}{\lambda_2}\right)} \]
          12. Step-by-step derivation
            1. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(\lambda_2, \color{blue}{\left(R + -1 \cdot \frac{R \cdot \lambda_1}{\lambda_2}\right)}\right) \]
            2. mul-1-negN/A

              \[\leadsto \mathsf{*.f64}\left(\lambda_2, \left(R + \left(\mathsf{neg}\left(\frac{R \cdot \lambda_1}{\lambda_2}\right)\right)\right)\right) \]
            3. unsub-negN/A

              \[\leadsto \mathsf{*.f64}\left(\lambda_2, \left(R - \color{blue}{\frac{R \cdot \lambda_1}{\lambda_2}}\right)\right) \]
            4. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(\lambda_2, \mathsf{\_.f64}\left(R, \color{blue}{\left(\frac{R \cdot \lambda_1}{\lambda_2}\right)}\right)\right) \]
            5. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(\lambda_2, \mathsf{\_.f64}\left(R, \mathsf{/.f64}\left(\left(R \cdot \lambda_1\right), \color{blue}{\lambda_2}\right)\right)\right) \]
            6. *-commutativeN/A

              \[\leadsto \mathsf{*.f64}\left(\lambda_2, \mathsf{\_.f64}\left(R, \mathsf{/.f64}\left(\left(\lambda_1 \cdot R\right), \lambda_2\right)\right)\right) \]
            7. *-lowering-*.f6426.3%

              \[\leadsto \mathsf{*.f64}\left(\lambda_2, \mathsf{\_.f64}\left(R, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\lambda_1, R\right), \lambda_2\right)\right)\right) \]
          13. Simplified26.3%

            \[\leadsto \color{blue}{\lambda_2 \cdot \left(R - \frac{\lambda_1 \cdot R}{\lambda_2}\right)} \]

          if 3.50000000000000027e-204 < phi1

          1. Initial program 50.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. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
            2. hypot-defineN/A

              \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
            3. hypot-lowering-hypot.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
            4. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
            5. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            6. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            8. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            9. --lowering--.f6493.7%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
          3. Simplified93.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. Add Preprocessing
          5. Taylor expanded in phi2 around inf

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

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\phi_2}\right) \]
          7. Simplified12.5%

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

          \[\leadsto \begin{array}{l} \mathbf{if}\;\phi_1 \leq -3.2 \cdot 10^{+17}:\\ \;\;\;\;\phi_1 \cdot \left(\frac{R \cdot \phi_2}{\phi_1} - R\right)\\ \mathbf{elif}\;\phi_1 \leq 3.5 \cdot 10^{-204}:\\ \;\;\;\;\lambda_2 \cdot \left(R - \frac{R \cdot \lambda_1}{\lambda_2}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \phi_2\\ \end{array} \]
        5. Add Preprocessing

        Alternative 16: 33.3% accurate, 17.3× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\phi_2 \leq -1.2 \cdot 10^{-224}:\\ \;\;\;\;\phi_1 \cdot \left(0 - R\right)\\ \mathbf{elif}\;\phi_2 \leq 1.75 \cdot 10^{+25}:\\ \;\;\;\;\lambda_2 \cdot \left(R - \frac{R \cdot \lambda_1}{\lambda_2}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(\phi_2 \cdot \left(1 - \frac{\phi_1}{\phi_2}\right)\right)\\ \end{array} \end{array} \]
        (FPCore (R lambda1 lambda2 phi1 phi2)
         :precision binary64
         (if (<= phi2 -1.2e-224)
           (* phi1 (- 0.0 R))
           (if (<= phi2 1.75e+25)
             (* lambda2 (- R (/ (* R lambda1) lambda2)))
             (* R (* phi2 (- 1.0 (/ phi1 phi2)))))))
        double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
        	double tmp;
        	if (phi2 <= -1.2e-224) {
        		tmp = phi1 * (0.0 - R);
        	} else if (phi2 <= 1.75e+25) {
        		tmp = lambda2 * (R - ((R * lambda1) / lambda2));
        	} else {
        		tmp = R * (phi2 * (1.0 - (phi1 / 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 <= (-1.2d-224)) then
                tmp = phi1 * (0.0d0 - r)
            else if (phi2 <= 1.75d+25) then
                tmp = lambda2 * (r - ((r * lambda1) / lambda2))
            else
                tmp = r * (phi2 * (1.0d0 - (phi1 / 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 <= -1.2e-224) {
        		tmp = phi1 * (0.0 - R);
        	} else if (phi2 <= 1.75e+25) {
        		tmp = lambda2 * (R - ((R * lambda1) / lambda2));
        	} else {
        		tmp = R * (phi2 * (1.0 - (phi1 / phi2)));
        	}
        	return tmp;
        }
        
        def code(R, lambda1, lambda2, phi1, phi2):
        	tmp = 0
        	if phi2 <= -1.2e-224:
        		tmp = phi1 * (0.0 - R)
        	elif phi2 <= 1.75e+25:
        		tmp = lambda2 * (R - ((R * lambda1) / lambda2))
        	else:
        		tmp = R * (phi2 * (1.0 - (phi1 / phi2)))
        	return tmp
        
        function code(R, lambda1, lambda2, phi1, phi2)
        	tmp = 0.0
        	if (phi2 <= -1.2e-224)
        		tmp = Float64(phi1 * Float64(0.0 - R));
        	elseif (phi2 <= 1.75e+25)
        		tmp = Float64(lambda2 * Float64(R - Float64(Float64(R * lambda1) / lambda2)));
        	else
        		tmp = Float64(R * Float64(phi2 * Float64(1.0 - Float64(phi1 / phi2))));
        	end
        	return tmp
        end
        
        function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
        	tmp = 0.0;
        	if (phi2 <= -1.2e-224)
        		tmp = phi1 * (0.0 - R);
        	elseif (phi2 <= 1.75e+25)
        		tmp = lambda2 * (R - ((R * lambda1) / lambda2));
        	else
        		tmp = R * (phi2 * (1.0 - (phi1 / phi2)));
        	end
        	tmp_2 = tmp;
        end
        
        code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, -1.2e-224], N[(phi1 * N[(0.0 - R), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 1.75e+25], N[(lambda2 * N[(R - N[(N[(R * lambda1), $MachinePrecision] / lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(phi2 * N[(1.0 - N[(phi1 / phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;\phi_2 \leq -1.2 \cdot 10^{-224}:\\
        \;\;\;\;\phi_1 \cdot \left(0 - R\right)\\
        
        \mathbf{elif}\;\phi_2 \leq 1.75 \cdot 10^{+25}:\\
        \;\;\;\;\lambda_2 \cdot \left(R - \frac{R \cdot \lambda_1}{\lambda_2}\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;R \cdot \left(\phi_2 \cdot \left(1 - \frac{\phi_1}{\phi_2}\right)\right)\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if phi2 < -1.20000000000000007e-224

          1. Initial program 59.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. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
            2. hypot-defineN/A

              \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
            3. hypot-lowering-hypot.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
            4. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
            5. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            6. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            8. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            9. --lowering--.f6495.0%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
          3. Simplified95.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. Add Preprocessing
          5. Taylor expanded in phi1 around -inf

            \[\leadsto \color{blue}{-1 \cdot \left(R \cdot \phi_1\right)} \]
          6. Step-by-step derivation
            1. mul-1-negN/A

              \[\leadsto \mathsf{neg}\left(R \cdot \phi_1\right) \]
            2. neg-sub0N/A

              \[\leadsto 0 - \color{blue}{R \cdot \phi_1} \]
            3. --lowering--.f64N/A

              \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{\left(R \cdot \phi_1\right)}\right) \]
            4. *-lowering-*.f6413.3%

              \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(R, \color{blue}{\phi_1}\right)\right) \]
          7. Simplified13.3%

            \[\leadsto \color{blue}{0 - R \cdot \phi_1} \]
          8. Step-by-step derivation
            1. sub0-negN/A

              \[\leadsto \mathsf{neg}\left(R \cdot \phi_1\right) \]
            2. neg-lowering-neg.f64N/A

              \[\leadsto \mathsf{neg.f64}\left(\left(R \cdot \phi_1\right)\right) \]
            3. *-commutativeN/A

              \[\leadsto \mathsf{neg.f64}\left(\left(\phi_1 \cdot R\right)\right) \]
            4. *-lowering-*.f6413.3%

              \[\leadsto \mathsf{neg.f64}\left(\mathsf{*.f64}\left(\phi_1, R\right)\right) \]
          9. Applied egg-rr13.3%

            \[\leadsto \color{blue}{-\phi_1 \cdot R} \]

          if -1.20000000000000007e-224 < phi2 < 1.75e25

          1. Initial program 58.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. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
            2. hypot-defineN/A

              \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
            3. hypot-lowering-hypot.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
            4. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
            5. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            6. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            8. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            9. --lowering--.f6498.0%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
          3. Simplified98.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. Add Preprocessing
          5. Taylor expanded in phi1 around 0

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \color{blue}{\left(\cos \left(\frac{1}{2} \cdot \phi_2\right) + \frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)}\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          6. Step-by-step derivation
            1. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\cos \left(\frac{1}{2} \cdot \phi_2\right), \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            2. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\left(\frac{1}{2} \cdot \phi_2\right)\right), \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            3. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            4. *-commutativeN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right) \cdot \frac{-1}{2}\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            5. *-commutativeN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\left(\sin \left(\frac{1}{2} \cdot \phi_2\right) \cdot \phi_1\right) \cdot \frac{-1}{2}\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            6. associate-*l*N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\sin \left(\frac{1}{2} \cdot \phi_2\right) \cdot \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            7. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\sin \left(\frac{1}{2} \cdot \phi_2\right), \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            8. sin-lowering-sin.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\left(\frac{1}{2} \cdot \phi_2\right)\right), \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            9. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            10. *-lowering-*.f6481.3%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\phi_1, \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          7. Simplified81.3%

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

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\color{blue}{\left(\lambda_1 - \lambda_2\right)}, \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          9. Step-by-step derivation
            1. --lowering--.f6486.6%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{\_.f64}\left(\color{blue}{\phi_1}, \phi_2\right)\right)\right) \]
          10. Simplified86.6%

            \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\lambda_1 - \lambda_2}, \phi_1 - \phi_2\right) \]
          11. Taylor expanded in lambda2 around inf

            \[\leadsto \color{blue}{\lambda_2 \cdot \left(R + -1 \cdot \frac{R \cdot \lambda_1}{\lambda_2}\right)} \]
          12. Step-by-step derivation
            1. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(\lambda_2, \color{blue}{\left(R + -1 \cdot \frac{R \cdot \lambda_1}{\lambda_2}\right)}\right) \]
            2. mul-1-negN/A

              \[\leadsto \mathsf{*.f64}\left(\lambda_2, \left(R + \left(\mathsf{neg}\left(\frac{R \cdot \lambda_1}{\lambda_2}\right)\right)\right)\right) \]
            3. unsub-negN/A

              \[\leadsto \mathsf{*.f64}\left(\lambda_2, \left(R - \color{blue}{\frac{R \cdot \lambda_1}{\lambda_2}}\right)\right) \]
            4. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(\lambda_2, \mathsf{\_.f64}\left(R, \color{blue}{\left(\frac{R \cdot \lambda_1}{\lambda_2}\right)}\right)\right) \]
            5. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(\lambda_2, \mathsf{\_.f64}\left(R, \mathsf{/.f64}\left(\left(R \cdot \lambda_1\right), \color{blue}{\lambda_2}\right)\right)\right) \]
            6. *-commutativeN/A

              \[\leadsto \mathsf{*.f64}\left(\lambda_2, \mathsf{\_.f64}\left(R, \mathsf{/.f64}\left(\left(\lambda_1 \cdot R\right), \lambda_2\right)\right)\right) \]
            7. *-lowering-*.f6424.6%

              \[\leadsto \mathsf{*.f64}\left(\lambda_2, \mathsf{\_.f64}\left(R, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\lambda_1, R\right), \lambda_2\right)\right)\right) \]
          13. Simplified24.6%

            \[\leadsto \color{blue}{\lambda_2 \cdot \left(R - \frac{\lambda_1 \cdot R}{\lambda_2}\right)} \]

          if 1.75e25 < phi2

          1. Initial program 40.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. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
            2. hypot-defineN/A

              \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
            3. hypot-lowering-hypot.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
            4. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
            5. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            6. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            8. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            9. --lowering--.f6487.7%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
          3. Simplified87.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. Add Preprocessing
          5. Taylor expanded in phi2 around inf

            \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\phi_2 \cdot \left(1 + -1 \cdot \frac{\phi_1}{\phi_2}\right)\right)}\right) \]
          6. Step-by-step derivation
            1. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\phi_2, \color{blue}{\left(1 + -1 \cdot \frac{\phi_1}{\phi_2}\right)}\right)\right) \]
            2. mul-1-negN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\phi_2, \left(1 + \left(\mathsf{neg}\left(\frac{\phi_1}{\phi_2}\right)\right)\right)\right)\right) \]
            3. unsub-negN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\phi_2, \left(1 - \color{blue}{\frac{\phi_1}{\phi_2}}\right)\right)\right) \]
            4. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\phi_2, \mathsf{\_.f64}\left(1, \color{blue}{\left(\frac{\phi_1}{\phi_2}\right)}\right)\right)\right) \]
            5. /-lowering-/.f6465.1%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\phi_2, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right)\right) \]
          7. Simplified65.1%

            \[\leadsto R \cdot \color{blue}{\left(\phi_2 \cdot \left(1 - \frac{\phi_1}{\phi_2}\right)\right)} \]
        3. Recombined 3 regimes into one program.
        4. Final simplification28.4%

          \[\leadsto \begin{array}{l} \mathbf{if}\;\phi_2 \leq -1.2 \cdot 10^{-224}:\\ \;\;\;\;\phi_1 \cdot \left(0 - R\right)\\ \mathbf{elif}\;\phi_2 \leq 1.75 \cdot 10^{+25}:\\ \;\;\;\;\lambda_2 \cdot \left(R - \frac{R \cdot \lambda_1}{\lambda_2}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(\phi_2 \cdot \left(1 - \frac{\phi_1}{\phi_2}\right)\right)\\ \end{array} \]
        5. Add Preprocessing

        Alternative 17: 32.9% accurate, 17.3× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\phi_2 \leq -2.2 \cdot 10^{-219}:\\ \;\;\;\;\phi_1 \cdot \left(0 - R\right)\\ \mathbf{elif}\;\phi_2 \leq 2.15 \cdot 10^{+23}:\\ \;\;\;\;R \cdot \left(\lambda_2 \cdot \left(1 - \frac{\lambda_1}{\lambda_2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(\phi_2 \cdot \left(1 - \frac{\phi_1}{\phi_2}\right)\right)\\ \end{array} \end{array} \]
        (FPCore (R lambda1 lambda2 phi1 phi2)
         :precision binary64
         (if (<= phi2 -2.2e-219)
           (* phi1 (- 0.0 R))
           (if (<= phi2 2.15e+23)
             (* R (* lambda2 (- 1.0 (/ lambda1 lambda2))))
             (* R (* phi2 (- 1.0 (/ phi1 phi2)))))))
        double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
        	double tmp;
        	if (phi2 <= -2.2e-219) {
        		tmp = phi1 * (0.0 - R);
        	} else if (phi2 <= 2.15e+23) {
        		tmp = R * (lambda2 * (1.0 - (lambda1 / lambda2)));
        	} else {
        		tmp = R * (phi2 * (1.0 - (phi1 / 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 <= (-2.2d-219)) then
                tmp = phi1 * (0.0d0 - r)
            else if (phi2 <= 2.15d+23) then
                tmp = r * (lambda2 * (1.0d0 - (lambda1 / lambda2)))
            else
                tmp = r * (phi2 * (1.0d0 - (phi1 / 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 <= -2.2e-219) {
        		tmp = phi1 * (0.0 - R);
        	} else if (phi2 <= 2.15e+23) {
        		tmp = R * (lambda2 * (1.0 - (lambda1 / lambda2)));
        	} else {
        		tmp = R * (phi2 * (1.0 - (phi1 / phi2)));
        	}
        	return tmp;
        }
        
        def code(R, lambda1, lambda2, phi1, phi2):
        	tmp = 0
        	if phi2 <= -2.2e-219:
        		tmp = phi1 * (0.0 - R)
        	elif phi2 <= 2.15e+23:
        		tmp = R * (lambda2 * (1.0 - (lambda1 / lambda2)))
        	else:
        		tmp = R * (phi2 * (1.0 - (phi1 / phi2)))
        	return tmp
        
        function code(R, lambda1, lambda2, phi1, phi2)
        	tmp = 0.0
        	if (phi2 <= -2.2e-219)
        		tmp = Float64(phi1 * Float64(0.0 - R));
        	elseif (phi2 <= 2.15e+23)
        		tmp = Float64(R * Float64(lambda2 * Float64(1.0 - Float64(lambda1 / lambda2))));
        	else
        		tmp = Float64(R * Float64(phi2 * Float64(1.0 - Float64(phi1 / phi2))));
        	end
        	return tmp
        end
        
        function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
        	tmp = 0.0;
        	if (phi2 <= -2.2e-219)
        		tmp = phi1 * (0.0 - R);
        	elseif (phi2 <= 2.15e+23)
        		tmp = R * (lambda2 * (1.0 - (lambda1 / lambda2)));
        	else
        		tmp = R * (phi2 * (1.0 - (phi1 / phi2)));
        	end
        	tmp_2 = tmp;
        end
        
        code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, -2.2e-219], N[(phi1 * N[(0.0 - R), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 2.15e+23], N[(R * N[(lambda2 * N[(1.0 - N[(lambda1 / lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(phi2 * N[(1.0 - N[(phi1 / phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;\phi_2 \leq -2.2 \cdot 10^{-219}:\\
        \;\;\;\;\phi_1 \cdot \left(0 - R\right)\\
        
        \mathbf{elif}\;\phi_2 \leq 2.15 \cdot 10^{+23}:\\
        \;\;\;\;R \cdot \left(\lambda_2 \cdot \left(1 - \frac{\lambda_1}{\lambda_2}\right)\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;R \cdot \left(\phi_2 \cdot \left(1 - \frac{\phi_1}{\phi_2}\right)\right)\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if phi2 < -2.1999999999999999e-219

          1. Initial program 59.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. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
            2. hypot-defineN/A

              \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
            3. hypot-lowering-hypot.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
            4. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
            5. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            6. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            8. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            9. --lowering--.f6495.0%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
          3. Simplified95.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. Add Preprocessing
          5. Taylor expanded in phi1 around -inf

            \[\leadsto \color{blue}{-1 \cdot \left(R \cdot \phi_1\right)} \]
          6. Step-by-step derivation
            1. mul-1-negN/A

              \[\leadsto \mathsf{neg}\left(R \cdot \phi_1\right) \]
            2. neg-sub0N/A

              \[\leadsto 0 - \color{blue}{R \cdot \phi_1} \]
            3. --lowering--.f64N/A

              \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{\left(R \cdot \phi_1\right)}\right) \]
            4. *-lowering-*.f6413.3%

              \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(R, \color{blue}{\phi_1}\right)\right) \]
          7. Simplified13.3%

            \[\leadsto \color{blue}{0 - R \cdot \phi_1} \]
          8. Step-by-step derivation
            1. sub0-negN/A

              \[\leadsto \mathsf{neg}\left(R \cdot \phi_1\right) \]
            2. neg-lowering-neg.f64N/A

              \[\leadsto \mathsf{neg.f64}\left(\left(R \cdot \phi_1\right)\right) \]
            3. *-commutativeN/A

              \[\leadsto \mathsf{neg.f64}\left(\left(\phi_1 \cdot R\right)\right) \]
            4. *-lowering-*.f6413.3%

              \[\leadsto \mathsf{neg.f64}\left(\mathsf{*.f64}\left(\phi_1, R\right)\right) \]
          9. Applied egg-rr13.3%

            \[\leadsto \color{blue}{-\phi_1 \cdot R} \]

          if -2.1999999999999999e-219 < phi2 < 2.1499999999999999e23

          1. Initial program 58.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. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
            2. hypot-defineN/A

              \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
            3. hypot-lowering-hypot.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
            4. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
            5. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            6. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            8. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            9. --lowering--.f6498.0%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
          3. Simplified98.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. Add Preprocessing
          5. Taylor expanded in phi1 around 0

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \color{blue}{\left(\cos \left(\frac{1}{2} \cdot \phi_2\right) + \frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)}\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          6. Step-by-step derivation
            1. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\cos \left(\frac{1}{2} \cdot \phi_2\right), \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            2. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\left(\frac{1}{2} \cdot \phi_2\right)\right), \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            3. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            4. *-commutativeN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right) \cdot \frac{-1}{2}\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            5. *-commutativeN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\left(\sin \left(\frac{1}{2} \cdot \phi_2\right) \cdot \phi_1\right) \cdot \frac{-1}{2}\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            6. associate-*l*N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\sin \left(\frac{1}{2} \cdot \phi_2\right) \cdot \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            7. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\sin \left(\frac{1}{2} \cdot \phi_2\right), \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            8. sin-lowering-sin.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\left(\frac{1}{2} \cdot \phi_2\right)\right), \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            9. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            10. *-lowering-*.f6481.3%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\phi_1, \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          7. Simplified81.3%

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

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\color{blue}{\left(\lambda_1 - \lambda_2\right)}, \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          9. Step-by-step derivation
            1. --lowering--.f6486.6%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{\_.f64}\left(\color{blue}{\phi_1}, \phi_2\right)\right)\right) \]
          10. Simplified86.6%

            \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\lambda_1 - \lambda_2}, \phi_1 - \phi_2\right) \]
          11. Taylor expanded in lambda2 around inf

            \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\lambda_2 \cdot \left(1 + -1 \cdot \frac{\lambda_1}{\lambda_2}\right)\right)}\right) \]
          12. Step-by-step derivation
            1. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\lambda_2, \color{blue}{\left(1 + -1 \cdot \frac{\lambda_1}{\lambda_2}\right)}\right)\right) \]
            2. mul-1-negN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\lambda_2, \left(1 + \left(\mathsf{neg}\left(\frac{\lambda_1}{\lambda_2}\right)\right)\right)\right)\right) \]
            3. unsub-negN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\lambda_2, \left(1 - \color{blue}{\frac{\lambda_1}{\lambda_2}}\right)\right)\right) \]
            4. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\lambda_2, \mathsf{\_.f64}\left(1, \color{blue}{\left(\frac{\lambda_1}{\lambda_2}\right)}\right)\right)\right) \]
            5. /-lowering-/.f6424.4%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\lambda_2, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(\lambda_1, \color{blue}{\lambda_2}\right)\right)\right)\right) \]
          13. Simplified24.4%

            \[\leadsto R \cdot \color{blue}{\left(\lambda_2 \cdot \left(1 - \frac{\lambda_1}{\lambda_2}\right)\right)} \]

          if 2.1499999999999999e23 < phi2

          1. Initial program 40.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. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
            2. hypot-defineN/A

              \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
            3. hypot-lowering-hypot.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
            4. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
            5. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            6. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            8. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            9. --lowering--.f6487.7%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
          3. Simplified87.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. Add Preprocessing
          5. Taylor expanded in phi2 around inf

            \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\phi_2 \cdot \left(1 + -1 \cdot \frac{\phi_1}{\phi_2}\right)\right)}\right) \]
          6. Step-by-step derivation
            1. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\phi_2, \color{blue}{\left(1 + -1 \cdot \frac{\phi_1}{\phi_2}\right)}\right)\right) \]
            2. mul-1-negN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\phi_2, \left(1 + \left(\mathsf{neg}\left(\frac{\phi_1}{\phi_2}\right)\right)\right)\right)\right) \]
            3. unsub-negN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\phi_2, \left(1 - \color{blue}{\frac{\phi_1}{\phi_2}}\right)\right)\right) \]
            4. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\phi_2, \mathsf{\_.f64}\left(1, \color{blue}{\left(\frac{\phi_1}{\phi_2}\right)}\right)\right)\right) \]
            5. /-lowering-/.f6465.1%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\phi_2, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right)\right) \]
          7. Simplified65.1%

            \[\leadsto R \cdot \color{blue}{\left(\phi_2 \cdot \left(1 - \frac{\phi_1}{\phi_2}\right)\right)} \]
        3. Recombined 3 regimes into one program.
        4. Final simplification28.3%

          \[\leadsto \begin{array}{l} \mathbf{if}\;\phi_2 \leq -2.2 \cdot 10^{-219}:\\ \;\;\;\;\phi_1 \cdot \left(0 - R\right)\\ \mathbf{elif}\;\phi_2 \leq 2.15 \cdot 10^{+23}:\\ \;\;\;\;R \cdot \left(\lambda_2 \cdot \left(1 - \frac{\lambda_1}{\lambda_2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(\phi_2 \cdot \left(1 - \frac{\phi_1}{\phi_2}\right)\right)\\ \end{array} \]
        5. Add Preprocessing

        Alternative 18: 31.8% accurate, 17.3× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\phi_2 \leq -6.6 \cdot 10^{-220}:\\ \;\;\;\;\phi_1 \cdot \left(0 - R\right)\\ \mathbf{elif}\;\phi_2 \leq 1.9 \cdot 10^{+23}:\\ \;\;\;\;R \cdot \left(\lambda_2 \cdot \left(1 - \frac{\lambda_1}{\lambda_2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \phi_2\\ \end{array} \end{array} \]
        (FPCore (R lambda1 lambda2 phi1 phi2)
         :precision binary64
         (if (<= phi2 -6.6e-220)
           (* phi1 (- 0.0 R))
           (if (<= phi2 1.9e+23)
             (* R (* lambda2 (- 1.0 (/ lambda1 lambda2))))
             (* R phi2))))
        double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
        	double tmp;
        	if (phi2 <= -6.6e-220) {
        		tmp = phi1 * (0.0 - R);
        	} else if (phi2 <= 1.9e+23) {
        		tmp = R * (lambda2 * (1.0 - (lambda1 / 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 <= (-6.6d-220)) then
                tmp = phi1 * (0.0d0 - r)
            else if (phi2 <= 1.9d+23) then
                tmp = r * (lambda2 * (1.0d0 - (lambda1 / 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 <= -6.6e-220) {
        		tmp = phi1 * (0.0 - R);
        	} else if (phi2 <= 1.9e+23) {
        		tmp = R * (lambda2 * (1.0 - (lambda1 / lambda2)));
        	} else {
        		tmp = R * phi2;
        	}
        	return tmp;
        }
        
        def code(R, lambda1, lambda2, phi1, phi2):
        	tmp = 0
        	if phi2 <= -6.6e-220:
        		tmp = phi1 * (0.0 - R)
        	elif phi2 <= 1.9e+23:
        		tmp = R * (lambda2 * (1.0 - (lambda1 / lambda2)))
        	else:
        		tmp = R * phi2
        	return tmp
        
        function code(R, lambda1, lambda2, phi1, phi2)
        	tmp = 0.0
        	if (phi2 <= -6.6e-220)
        		tmp = Float64(phi1 * Float64(0.0 - R));
        	elseif (phi2 <= 1.9e+23)
        		tmp = Float64(R * Float64(lambda2 * Float64(1.0 - Float64(lambda1 / lambda2))));
        	else
        		tmp = Float64(R * phi2);
        	end
        	return tmp
        end
        
        function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
        	tmp = 0.0;
        	if (phi2 <= -6.6e-220)
        		tmp = phi1 * (0.0 - R);
        	elseif (phi2 <= 1.9e+23)
        		tmp = R * (lambda2 * (1.0 - (lambda1 / lambda2)));
        	else
        		tmp = R * phi2;
        	end
        	tmp_2 = tmp;
        end
        
        code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, -6.6e-220], N[(phi1 * N[(0.0 - R), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 1.9e+23], N[(R * N[(lambda2 * N[(1.0 - N[(lambda1 / lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * phi2), $MachinePrecision]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;\phi_2 \leq -6.6 \cdot 10^{-220}:\\
        \;\;\;\;\phi_1 \cdot \left(0 - R\right)\\
        
        \mathbf{elif}\;\phi_2 \leq 1.9 \cdot 10^{+23}:\\
        \;\;\;\;R \cdot \left(\lambda_2 \cdot \left(1 - \frac{\lambda_1}{\lambda_2}\right)\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;R \cdot \phi_2\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if phi2 < -6.59999999999999999e-220

          1. Initial program 59.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. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
            2. hypot-defineN/A

              \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
            3. hypot-lowering-hypot.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
            4. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
            5. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            6. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            8. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            9. --lowering--.f6495.0%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
          3. Simplified95.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. Add Preprocessing
          5. Taylor expanded in phi1 around -inf

            \[\leadsto \color{blue}{-1 \cdot \left(R \cdot \phi_1\right)} \]
          6. Step-by-step derivation
            1. mul-1-negN/A

              \[\leadsto \mathsf{neg}\left(R \cdot \phi_1\right) \]
            2. neg-sub0N/A

              \[\leadsto 0 - \color{blue}{R \cdot \phi_1} \]
            3. --lowering--.f64N/A

              \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{\left(R \cdot \phi_1\right)}\right) \]
            4. *-lowering-*.f6413.3%

              \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(R, \color{blue}{\phi_1}\right)\right) \]
          7. Simplified13.3%

            \[\leadsto \color{blue}{0 - R \cdot \phi_1} \]
          8. Step-by-step derivation
            1. sub0-negN/A

              \[\leadsto \mathsf{neg}\left(R \cdot \phi_1\right) \]
            2. neg-lowering-neg.f64N/A

              \[\leadsto \mathsf{neg.f64}\left(\left(R \cdot \phi_1\right)\right) \]
            3. *-commutativeN/A

              \[\leadsto \mathsf{neg.f64}\left(\left(\phi_1 \cdot R\right)\right) \]
            4. *-lowering-*.f6413.3%

              \[\leadsto \mathsf{neg.f64}\left(\mathsf{*.f64}\left(\phi_1, R\right)\right) \]
          9. Applied egg-rr13.3%

            \[\leadsto \color{blue}{-\phi_1 \cdot R} \]

          if -6.59999999999999999e-220 < phi2 < 1.89999999999999987e23

          1. Initial program 58.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. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
            2. hypot-defineN/A

              \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
            3. hypot-lowering-hypot.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
            4. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
            5. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            6. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            8. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            9. --lowering--.f6498.0%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
          3. Simplified98.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. Add Preprocessing
          5. Taylor expanded in phi1 around 0

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \color{blue}{\left(\cos \left(\frac{1}{2} \cdot \phi_2\right) + \frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)}\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          6. Step-by-step derivation
            1. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\cos \left(\frac{1}{2} \cdot \phi_2\right), \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            2. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\left(\frac{1}{2} \cdot \phi_2\right)\right), \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            3. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            4. *-commutativeN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right) \cdot \frac{-1}{2}\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            5. *-commutativeN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\left(\sin \left(\frac{1}{2} \cdot \phi_2\right) \cdot \phi_1\right) \cdot \frac{-1}{2}\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            6. associate-*l*N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\sin \left(\frac{1}{2} \cdot \phi_2\right) \cdot \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            7. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\sin \left(\frac{1}{2} \cdot \phi_2\right), \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            8. sin-lowering-sin.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\left(\frac{1}{2} \cdot \phi_2\right)\right), \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            9. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            10. *-lowering-*.f6481.3%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\phi_1, \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          7. Simplified81.3%

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

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\color{blue}{\left(\lambda_1 - \lambda_2\right)}, \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          9. Step-by-step derivation
            1. --lowering--.f6486.6%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{\_.f64}\left(\color{blue}{\phi_1}, \phi_2\right)\right)\right) \]
          10. Simplified86.6%

            \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\lambda_1 - \lambda_2}, \phi_1 - \phi_2\right) \]
          11. Taylor expanded in lambda2 around inf

            \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\lambda_2 \cdot \left(1 + -1 \cdot \frac{\lambda_1}{\lambda_2}\right)\right)}\right) \]
          12. Step-by-step derivation
            1. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\lambda_2, \color{blue}{\left(1 + -1 \cdot \frac{\lambda_1}{\lambda_2}\right)}\right)\right) \]
            2. mul-1-negN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\lambda_2, \left(1 + \left(\mathsf{neg}\left(\frac{\lambda_1}{\lambda_2}\right)\right)\right)\right)\right) \]
            3. unsub-negN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\lambda_2, \left(1 - \color{blue}{\frac{\lambda_1}{\lambda_2}}\right)\right)\right) \]
            4. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\lambda_2, \mathsf{\_.f64}\left(1, \color{blue}{\left(\frac{\lambda_1}{\lambda_2}\right)}\right)\right)\right) \]
            5. /-lowering-/.f6424.4%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\lambda_2, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(\lambda_1, \color{blue}{\lambda_2}\right)\right)\right)\right) \]
          13. Simplified24.4%

            \[\leadsto R \cdot \color{blue}{\left(\lambda_2 \cdot \left(1 - \frac{\lambda_1}{\lambda_2}\right)\right)} \]

          if 1.89999999999999987e23 < phi2

          1. Initial program 40.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. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
            2. hypot-defineN/A

              \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
            3. hypot-lowering-hypot.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
            4. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
            5. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            6. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            8. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            9. --lowering--.f6487.7%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
          3. Simplified87.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. Add Preprocessing
          5. Taylor expanded in phi2 around inf

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

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\phi_2}\right) \]
          7. Simplified63.5%

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

          \[\leadsto \begin{array}{l} \mathbf{if}\;\phi_2 \leq -6.6 \cdot 10^{-220}:\\ \;\;\;\;\phi_1 \cdot \left(0 - R\right)\\ \mathbf{elif}\;\phi_2 \leq 1.9 \cdot 10^{+23}:\\ \;\;\;\;R \cdot \left(\lambda_2 \cdot \left(1 - \frac{\lambda_1}{\lambda_2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \phi_2\\ \end{array} \]
        5. Add Preprocessing

        Alternative 19: 29.1% accurate, 21.9× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\phi_1 \leq -2.65 \cdot 10^{+45}:\\ \;\;\;\;\phi_1 \cdot \left(0 - R\right)\\ \mathbf{elif}\;\phi_1 \leq -3.4 \cdot 10^{-145}:\\ \;\;\;\;0 - R \cdot \lambda_1\\ \mathbf{else}:\\ \;\;\;\;R \cdot \phi_2\\ \end{array} \end{array} \]
        (FPCore (R lambda1 lambda2 phi1 phi2)
         :precision binary64
         (if (<= phi1 -2.65e+45)
           (* phi1 (- 0.0 R))
           (if (<= phi1 -3.4e-145) (- 0.0 (* R lambda1)) (* R phi2))))
        double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
        	double tmp;
        	if (phi1 <= -2.65e+45) {
        		tmp = phi1 * (0.0 - R);
        	} else if (phi1 <= -3.4e-145) {
        		tmp = 0.0 - (R * lambda1);
        	} 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 (phi1 <= (-2.65d+45)) then
                tmp = phi1 * (0.0d0 - r)
            else if (phi1 <= (-3.4d-145)) then
                tmp = 0.0d0 - (r * lambda1)
            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 (phi1 <= -2.65e+45) {
        		tmp = phi1 * (0.0 - R);
        	} else if (phi1 <= -3.4e-145) {
        		tmp = 0.0 - (R * lambda1);
        	} else {
        		tmp = R * phi2;
        	}
        	return tmp;
        }
        
        def code(R, lambda1, lambda2, phi1, phi2):
        	tmp = 0
        	if phi1 <= -2.65e+45:
        		tmp = phi1 * (0.0 - R)
        	elif phi1 <= -3.4e-145:
        		tmp = 0.0 - (R * lambda1)
        	else:
        		tmp = R * phi2
        	return tmp
        
        function code(R, lambda1, lambda2, phi1, phi2)
        	tmp = 0.0
        	if (phi1 <= -2.65e+45)
        		tmp = Float64(phi1 * Float64(0.0 - R));
        	elseif (phi1 <= -3.4e-145)
        		tmp = Float64(0.0 - Float64(R * lambda1));
        	else
        		tmp = Float64(R * phi2);
        	end
        	return tmp
        end
        
        function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
        	tmp = 0.0;
        	if (phi1 <= -2.65e+45)
        		tmp = phi1 * (0.0 - R);
        	elseif (phi1 <= -3.4e-145)
        		tmp = 0.0 - (R * lambda1);
        	else
        		tmp = R * phi2;
        	end
        	tmp_2 = tmp;
        end
        
        code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -2.65e+45], N[(phi1 * N[(0.0 - R), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, -3.4e-145], N[(0.0 - N[(R * lambda1), $MachinePrecision]), $MachinePrecision], N[(R * phi2), $MachinePrecision]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;\phi_1 \leq -2.65 \cdot 10^{+45}:\\
        \;\;\;\;\phi_1 \cdot \left(0 - R\right)\\
        
        \mathbf{elif}\;\phi_1 \leq -3.4 \cdot 10^{-145}:\\
        \;\;\;\;0 - R \cdot \lambda_1\\
        
        \mathbf{else}:\\
        \;\;\;\;R \cdot \phi_2\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if phi1 < -2.64999999999999996e45

          1. Initial program 55.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. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
            2. hypot-defineN/A

              \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
            3. hypot-lowering-hypot.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
            4. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
            5. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            6. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            8. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            9. --lowering--.f6488.7%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
          3. Simplified88.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. Add Preprocessing
          5. Taylor expanded in phi1 around -inf

            \[\leadsto \color{blue}{-1 \cdot \left(R \cdot \phi_1\right)} \]
          6. Step-by-step derivation
            1. mul-1-negN/A

              \[\leadsto \mathsf{neg}\left(R \cdot \phi_1\right) \]
            2. neg-sub0N/A

              \[\leadsto 0 - \color{blue}{R \cdot \phi_1} \]
            3. --lowering--.f64N/A

              \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{\left(R \cdot \phi_1\right)}\right) \]
            4. *-lowering-*.f6456.3%

              \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(R, \color{blue}{\phi_1}\right)\right) \]
          7. Simplified56.3%

            \[\leadsto \color{blue}{0 - R \cdot \phi_1} \]
          8. Step-by-step derivation
            1. sub0-negN/A

              \[\leadsto \mathsf{neg}\left(R \cdot \phi_1\right) \]
            2. neg-lowering-neg.f64N/A

              \[\leadsto \mathsf{neg.f64}\left(\left(R \cdot \phi_1\right)\right) \]
            3. *-commutativeN/A

              \[\leadsto \mathsf{neg.f64}\left(\left(\phi_1 \cdot R\right)\right) \]
            4. *-lowering-*.f6456.3%

              \[\leadsto \mathsf{neg.f64}\left(\mathsf{*.f64}\left(\phi_1, R\right)\right) \]
          9. Applied egg-rr56.3%

            \[\leadsto \color{blue}{-\phi_1 \cdot R} \]

          if -2.64999999999999996e45 < phi1 < -3.3999999999999999e-145

          1. Initial program 63.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. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
            2. hypot-defineN/A

              \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
            3. hypot-lowering-hypot.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
            4. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
            5. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            6. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            8. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            9. --lowering--.f6496.9%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\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. Add Preprocessing
          5. Taylor expanded in phi1 around 0

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \color{blue}{\left(\cos \left(\frac{1}{2} \cdot \phi_2\right) + \frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)}\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          6. Step-by-step derivation
            1. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\cos \left(\frac{1}{2} \cdot \phi_2\right), \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            2. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\left(\frac{1}{2} \cdot \phi_2\right)\right), \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            3. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            4. *-commutativeN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right) \cdot \frac{-1}{2}\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            5. *-commutativeN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\left(\sin \left(\frac{1}{2} \cdot \phi_2\right) \cdot \phi_1\right) \cdot \frac{-1}{2}\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            6. associate-*l*N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\sin \left(\frac{1}{2} \cdot \phi_2\right) \cdot \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            7. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\sin \left(\frac{1}{2} \cdot \phi_2\right), \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            8. sin-lowering-sin.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\left(\frac{1}{2} \cdot \phi_2\right)\right), \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            9. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            10. *-lowering-*.f6492.6%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\phi_1, \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          7. Simplified92.6%

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

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\color{blue}{\left(\lambda_1 - \lambda_2\right)}, \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          9. Step-by-step derivation
            1. --lowering--.f6484.6%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{\_.f64}\left(\color{blue}{\phi_1}, \phi_2\right)\right)\right) \]
          10. Simplified84.6%

            \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\lambda_1 - \lambda_2}, \phi_1 - \phi_2\right) \]
          11. Taylor expanded in lambda1 around -inf

            \[\leadsto \color{blue}{-1 \cdot \left(R \cdot \lambda_1\right)} \]
          12. Step-by-step derivation
            1. mul-1-negN/A

              \[\leadsto \mathsf{neg}\left(R \cdot \lambda_1\right) \]
            2. neg-sub0N/A

              \[\leadsto 0 - \color{blue}{R \cdot \lambda_1} \]
            3. --lowering--.f64N/A

              \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{\left(R \cdot \lambda_1\right)}\right) \]
            4. *-commutativeN/A

              \[\leadsto \mathsf{\_.f64}\left(0, \left(\lambda_1 \cdot \color{blue}{R}\right)\right) \]
            5. *-lowering-*.f6410.9%

              \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(\lambda_1, \color{blue}{R}\right)\right) \]
          13. Simplified10.9%

            \[\leadsto \color{blue}{0 - \lambda_1 \cdot R} \]

          if -3.3999999999999999e-145 < phi1

          1. Initial program 52.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. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
            2. hypot-defineN/A

              \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
            3. hypot-lowering-hypot.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
            4. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
            5. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            6. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            8. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            9. --lowering--.f6495.6%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
          3. Simplified95.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. Add Preprocessing
          5. Taylor expanded in phi2 around inf

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

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\phi_2}\right) \]
          7. Simplified15.8%

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

          \[\leadsto \begin{array}{l} \mathbf{if}\;\phi_1 \leq -2.65 \cdot 10^{+45}:\\ \;\;\;\;\phi_1 \cdot \left(0 - R\right)\\ \mathbf{elif}\;\phi_1 \leq -3.4 \cdot 10^{-145}:\\ \;\;\;\;0 - R \cdot \lambda_1\\ \mathbf{else}:\\ \;\;\;\;R \cdot \phi_2\\ \end{array} \]
        5. Add Preprocessing

        Alternative 20: 29.2% accurate, 32.8× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\phi_2 \leq 3.5 \cdot 10^{+39}:\\ \;\;\;\;\phi_1 \cdot \left(0 - R\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \phi_2\\ \end{array} \end{array} \]
        (FPCore (R lambda1 lambda2 phi1 phi2)
         :precision binary64
         (if (<= phi2 3.5e+39) (* phi1 (- 0.0 R)) (* R phi2)))
        double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
        	double tmp;
        	if (phi2 <= 3.5e+39) {
        		tmp = phi1 * (0.0 - R);
        	} 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 <= 3.5d+39) then
                tmp = phi1 * (0.0d0 - r)
            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 <= 3.5e+39) {
        		tmp = phi1 * (0.0 - R);
        	} else {
        		tmp = R * phi2;
        	}
        	return tmp;
        }
        
        def code(R, lambda1, lambda2, phi1, phi2):
        	tmp = 0
        	if phi2 <= 3.5e+39:
        		tmp = phi1 * (0.0 - R)
        	else:
        		tmp = R * phi2
        	return tmp
        
        function code(R, lambda1, lambda2, phi1, phi2)
        	tmp = 0.0
        	if (phi2 <= 3.5e+39)
        		tmp = Float64(phi1 * Float64(0.0 - R));
        	else
        		tmp = Float64(R * phi2);
        	end
        	return tmp
        end
        
        function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
        	tmp = 0.0;
        	if (phi2 <= 3.5e+39)
        		tmp = phi1 * (0.0 - R);
        	else
        		tmp = R * phi2;
        	end
        	tmp_2 = tmp;
        end
        
        code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 3.5e+39], N[(phi1 * N[(0.0 - R), $MachinePrecision]), $MachinePrecision], N[(R * phi2), $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;\phi_2 \leq 3.5 \cdot 10^{+39}:\\
        \;\;\;\;\phi_1 \cdot \left(0 - R\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;R \cdot \phi_2\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if phi2 < 3.5000000000000002e39

          1. Initial program 59.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. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
            2. hypot-defineN/A

              \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
            3. hypot-lowering-hypot.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
            4. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
            5. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            6. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            8. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            9. --lowering--.f6496.3%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\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. Add Preprocessing
          5. Taylor expanded in phi1 around -inf

            \[\leadsto \color{blue}{-1 \cdot \left(R \cdot \phi_1\right)} \]
          6. Step-by-step derivation
            1. mul-1-negN/A

              \[\leadsto \mathsf{neg}\left(R \cdot \phi_1\right) \]
            2. neg-sub0N/A

              \[\leadsto 0 - \color{blue}{R \cdot \phi_1} \]
            3. --lowering--.f64N/A

              \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{\left(R \cdot \phi_1\right)}\right) \]
            4. *-lowering-*.f6416.4%

              \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(R, \color{blue}{\phi_1}\right)\right) \]
          7. Simplified16.4%

            \[\leadsto \color{blue}{0 - R \cdot \phi_1} \]
          8. Step-by-step derivation
            1. sub0-negN/A

              \[\leadsto \mathsf{neg}\left(R \cdot \phi_1\right) \]
            2. neg-lowering-neg.f64N/A

              \[\leadsto \mathsf{neg.f64}\left(\left(R \cdot \phi_1\right)\right) \]
            3. *-commutativeN/A

              \[\leadsto \mathsf{neg.f64}\left(\left(\phi_1 \cdot R\right)\right) \]
            4. *-lowering-*.f6416.4%

              \[\leadsto \mathsf{neg.f64}\left(\mathsf{*.f64}\left(\phi_1, R\right)\right) \]
          9. Applied egg-rr16.4%

            \[\leadsto \color{blue}{-\phi_1 \cdot R} \]

          if 3.5000000000000002e39 < phi2

          1. Initial program 38.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. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
            2. hypot-defineN/A

              \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
            3. hypot-lowering-hypot.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
            4. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
            5. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            6. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            8. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            9. --lowering--.f6487.2%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
          3. Simplified87.2%

            \[\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. Add Preprocessing
          5. Taylor expanded in phi2 around inf

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

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\phi_2}\right) \]
          7. Simplified63.8%

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

          \[\leadsto \begin{array}{l} \mathbf{if}\;\phi_2 \leq 3.5 \cdot 10^{+39}:\\ \;\;\;\;\phi_1 \cdot \left(0 - R\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \phi_2\\ \end{array} \]
        5. Add Preprocessing

        Alternative 21: 26.4% accurate, 41.0× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\phi_2 \leq 2.2 \cdot 10^{+23}:\\ \;\;\;\;R \cdot \lambda_2\\ \mathbf{else}:\\ \;\;\;\;R \cdot \phi_2\\ \end{array} \end{array} \]
        (FPCore (R lambda1 lambda2 phi1 phi2)
         :precision binary64
         (if (<= phi2 2.2e+23) (* R lambda2) (* R phi2)))
        double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
        	double tmp;
        	if (phi2 <= 2.2e+23) {
        		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 <= 2.2d+23) 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 <= 2.2e+23) {
        		tmp = R * lambda2;
        	} else {
        		tmp = R * phi2;
        	}
        	return tmp;
        }
        
        def code(R, lambda1, lambda2, phi1, phi2):
        	tmp = 0
        	if phi2 <= 2.2e+23:
        		tmp = R * lambda2
        	else:
        		tmp = R * phi2
        	return tmp
        
        function code(R, lambda1, lambda2, phi1, phi2)
        	tmp = 0.0
        	if (phi2 <= 2.2e+23)
        		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 <= 2.2e+23)
        		tmp = R * lambda2;
        	else
        		tmp = R * phi2;
        	end
        	tmp_2 = tmp;
        end
        
        code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 2.2e+23], N[(R * lambda2), $MachinePrecision], N[(R * phi2), $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;\phi_2 \leq 2.2 \cdot 10^{+23}:\\
        \;\;\;\;R \cdot \lambda_2\\
        
        \mathbf{else}:\\
        \;\;\;\;R \cdot \phi_2\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if phi2 < 2.20000000000000008e23

          1. Initial program 58.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. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
            2. hypot-defineN/A

              \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
            3. hypot-lowering-hypot.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
            4. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
            5. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            6. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            8. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            9. --lowering--.f6496.3%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\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. Add Preprocessing
          5. Taylor expanded in phi1 around 0

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \color{blue}{\left(\cos \left(\frac{1}{2} \cdot \phi_2\right) + \frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)}\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          6. Step-by-step derivation
            1. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\cos \left(\frac{1}{2} \cdot \phi_2\right), \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            2. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\left(\frac{1}{2} \cdot \phi_2\right)\right), \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            3. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            4. *-commutativeN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\left(\phi_1 \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right) \cdot \frac{-1}{2}\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            5. *-commutativeN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\left(\sin \left(\frac{1}{2} \cdot \phi_2\right) \cdot \phi_1\right) \cdot \frac{-1}{2}\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            6. associate-*l*N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\sin \left(\frac{1}{2} \cdot \phi_2\right) \cdot \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            7. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\sin \left(\frac{1}{2} \cdot \phi_2\right), \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            8. sin-lowering-sin.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\left(\frac{1}{2} \cdot \phi_2\right)\right), \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            9. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \left(\phi_1 \cdot \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            10. *-lowering-*.f6482.9%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{*.f64}\left(\phi_1, \frac{-1}{2}\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          7. Simplified82.9%

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

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\color{blue}{\left(\lambda_1 - \lambda_2\right)}, \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          9. Step-by-step derivation
            1. --lowering--.f6484.6%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{\_.f64}\left(\color{blue}{\phi_1}, \phi_2\right)\right)\right) \]
          10. Simplified84.6%

            \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\lambda_1 - \lambda_2}, \phi_1 - \phi_2\right) \]
          11. Taylor expanded in lambda2 around inf

            \[\leadsto \color{blue}{R \cdot \lambda_2} \]
          12. Step-by-step derivation
            1. *-commutativeN/A

              \[\leadsto \lambda_2 \cdot \color{blue}{R} \]
            2. *-lowering-*.f6414.5%

              \[\leadsto \mathsf{*.f64}\left(\lambda_2, \color{blue}{R}\right) \]
          13. Simplified14.5%

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

          if 2.20000000000000008e23 < phi2

          1. Initial program 40.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. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
            2. hypot-defineN/A

              \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
            3. hypot-lowering-hypot.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
            4. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
            5. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            6. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            8. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
            9. --lowering--.f6487.7%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
          3. Simplified87.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. Add Preprocessing
          5. Taylor expanded in phi2 around inf

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

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\phi_2}\right) \]
          7. Simplified63.5%

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

          \[\leadsto \begin{array}{l} \mathbf{if}\;\phi_2 \leq 2.2 \cdot 10^{+23}:\\ \;\;\;\;R \cdot \lambda_2\\ \mathbf{else}:\\ \;\;\;\;R \cdot \phi_2\\ \end{array} \]
        5. Add Preprocessing

        Alternative 22: 18.2% accurate, 109.7× speedup?

        \[\begin{array}{l} \\ R \cdot \phi_2 \end{array} \]
        (FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R phi2))
        double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
        	return R * phi2;
        }
        
        real(8) function code(r, lambda1, lambda2, phi1, phi2)
            real(8), intent (in) :: r
            real(8), intent (in) :: lambda1
            real(8), intent (in) :: lambda2
            real(8), intent (in) :: phi1
            real(8), intent (in) :: phi2
            code = r * phi2
        end function
        
        public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
        	return R * phi2;
        }
        
        def code(R, lambda1, lambda2, phi1, phi2):
        	return R * phi2
        
        function code(R, lambda1, lambda2, phi1, phi2)
        	return Float64(R * phi2)
        end
        
        function tmp = code(R, lambda1, lambda2, phi1, phi2)
        	tmp = R * phi2;
        end
        
        code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * phi2), $MachinePrecision]
        
        \begin{array}{l}
        
        \\
        R \cdot \phi_2
        \end{array}
        
        Derivation
        1. Initial program 54.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. *-lowering-*.f64N/A

            \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\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)}\right)}\right) \]
          2. hypot-defineN/A

            \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \color{blue}{\phi_1 - \phi_2}\right)\right)\right) \]
          3. hypot-lowering-hypot.f64N/A

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \color{blue}{\left(\phi_1 - \phi_2\right)}\right)\right) \]
          4. *-lowering-*.f64N/A

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\color{blue}{\phi_1} - \phi_2\right)\right)\right) \]
          5. --lowering--.f64N/A

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
          6. cos-lowering-cos.f64N/A

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
          7. /-lowering-/.f64N/A

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
          8. +-lowering-+.f64N/A

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
          9. --lowering--.f6494.4%

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \color{blue}{\phi_2}\right)\right)\right) \]
        3. Simplified94.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. Add Preprocessing
        5. Taylor expanded in phi2 around inf

          \[\leadsto \color{blue}{R \cdot \phi_2} \]
        6. Step-by-step derivation
          1. *-lowering-*.f6416.4%

            \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\phi_2}\right) \]
        7. Simplified16.4%

          \[\leadsto \color{blue}{R \cdot \phi_2} \]
        8. Add Preprocessing

        Reproduce

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