Equirectangular approximation to distance on a great circle

Percentage Accurate: 59.8% → 99.9%
Time: 19.6s
Alternatives: 14
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 14 alternatives:

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

Initial Program: 59.8% 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.6× speedup?

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\frac{\cos \left(\frac{\phi_1 + \phi_2}{2}\right)}{\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}}\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(\cos \left(\frac{\phi_1 + \phi_2}{2}\right), \left(\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}\right)\right), \mathsf{\_.f64}\left(\color{blue}{\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{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}\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{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right), \left(\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}\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{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right), \left(\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    9. clear-numN/A

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

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

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

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right), \mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
  6. Applied egg-rr96.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\phi_2, \frac{1}{2}\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_1\right)\right)\right), \left(\lambda_1 - \lambda_2\right)\right), \left(\frac{\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)}{\frac{1}{\lambda_1 - \lambda_2}}\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{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\phi_2, \frac{1}{2}\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_1\right)\right)\right), \mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \left(\frac{\sin \left(\phi_2 \cdot \frac{1}{2}\right) \cdot \sin \left(\phi_1 \cdot \frac{1}{2}\right)}{\frac{1}{\lambda_1 - \lambda_2}}\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    14. div-invN/A

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

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

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

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

Alternative 2: 99.9% accurate, 0.6× speedup?

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

\\
R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \left(\cos \left(0.5 \cdot \phi_1\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \sin \left(0.5 \cdot \phi_1\right) \cdot \sin \left(\phi_2 \cdot 0.5\right)\right), \phi_1 - \phi_2\right)
\end{array}
Derivation
  1. Initial program 62.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--.f6496.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. Simplified96.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. *-commutativeN/A

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

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

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

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\frac{\cos \left(\frac{\phi_1 + \phi_2}{2}\right)}{\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}}\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(\cos \left(\frac{\phi_1 + \phi_2}{2}\right), \left(\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}\right)\right), \mathsf{\_.f64}\left(\color{blue}{\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{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}\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{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right), \left(\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}\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{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right), \left(\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    9. clear-numN/A

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

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

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

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right), \mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
  6. Applied egg-rr96.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\color{blue}{\left(\left(\lambda_1 - \lambda_2\right) \cdot \left(\cos \left(\frac{1}{2} \cdot \phi_1\right) \cdot \cos \left(\frac{1}{2} \cdot \phi_2\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(\phi_1, \phi_2\right)\right)\right) \]
  10. Step-by-step derivation
    1. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \left(\cos \left(\frac{1}{2} \cdot \phi_1\right) \cdot \cos \left(\frac{1}{2} \cdot \phi_2\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) \]
    2. --lowering--.f64N/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_1\right) \cdot \cos \left(\frac{1}{2} \cdot \phi_2\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(\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(\left(\cos \left(\frac{1}{2} \cdot \phi_1\right) \cdot \cos \left(\frac{1}{2} \cdot \phi_2\right)\right), \left(\sin \left(\frac{1}{2} \cdot \phi_1\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    4. *-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_1\right), \cos \left(\frac{1}{2} \cdot \phi_2\right)\right), \left(\sin \left(\frac{1}{2} \cdot \phi_1\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    5. 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_1\right)\right), \cos \left(\frac{1}{2} \cdot \phi_2\right)\right), \left(\sin \left(\frac{1}{2} \cdot \phi_1\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_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{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_1\right)\right), \cos \left(\frac{1}{2} \cdot \phi_2\right)\right), \left(\sin \left(\frac{1}{2} \cdot \phi_1\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    7. 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(\frac{1}{2}, \phi_1\right)\right), \mathsf{cos.f64}\left(\left(\frac{1}{2} \cdot \phi_2\right)\right)\right), \left(\sin \left(\frac{1}{2} \cdot \phi_1\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_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{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_1\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right)\right), \left(\sin \left(\frac{1}{2} \cdot \phi_1\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_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(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_1\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right)\right), \mathsf{*.f64}\left(\sin \left(\frac{1}{2} \cdot \phi_1\right), \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    10. 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{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_1\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\left(\frac{1}{2} \cdot \phi_1\right)\right), \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    11. *-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(\frac{1}{2}, \phi_1\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_1\right)\right), \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    12. 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{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_1\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_1\right)\right), \mathsf{sin.f64}\left(\left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    13. *-lowering-*.f6499.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{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_1\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_1\right)\right), \mathsf{sin.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
  11. Simplified99.9%

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

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

Alternative 3: 93.4% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\phi_2 \leq 2 \cdot 10^{-31}:\\ \;\;\;\;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 2e-31)
   (* 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 <= 2e-31) {
		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 <= 2e-31) {
		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 <= 2e-31:
		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 <= 2e-31)
		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 <= 2e-31)
		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, 2e-31], 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 2 \cdot 10^{-31}:\\
\;\;\;\;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 < 2e-31

    1. Initial program 66.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--.f6498.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. Simplified98.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. Simplified96.5%

        \[\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 2e-31 < phi2

      1. Initial program 53.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.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. Simplified90.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), \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. Simplified88.8%

          \[\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 4: 82.0% accurate, 1.5× speedup?

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

        1. Initial program 58.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--.f6494.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. Simplified94.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. Simplified91.3%

            \[\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 -1.04999999999999999e-131 < phi1

          1. Initial program 65.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--.f6497.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. Simplified97.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. *-commutativeN/A

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

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

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

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\frac{\cos \left(\frac{\phi_1 + \phi_2}{2}\right)}{\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}}\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(\cos \left(\frac{\phi_1 + \phi_2}{2}\right), \left(\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}\right)\right), \mathsf{\_.f64}\left(\color{blue}{\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{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}\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{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right), \left(\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}\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{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right), \left(\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            9. clear-numN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\lambda_1 \cdot \left(\cos \left(\frac{1}{2} \cdot \phi_1\right) \cdot \cos \left(\frac{1}{2} \cdot \phi_2\right) - \sin \left(\frac{1}{2} \cdot \phi_1\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right) + -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) - \sin \left(\frac{1}{2} \cdot \phi_1\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right), \mathsf{\_.f64}\left(\color{blue}{\phi_1}, \phi_2\right)\right)\right) \]
            2. mul-1-negN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\lambda_1 \cdot \left(\cos \left(\frac{1}{2} \cdot \phi_1\right) \cdot \cos \left(\frac{1}{2} \cdot \phi_2\right) - \sin \left(\frac{1}{2} \cdot \phi_1\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right) + \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) - \sin \left(\frac{1}{2} \cdot \phi_1\right) \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. unsub-negN/A

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\phi_2, \color{blue}{\left(\lambda_1 \cdot \cos \left(\frac{1}{2} \cdot \phi_2\right) - \lambda_2 \cdot \cos \left(\frac{1}{2} \cdot \phi_2\right)\right)}\right)\right) \]
            6. distribute-rgt-out--N/A

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

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

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

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

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\phi_2, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{\_.f64}\left(\lambda_1, \color{blue}{\lambda_2}\right)\right)\right)\right) \]
          14. Simplified80.3%

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

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

        Alternative 5: 79.0% accurate, 1.5× speedup?

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

          1. Initial program 53.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--.f6492.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. Simplified92.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. *-commutativeN/A

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

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

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

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\frac{\cos \left(\frac{\phi_1 + \phi_2}{2}\right)}{\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}}\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(\cos \left(\frac{\phi_1 + \phi_2}{2}\right), \left(\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}\right)\right), \mathsf{\_.f64}\left(\color{blue}{\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{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}\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{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right), \left(\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}\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{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right), \left(\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            9. clear-numN/A

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

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

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

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right), \mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          6. Applied egg-rr92.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\lambda_1 \cdot \left(\cos \left(\frac{1}{2} \cdot \phi_1\right) \cdot \cos \left(\frac{1}{2} \cdot \phi_2\right) - \sin \left(\frac{1}{2} \cdot \phi_1\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right) + -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) - \sin \left(\frac{1}{2} \cdot \phi_1\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right), \mathsf{\_.f64}\left(\color{blue}{\phi_1}, \phi_2\right)\right)\right) \]
            2. mul-1-negN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\lambda_1 \cdot \left(\cos \left(\frac{1}{2} \cdot \phi_1\right) \cdot \cos \left(\frac{1}{2} \cdot \phi_2\right) - \sin \left(\frac{1}{2} \cdot \phi_1\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right) + \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) - \sin \left(\frac{1}{2} \cdot \phi_1\right) \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. unsub-negN/A

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

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

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

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

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

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

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

              \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\phi_1, \color{blue}{\lambda_1 \cdot \cos \left(\frac{1}{2} \cdot \phi_1\right) - \lambda_2 \cdot \cos \left(\frac{1}{2} \cdot \phi_1\right)}\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 \cdot \cos \left(\frac{1}{2} \cdot \phi_1\right) - \lambda_2 \cdot \cos \left(\frac{1}{2} \cdot \phi_1\right)\right)}\right)\right) \]
            6. distribute-rgt-out--N/A

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

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

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

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\phi_1, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_1\right)\right), \left(\lambda_1 - \lambda_2\right)\right)\right)\right) \]
            10. --lowering--.f6483.1%

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

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

          if -6.4000000000000005e-14 < phi1

          1. Initial program 66.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--.f6497.5%

              \[\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. Simplified97.5%

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

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

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

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

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\frac{\cos \left(\frac{\phi_1 + \phi_2}{2}\right)}{\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}}\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(\cos \left(\frac{\phi_1 + \phi_2}{2}\right), \left(\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}\right)\right), \mathsf{\_.f64}\left(\color{blue}{\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{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}\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{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right), \left(\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}\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{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right), \left(\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            9. clear-numN/A

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

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

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

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right), \mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          6. Applied egg-rr97.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\lambda_1 \cdot \left(\cos \left(\frac{1}{2} \cdot \phi_1\right) \cdot \cos \left(\frac{1}{2} \cdot \phi_2\right) - \sin \left(\frac{1}{2} \cdot \phi_1\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right) + -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) - \sin \left(\frac{1}{2} \cdot \phi_1\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right), \mathsf{\_.f64}\left(\color{blue}{\phi_1}, \phi_2\right)\right)\right) \]
            2. mul-1-negN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\lambda_1 \cdot \left(\cos \left(\frac{1}{2} \cdot \phi_1\right) \cdot \cos \left(\frac{1}{2} \cdot \phi_2\right) - \sin \left(\frac{1}{2} \cdot \phi_1\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right) + \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) - \sin \left(\frac{1}{2} \cdot \phi_1\right) \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. unsub-negN/A

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\phi_2, \color{blue}{\left(\lambda_1 \cdot \cos \left(\frac{1}{2} \cdot \phi_2\right) - \lambda_2 \cdot \cos \left(\frac{1}{2} \cdot \phi_2\right)\right)}\right)\right) \]
            6. distribute-rgt-out--N/A

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

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

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

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

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\phi_2, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_2\right)\right), \mathsf{\_.f64}\left(\lambda_1, \color{blue}{\lambda_2}\right)\right)\right)\right) \]
          14. Simplified82.5%

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

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

        Alternative 6: 75.7% accurate, 1.5× speedup?

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

          1. Initial program 66.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--.f6498.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. Simplified98.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. Step-by-step derivation
            1. *-commutativeN/A

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

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

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

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\frac{\cos \left(\frac{\phi_1 + \phi_2}{2}\right)}{\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}}\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(\cos \left(\frac{\phi_1 + \phi_2}{2}\right), \left(\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}\right)\right), \mathsf{\_.f64}\left(\color{blue}{\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{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}\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{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right), \left(\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}\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{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right), \left(\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
            9. clear-numN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\lambda_1 \cdot \left(\cos \left(\frac{1}{2} \cdot \phi_1\right) \cdot \cos \left(\frac{1}{2} \cdot \phi_2\right) - \sin \left(\frac{1}{2} \cdot \phi_1\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right) + -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) - \sin \left(\frac{1}{2} \cdot \phi_1\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right), \mathsf{\_.f64}\left(\color{blue}{\phi_1}, \phi_2\right)\right)\right) \]
            2. mul-1-negN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\lambda_1 \cdot \left(\cos \left(\frac{1}{2} \cdot \phi_1\right) \cdot \cos \left(\frac{1}{2} \cdot \phi_2\right) - \sin \left(\frac{1}{2} \cdot \phi_1\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right) + \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) - \sin \left(\frac{1}{2} \cdot \phi_1\right) \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. unsub-negN/A

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

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

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

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

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

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

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

              \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{hypot}\left(\phi_1, \color{blue}{\lambda_1 \cdot \cos \left(\frac{1}{2} \cdot \phi_1\right) - \lambda_2 \cdot \cos \left(\frac{1}{2} \cdot \phi_1\right)}\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 \cdot \cos \left(\frac{1}{2} \cdot \phi_1\right) - \lambda_2 \cdot \cos \left(\frac{1}{2} \cdot \phi_1\right)\right)}\right)\right) \]
            6. distribute-rgt-out--N/A

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

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

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

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

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\phi_1, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_1\right)\right), \mathsf{\_.f64}\left(\lambda_1, \color{blue}{\lambda_2}\right)\right)\right)\right) \]
          14. Simplified82.3%

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

          if 1.9599999999999999e-22 < phi2

          1. Initial program 53.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--.f6489.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. Simplified89.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(\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. associate-/l*N/A

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

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

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

            \[\leadsto \color{blue}{0 - \phi_1 \cdot \left(R - R \cdot \frac{\phi_2}{\phi_1}\right)} \]
          8. Taylor expanded in phi1 around 0

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

              \[\leadsto -1 \cdot \left(R \cdot \phi_1\right) + \color{blue}{\left(\mathsf{neg}\left(-1 \cdot \left(R \cdot \phi_2\right)\right)\right)} \]
            2. neg-mul-1N/A

              \[\leadsto -1 \cdot \left(R \cdot \phi_1\right) + -1 \cdot \color{blue}{\left(-1 \cdot \left(R \cdot \phi_2\right)\right)} \]
            3. distribute-lft-inN/A

              \[\leadsto -1 \cdot \color{blue}{\left(R \cdot \phi_1 + -1 \cdot \left(R \cdot \phi_2\right)\right)} \]
            4. +-commutativeN/A

              \[\leadsto -1 \cdot \left(-1 \cdot \left(R \cdot \phi_2\right) + \color{blue}{R \cdot \phi_1}\right) \]
            5. distribute-lft-inN/A

              \[\leadsto -1 \cdot \left(-1 \cdot \left(R \cdot \phi_2\right)\right) + \color{blue}{-1 \cdot \left(R \cdot \phi_1\right)} \]
            6. neg-mul-1N/A

              \[\leadsto \left(\mathsf{neg}\left(-1 \cdot \left(R \cdot \phi_2\right)\right)\right) + \color{blue}{-1} \cdot \left(R \cdot \phi_1\right) \]
            7. mul-1-negN/A

              \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(R \cdot \phi_2\right)\right)\right)\right) + -1 \cdot \left(R \cdot \phi_1\right) \]
            8. remove-double-negN/A

              \[\leadsto R \cdot \phi_2 + \color{blue}{-1} \cdot \left(R \cdot \phi_1\right) \]
            9. mul-1-negN/A

              \[\leadsto R \cdot \phi_2 + \left(\mathsf{neg}\left(R \cdot \phi_1\right)\right) \]
            10. sub-negN/A

              \[\leadsto R \cdot \phi_2 - \color{blue}{R \cdot \phi_1} \]
            11. distribute-lft-out--N/A

              \[\leadsto R \cdot \color{blue}{\left(\phi_2 - \phi_1\right)} \]
            12. *-lowering-*.f64N/A

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

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

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

        Alternative 7: 96.3% 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 62.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--.f6496.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. Simplified96.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. Final simplification96.0%

          \[\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 8: 69.2% accurate, 3.0× speedup?

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

          1. Initial program 66.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--.f6498.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. Simplified98.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. Simplified92.7%

              \[\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) \]
            2. Taylor expanded in phi2 around 0

              \[\leadsto \color{blue}{R \cdot \sqrt{{\phi_1}^{2} + {\left(\lambda_1 - \lambda_2\right)}^{2}}} \]
            3. 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--.f6476.9%

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

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

            if 4.2999999999999998e-47 < phi2

            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--.f6490.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. Simplified90.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 \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. associate-/l*N/A

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

                \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(\phi_1, \mathsf{\_.f64}\left(R, \mathsf{*.f64}\left(R, \color{blue}{\left(\frac{\phi_2}{\phi_1}\right)}\right)\right)\right)\right) \]
              10. /-lowering-/.f6450.4%

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

              \[\leadsto \color{blue}{0 - \phi_1 \cdot \left(R - R \cdot \frac{\phi_2}{\phi_1}\right)} \]
            8. Taylor expanded in phi1 around 0

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

                \[\leadsto -1 \cdot \left(R \cdot \phi_1\right) + \color{blue}{\left(\mathsf{neg}\left(-1 \cdot \left(R \cdot \phi_2\right)\right)\right)} \]
              2. neg-mul-1N/A

                \[\leadsto -1 \cdot \left(R \cdot \phi_1\right) + -1 \cdot \color{blue}{\left(-1 \cdot \left(R \cdot \phi_2\right)\right)} \]
              3. distribute-lft-inN/A

                \[\leadsto -1 \cdot \color{blue}{\left(R \cdot \phi_1 + -1 \cdot \left(R \cdot \phi_2\right)\right)} \]
              4. +-commutativeN/A

                \[\leadsto -1 \cdot \left(-1 \cdot \left(R \cdot \phi_2\right) + \color{blue}{R \cdot \phi_1}\right) \]
              5. distribute-lft-inN/A

                \[\leadsto -1 \cdot \left(-1 \cdot \left(R \cdot \phi_2\right)\right) + \color{blue}{-1 \cdot \left(R \cdot \phi_1\right)} \]
              6. neg-mul-1N/A

                \[\leadsto \left(\mathsf{neg}\left(-1 \cdot \left(R \cdot \phi_2\right)\right)\right) + \color{blue}{-1} \cdot \left(R \cdot \phi_1\right) \]
              7. mul-1-negN/A

                \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(R \cdot \phi_2\right)\right)\right)\right) + -1 \cdot \left(R \cdot \phi_1\right) \]
              8. remove-double-negN/A

                \[\leadsto R \cdot \phi_2 + \color{blue}{-1} \cdot \left(R \cdot \phi_1\right) \]
              9. mul-1-negN/A

                \[\leadsto R \cdot \phi_2 + \left(\mathsf{neg}\left(R \cdot \phi_1\right)\right) \]
              10. sub-negN/A

                \[\leadsto R \cdot \phi_2 - \color{blue}{R \cdot \phi_1} \]
              11. distribute-lft-out--N/A

                \[\leadsto R \cdot \color{blue}{\left(\phi_2 - \phi_1\right)} \]
              12. *-lowering-*.f64N/A

                \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\phi_2 - \phi_1\right)}\right) \]
              13. --lowering--.f6466.0%

                \[\leadsto \mathsf{*.f64}\left(R, \mathsf{\_.f64}\left(\phi_2, \color{blue}{\phi_1}\right)\right) \]
            10. Simplified66.0%

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

          Alternative 9: 30.9% accurate, 23.5× speedup?

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

            1. Initial program 66.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--.f6498.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. Simplified98.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 \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. associate-/l*N/A

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

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

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

              \[\leadsto \color{blue}{0 - \phi_1 \cdot \left(R - R \cdot \frac{\phi_2}{\phi_1}\right)} \]
            8. Step-by-step derivation
              1. associate-*r/N/A

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

                \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(\phi_1, \mathsf{\_.f64}\left(R, \left(\frac{\phi_2 \cdot R}{\phi_1}\right)\right)\right)\right) \]
              3. associate-/l*N/A

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

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

                \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(\phi_1, \mathsf{\_.f64}\left(R, \mathsf{*.f64}\left(\phi_2, \mathsf{/.f64}\left(R, \color{blue}{\phi_1}\right)\right)\right)\right)\right) \]
            9. Applied egg-rr21.5%

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

            if 2.5000000000000001e-57 < phi2

            1. Initial program 54.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--.f6490.5%

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

              \[\leadsto \color{blue}{R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
            4. 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. associate-/l*N/A

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

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

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

              \[\leadsto \color{blue}{0 - \phi_1 \cdot \left(R - R \cdot \frac{\phi_2}{\phi_1}\right)} \]
            8. Taylor expanded in phi1 around 0

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

                \[\leadsto -1 \cdot \left(R \cdot \phi_1\right) + \color{blue}{\left(\mathsf{neg}\left(-1 \cdot \left(R \cdot \phi_2\right)\right)\right)} \]
              2. neg-mul-1N/A

                \[\leadsto -1 \cdot \left(R \cdot \phi_1\right) + -1 \cdot \color{blue}{\left(-1 \cdot \left(R \cdot \phi_2\right)\right)} \]
              3. distribute-lft-inN/A

                \[\leadsto -1 \cdot \color{blue}{\left(R \cdot \phi_1 + -1 \cdot \left(R \cdot \phi_2\right)\right)} \]
              4. +-commutativeN/A

                \[\leadsto -1 \cdot \left(-1 \cdot \left(R \cdot \phi_2\right) + \color{blue}{R \cdot \phi_1}\right) \]
              5. distribute-lft-inN/A

                \[\leadsto -1 \cdot \left(-1 \cdot \left(R \cdot \phi_2\right)\right) + \color{blue}{-1 \cdot \left(R \cdot \phi_1\right)} \]
              6. neg-mul-1N/A

                \[\leadsto \left(\mathsf{neg}\left(-1 \cdot \left(R \cdot \phi_2\right)\right)\right) + \color{blue}{-1} \cdot \left(R \cdot \phi_1\right) \]
              7. mul-1-negN/A

                \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(R \cdot \phi_2\right)\right)\right)\right) + -1 \cdot \left(R \cdot \phi_1\right) \]
              8. remove-double-negN/A

                \[\leadsto R \cdot \phi_2 + \color{blue}{-1} \cdot \left(R \cdot \phi_1\right) \]
              9. mul-1-negN/A

                \[\leadsto R \cdot \phi_2 + \left(\mathsf{neg}\left(R \cdot \phi_1\right)\right) \]
              10. sub-negN/A

                \[\leadsto R \cdot \phi_2 - \color{blue}{R \cdot \phi_1} \]
              11. distribute-lft-out--N/A

                \[\leadsto R \cdot \color{blue}{\left(\phi_2 - \phi_1\right)} \]
              12. *-lowering-*.f64N/A

                \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\phi_2 - \phi_1\right)}\right) \]
              13. --lowering--.f6465.2%

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

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

            \[\leadsto \begin{array}{l} \mathbf{if}\;\phi_2 \leq 2.5 \cdot 10^{-57}:\\ \;\;\;\;\phi_1 \cdot \left(\phi_2 \cdot \frac{R}{\phi_1} - R\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(\phi_2 - \phi_1\right)\\ \end{array} \]
          5. Add Preprocessing

          Alternative 10: 30.1% accurate, 23.5× speedup?

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

            1. Initial program 66.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--.f6498.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. Simplified98.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 \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. associate-/l*N/A

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

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

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

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

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

                \[\leadsto \mathsf{neg}\left(\left(R - R \cdot \frac{\phi_2}{\phi_1}\right) \cdot \phi_1\right) \]
              3. distribute-lft-neg-inN/A

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

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

                \[\leadsto \mathsf{*.f64}\left(\mathsf{neg.f64}\left(\left(R - R \cdot \frac{\phi_2}{\phi_1}\right)\right), \phi_1\right) \]
              6. --lowering--.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{neg.f64}\left(\mathsf{\_.f64}\left(R, \left(R \cdot \frac{\phi_2}{\phi_1}\right)\right)\right), \phi_1\right) \]
              7. clear-numN/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{neg.f64}\left(\mathsf{\_.f64}\left(R, \left(R \cdot \frac{1}{\frac{\phi_1}{\phi_2}}\right)\right)\right), \phi_1\right) \]
              8. un-div-invN/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{neg.f64}\left(\mathsf{\_.f64}\left(R, \left(\frac{R}{\frac{\phi_1}{\phi_2}}\right)\right)\right), \phi_1\right) \]
              9. /-lowering-/.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{neg.f64}\left(\mathsf{\_.f64}\left(R, \mathsf{/.f64}\left(R, \left(\frac{\phi_1}{\phi_2}\right)\right)\right)\right), \phi_1\right) \]
              10. /-lowering-/.f6420.2%

                \[\leadsto \mathsf{*.f64}\left(\mathsf{neg.f64}\left(\mathsf{\_.f64}\left(R, \mathsf{/.f64}\left(R, \mathsf{/.f64}\left(\phi_1, \phi_2\right)\right)\right)\right), \phi_1\right) \]
            9. Applied egg-rr20.2%

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

            if 3.1e-24 < phi2

            1. Initial program 53.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--.f6489.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. Simplified89.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(\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. associate-/l*N/A

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

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

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

              \[\leadsto \color{blue}{0 - \phi_1 \cdot \left(R - R \cdot \frac{\phi_2}{\phi_1}\right)} \]
            8. Taylor expanded in phi1 around 0

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

                \[\leadsto -1 \cdot \left(R \cdot \phi_1\right) + \color{blue}{\left(\mathsf{neg}\left(-1 \cdot \left(R \cdot \phi_2\right)\right)\right)} \]
              2. neg-mul-1N/A

                \[\leadsto -1 \cdot \left(R \cdot \phi_1\right) + -1 \cdot \color{blue}{\left(-1 \cdot \left(R \cdot \phi_2\right)\right)} \]
              3. distribute-lft-inN/A

                \[\leadsto -1 \cdot \color{blue}{\left(R \cdot \phi_1 + -1 \cdot \left(R \cdot \phi_2\right)\right)} \]
              4. +-commutativeN/A

                \[\leadsto -1 \cdot \left(-1 \cdot \left(R \cdot \phi_2\right) + \color{blue}{R \cdot \phi_1}\right) \]
              5. distribute-lft-inN/A

                \[\leadsto -1 \cdot \left(-1 \cdot \left(R \cdot \phi_2\right)\right) + \color{blue}{-1 \cdot \left(R \cdot \phi_1\right)} \]
              6. neg-mul-1N/A

                \[\leadsto \left(\mathsf{neg}\left(-1 \cdot \left(R \cdot \phi_2\right)\right)\right) + \color{blue}{-1} \cdot \left(R \cdot \phi_1\right) \]
              7. mul-1-negN/A

                \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(R \cdot \phi_2\right)\right)\right)\right) + -1 \cdot \left(R \cdot \phi_1\right) \]
              8. remove-double-negN/A

                \[\leadsto R \cdot \phi_2 + \color{blue}{-1} \cdot \left(R \cdot \phi_1\right) \]
              9. mul-1-negN/A

                \[\leadsto R \cdot \phi_2 + \left(\mathsf{neg}\left(R \cdot \phi_1\right)\right) \]
              10. sub-negN/A

                \[\leadsto R \cdot \phi_2 - \color{blue}{R \cdot \phi_1} \]
              11. distribute-lft-out--N/A

                \[\leadsto R \cdot \color{blue}{\left(\phi_2 - \phi_1\right)} \]
              12. *-lowering-*.f64N/A

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

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

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

            \[\leadsto \begin{array}{l} \mathbf{if}\;\phi_2 \leq 3.1 \cdot 10^{-24}:\\ \;\;\;\;\phi_1 \cdot \left(\frac{R}{\frac{\phi_1}{\phi_2}} - R\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(\phi_2 - \phi_1\right)\\ \end{array} \]
          5. Add Preprocessing

          Alternative 11: 30.0% accurate, 23.5× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\lambda_1 \leq -5 \cdot 10^{+47}:\\ \;\;\;\;\phi_1 \cdot \left(\frac{R \cdot \phi_2}{\phi_1} - R\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(\phi_2 - \phi_1\right)\\ \end{array} \end{array} \]
          (FPCore (R lambda1 lambda2 phi1 phi2)
           :precision binary64
           (if (<= lambda1 -5e+47)
             (* phi1 (- (/ (* R phi2) phi1) R))
             (* R (- phi2 phi1))))
          double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
          	double tmp;
          	if (lambda1 <= -5e+47) {
          		tmp = phi1 * (((R * phi2) / phi1) - R);
          	} else {
          		tmp = R * (phi2 - phi1);
          	}
          	return tmp;
          }
          
          real(8) function code(r, lambda1, lambda2, phi1, phi2)
              real(8), intent (in) :: r
              real(8), intent (in) :: lambda1
              real(8), intent (in) :: lambda2
              real(8), intent (in) :: phi1
              real(8), intent (in) :: phi2
              real(8) :: tmp
              if (lambda1 <= (-5d+47)) then
                  tmp = phi1 * (((r * phi2) / phi1) - r)
              else
                  tmp = r * (phi2 - phi1)
              end if
              code = tmp
          end function
          
          public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
          	double tmp;
          	if (lambda1 <= -5e+47) {
          		tmp = phi1 * (((R * phi2) / phi1) - R);
          	} else {
          		tmp = R * (phi2 - phi1);
          	}
          	return tmp;
          }
          
          def code(R, lambda1, lambda2, phi1, phi2):
          	tmp = 0
          	if lambda1 <= -5e+47:
          		tmp = phi1 * (((R * phi2) / phi1) - R)
          	else:
          		tmp = R * (phi2 - phi1)
          	return tmp
          
          function code(R, lambda1, lambda2, phi1, phi2)
          	tmp = 0.0
          	if (lambda1 <= -5e+47)
          		tmp = Float64(phi1 * Float64(Float64(Float64(R * phi2) / phi1) - R));
          	else
          		tmp = Float64(R * Float64(phi2 - phi1));
          	end
          	return tmp
          end
          
          function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
          	tmp = 0.0;
          	if (lambda1 <= -5e+47)
          		tmp = phi1 * (((R * phi2) / phi1) - R);
          	else
          		tmp = R * (phi2 - phi1);
          	end
          	tmp_2 = tmp;
          end
          
          code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, -5e+47], N[(phi1 * N[(N[(N[(R * phi2), $MachinePrecision] / phi1), $MachinePrecision] - R), $MachinePrecision]), $MachinePrecision], N[(R * N[(phi2 - phi1), $MachinePrecision]), $MachinePrecision]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;\lambda_1 \leq -5 \cdot 10^{+47}:\\
          \;\;\;\;\phi_1 \cdot \left(\frac{R \cdot \phi_2}{\phi_1} - R\right)\\
          
          \mathbf{else}:\\
          \;\;\;\;R \cdot \left(\phi_2 - \phi_1\right)\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if lambda1 < -5.00000000000000022e47

            1. Initial program 64.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--.f6494.8%

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

              \[\leadsto \color{blue}{R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
            4. 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. associate-/l*N/A

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

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

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

              \[\leadsto \color{blue}{0 - \phi_1 \cdot \left(R - R \cdot \frac{\phi_2}{\phi_1}\right)} \]
            8. Taylor expanded in phi1 around inf

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

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

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

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

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

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

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

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

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

                \[\leadsto \mathsf{*.f64}\left(\phi_1, \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\left(R \cdot \phi_2\right), \phi_1\right), R\right)\right) \]
              10. *-commutativeN/A

                \[\leadsto \mathsf{*.f64}\left(\phi_1, \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\left(\phi_2 \cdot R\right), \phi_1\right), R\right)\right) \]
              11. *-lowering-*.f6424.3%

                \[\leadsto \mathsf{*.f64}\left(\phi_1, \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\phi_2, R\right), \phi_1\right), R\right)\right) \]
            10. Simplified24.3%

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

            if -5.00000000000000022e47 < lambda1

            1. Initial program 62.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--.f6496.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. Simplified96.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 \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. associate-/l*N/A

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

                \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(\phi_1, \mathsf{\_.f64}\left(R, \mathsf{*.f64}\left(R, \color{blue}{\left(\frac{\phi_2}{\phi_1}\right)}\right)\right)\right)\right) \]
              10. /-lowering-/.f6431.6%

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

              \[\leadsto \color{blue}{0 - \phi_1 \cdot \left(R - R \cdot \frac{\phi_2}{\phi_1}\right)} \]
            8. Taylor expanded in phi1 around 0

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

                \[\leadsto -1 \cdot \left(R \cdot \phi_1\right) + \color{blue}{\left(\mathsf{neg}\left(-1 \cdot \left(R \cdot \phi_2\right)\right)\right)} \]
              2. neg-mul-1N/A

                \[\leadsto -1 \cdot \left(R \cdot \phi_1\right) + -1 \cdot \color{blue}{\left(-1 \cdot \left(R \cdot \phi_2\right)\right)} \]
              3. distribute-lft-inN/A

                \[\leadsto -1 \cdot \color{blue}{\left(R \cdot \phi_1 + -1 \cdot \left(R \cdot \phi_2\right)\right)} \]
              4. +-commutativeN/A

                \[\leadsto -1 \cdot \left(-1 \cdot \left(R \cdot \phi_2\right) + \color{blue}{R \cdot \phi_1}\right) \]
              5. distribute-lft-inN/A

                \[\leadsto -1 \cdot \left(-1 \cdot \left(R \cdot \phi_2\right)\right) + \color{blue}{-1 \cdot \left(R \cdot \phi_1\right)} \]
              6. neg-mul-1N/A

                \[\leadsto \left(\mathsf{neg}\left(-1 \cdot \left(R \cdot \phi_2\right)\right)\right) + \color{blue}{-1} \cdot \left(R \cdot \phi_1\right) \]
              7. mul-1-negN/A

                \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(R \cdot \phi_2\right)\right)\right)\right) + -1 \cdot \left(R \cdot \phi_1\right) \]
              8. remove-double-negN/A

                \[\leadsto R \cdot \phi_2 + \color{blue}{-1} \cdot \left(R \cdot \phi_1\right) \]
              9. mul-1-negN/A

                \[\leadsto R \cdot \phi_2 + \left(\mathsf{neg}\left(R \cdot \phi_1\right)\right) \]
              10. sub-negN/A

                \[\leadsto R \cdot \phi_2 - \color{blue}{R \cdot \phi_1} \]
              11. distribute-lft-out--N/A

                \[\leadsto R \cdot \color{blue}{\left(\phi_2 - \phi_1\right)} \]
              12. *-lowering-*.f64N/A

                \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\phi_2 - \phi_1\right)}\right) \]
              13. --lowering--.f6436.5%

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

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

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

          Alternative 12: 28.4% accurate, 32.8× speedup?

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

            1. Initial program 54.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--.f6492.8%

                \[\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. Simplified92.8%

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

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

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

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

                \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\frac{\cos \left(\frac{\phi_1 + \phi_2}{2}\right)}{\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}}\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(\cos \left(\frac{\phi_1 + \phi_2}{2}\right), \left(\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}\right)\right), \mathsf{\_.f64}\left(\color{blue}{\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{cos.f64}\left(\left(\frac{\phi_1 + \phi_2}{2}\right)\right), \left(\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}\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{cos.f64}\left(\mathsf{/.f64}\left(\left(\phi_1 + \phi_2\right), 2\right)\right), \left(\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}\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{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right), \left(\frac{\lambda_1 + \lambda_2}{\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2}\right)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
              9. clear-numN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\lambda_1 \cdot \left(\cos \left(\frac{1}{2} \cdot \phi_1\right) \cdot \cos \left(\frac{1}{2} \cdot \phi_2\right) - \sin \left(\frac{1}{2} \cdot \phi_1\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right) + -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) - \sin \left(\frac{1}{2} \cdot \phi_1\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)\right), \mathsf{\_.f64}\left(\color{blue}{\phi_1}, \phi_2\right)\right)\right) \]
              2. mul-1-negN/A

                \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\left(\lambda_1 \cdot \left(\cos \left(\frac{1}{2} \cdot \phi_1\right) \cdot \cos \left(\frac{1}{2} \cdot \phi_2\right) - \sin \left(\frac{1}{2} \cdot \phi_1\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right) + \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) - \sin \left(\frac{1}{2} \cdot \phi_1\right) \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. unsub-negN/A

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

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

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

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

                \[\leadsto \mathsf{*.f64}\left(R, \left(\mathsf{neg}\left(\phi_1\right)\right)\right) \]
              2. neg-lowering-neg.f6473.6%

                \[\leadsto \mathsf{*.f64}\left(R, \mathsf{neg.f64}\left(\phi_1\right)\right) \]
            14. Simplified73.6%

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

            if -1.05999999999999999e74 < phi1

            1. Initial program 64.8%

              \[R \cdot \sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)} \]
            2. Step-by-step derivation
              1. *-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 phi2 around inf

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

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

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

            \[\leadsto \begin{array}{l} \mathbf{if}\;\phi_1 \leq -1.06 \cdot 10^{+74}:\\ \;\;\;\;R \cdot \left(0 - \phi_1\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \phi_2\\ \end{array} \]
          5. Add Preprocessing

          Alternative 13: 29.9% accurate, 65.8× speedup?

          \[\begin{array}{l} \\ R \cdot \left(\phi_2 - \phi_1\right) \end{array} \]
          (FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (- phi2 phi1)))
          double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
          	return R * (phi2 - phi1);
          }
          
          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 - phi1)
          end function
          
          public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
          	return R * (phi2 - phi1);
          }
          
          def code(R, lambda1, lambda2, phi1, phi2):
          	return R * (phi2 - phi1)
          
          function code(R, lambda1, lambda2, phi1, phi2)
          	return Float64(R * Float64(phi2 - phi1))
          end
          
          function tmp = code(R, lambda1, lambda2, phi1, phi2)
          	tmp = R * (phi2 - phi1);
          end
          
          code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(phi2 - phi1), $MachinePrecision]), $MachinePrecision]
          
          \begin{array}{l}
          
          \\
          R \cdot \left(\phi_2 - \phi_1\right)
          \end{array}
          
          Derivation
          1. Initial program 62.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--.f6496.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. Simplified96.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(\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. associate-/l*N/A

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

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

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

            \[\leadsto \color{blue}{0 - \phi_1 \cdot \left(R - R \cdot \frac{\phi_2}{\phi_1}\right)} \]
          8. Taylor expanded in phi1 around 0

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

              \[\leadsto -1 \cdot \left(R \cdot \phi_1\right) + \color{blue}{\left(\mathsf{neg}\left(-1 \cdot \left(R \cdot \phi_2\right)\right)\right)} \]
            2. neg-mul-1N/A

              \[\leadsto -1 \cdot \left(R \cdot \phi_1\right) + -1 \cdot \color{blue}{\left(-1 \cdot \left(R \cdot \phi_2\right)\right)} \]
            3. distribute-lft-inN/A

              \[\leadsto -1 \cdot \color{blue}{\left(R \cdot \phi_1 + -1 \cdot \left(R \cdot \phi_2\right)\right)} \]
            4. +-commutativeN/A

              \[\leadsto -1 \cdot \left(-1 \cdot \left(R \cdot \phi_2\right) + \color{blue}{R \cdot \phi_1}\right) \]
            5. distribute-lft-inN/A

              \[\leadsto -1 \cdot \left(-1 \cdot \left(R \cdot \phi_2\right)\right) + \color{blue}{-1 \cdot \left(R \cdot \phi_1\right)} \]
            6. neg-mul-1N/A

              \[\leadsto \left(\mathsf{neg}\left(-1 \cdot \left(R \cdot \phi_2\right)\right)\right) + \color{blue}{-1} \cdot \left(R \cdot \phi_1\right) \]
            7. mul-1-negN/A

              \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(R \cdot \phi_2\right)\right)\right)\right) + -1 \cdot \left(R \cdot \phi_1\right) \]
            8. remove-double-negN/A

              \[\leadsto R \cdot \phi_2 + \color{blue}{-1} \cdot \left(R \cdot \phi_1\right) \]
            9. mul-1-negN/A

              \[\leadsto R \cdot \phi_2 + \left(\mathsf{neg}\left(R \cdot \phi_1\right)\right) \]
            10. sub-negN/A

              \[\leadsto R \cdot \phi_2 - \color{blue}{R \cdot \phi_1} \]
            11. distribute-lft-out--N/A

              \[\leadsto R \cdot \color{blue}{\left(\phi_2 - \phi_1\right)} \]
            12. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(\phi_2 - \phi_1\right)}\right) \]
            13. --lowering--.f6433.4%

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

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

          Alternative 14: 17.5% 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 62.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--.f6496.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. Simplified96.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 phi2 around inf

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

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

            \[\leadsto \color{blue}{R \cdot \phi_2} \]
          8. Add Preprocessing

          Reproduce

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