Equirectangular approximation to distance on a great circle

Percentage Accurate: 59.6% → 99.9%
Time: 17.9s
Alternatives: 12
Speedup: 1.6×

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 12 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.6% 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(\phi_2 \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \phi_1\right) - \sin \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_1\right)\right), \phi_1 - \phi_2\right) \end{array} \]
(FPCore (R lambda1 lambda2 phi1 phi2)
 :precision binary64
 (*
  R
  (hypot
   (*
    (- lambda1 lambda2)
    (-
     (* (cos (* phi2 0.5)) (cos (* 0.5 phi1)))
     (* (sin (* phi2 0.5)) (sin (* 0.5 phi1)))))
   (- phi1 phi2))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	return R * hypot(((lambda1 - lambda2) * ((cos((phi2 * 0.5)) * cos((0.5 * phi1))) - (sin((phi2 * 0.5)) * sin((0.5 * phi1))))), (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 * 0.5)) * Math.cos((0.5 * phi1))) - (Math.sin((phi2 * 0.5)) * Math.sin((0.5 * phi1))))), (phi1 - phi2));
}
def code(R, lambda1, lambda2, phi1, phi2):
	return R * math.hypot(((lambda1 - lambda2) * ((math.cos((phi2 * 0.5)) * math.cos((0.5 * phi1))) - (math.sin((phi2 * 0.5)) * math.sin((0.5 * phi1))))), (phi1 - phi2))
function code(R, lambda1, lambda2, phi1, phi2)
	return Float64(R * hypot(Float64(Float64(lambda1 - lambda2) * Float64(Float64(cos(Float64(phi2 * 0.5)) * cos(Float64(0.5 * phi1))) - Float64(sin(Float64(phi2 * 0.5)) * sin(Float64(0.5 * phi1))))), Float64(phi1 - phi2)))
end
function tmp = code(R, lambda1, lambda2, phi1, phi2)
	tmp = R * hypot(((lambda1 - lambda2) * ((cos((phi2 * 0.5)) * cos((0.5 * phi1))) - (sin((phi2 * 0.5)) * sin((0.5 * phi1))))), (phi1 - phi2));
end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[Sqrt[N[(N[(lambda1 - lambda2), $MachinePrecision] * N[(N[(N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi1), $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(\phi_2 \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \phi_1\right) - \sin \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_1\right)\right), \phi_1 - \phi_2\right)
\end{array}
Derivation
  1. Initial program 64.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--.f6497.1%

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\lambda_1, \left(1 + \left(\mathsf{neg}\left(\frac{\lambda_2}{\lambda_1}\right)\right)\right)\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, \phi_2\right)\right)\right) \]
    3. unsub-negN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\lambda_1, \left(1 - \frac{\lambda_2}{\lambda_1}\right)\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, \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, \mathsf{\_.f64}\left(1, \left(\frac{\lambda_2}{\lambda_1}\right)\right)\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, \phi_2\right)\right)\right) \]
    5. /-lowering-/.f6491.7%

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\lambda_1, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(\lambda_2, \lambda_1\right)\right)\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, \phi_2\right)\right)\right) \]
  7. Simplified91.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\lambda_1, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(\lambda_2, \lambda_1\right)\right)\right), \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)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
  9. Applied egg-rr93.6%

    \[\leadsto R \cdot \mathsf{hypot}\left(\left(\lambda_1 \cdot \left(1 - \frac{\lambda_2}{\lambda_1}\right)\right) \cdot \color{blue}{\left(\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)\right)}, \phi_1 - \phi_2\right) \]
  10. Taylor expanded in lambda1 around 0

    \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\color{blue}{\left(\lambda_1 + -1 \cdot \lambda_2\right)}, \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)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
  11. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 + \left(\mathsf{neg}\left(\lambda_2\right)\right)\right), \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)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    2. sub-negN/A

      \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\left(\lambda_1 - \lambda_2\right), \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)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
    3. --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(\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)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
  12. Simplified99.9%

    \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\left(\lambda_1 - \lambda_2\right)} \cdot \left(\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)\right), \phi_1 - \phi_2\right) \]
  13. Final simplification99.9%

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

Alternative 2: 93.0% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\phi_1 \leq -0.0115:\\ \;\;\;\;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 (<= phi1 -0.0115)
   (* 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 (phi1 <= -0.0115) {
		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 (phi1 <= -0.0115) {
		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 phi1 <= -0.0115:
		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 (phi1 <= -0.0115)
		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 (phi1 <= -0.0115)
		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[phi1, -0.0115], 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_1 \leq -0.0115:\\
\;\;\;\;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 phi1 < -0.0115

    1. Initial program 62.5%

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\phi_1, \phi_2\right), 2\right)\right)\right), \left(\phi_1 - \phi_2\right)\right)\right) \]
      9. --lowering--.f6492.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. Simplified92.6%

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

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

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

      if -0.0115 < phi1

      1. Initial program 65.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. Simplified95.1%

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

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

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

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

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

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

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

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

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

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

        Alternative 5: 31.1% accurate, 2.6× speedup?

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

          1. Initial program 64.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.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-/.f6419.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. Simplified19.6%

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

          if 4.00000000000000023e-288 < phi2 < 0.122

          1. Initial program 71.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{*.f64}\left(\left(\cos \left(\frac{1}{2} \cdot \left(\phi_1 + \phi_2\right)\right) \cdot R - \cos \left(\frac{1}{2} \cdot \left(\phi_1 + \phi_2\right)\right) \cdot \frac{R \cdot \lambda_2}{\lambda_1}\right), \mathsf{neg.f64}\left(\lambda_1\right)\right) \]
            3. distribute-lft-out--N/A

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(\phi_2, \phi_1\right)\right)\right), \mathsf{\_.f64}\left(R, \mathsf{/.f64}\left(\left(R \cdot \lambda_2\right), \lambda_1\right)\right)\right), \mathsf{neg.f64}\left(\lambda_1\right)\right) \]
            15. *-lowering-*.f6435.7%

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

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

          if 0.122 < phi2

          1. Initial program 59.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--.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. Taylor expanded in phi2 around inf

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{\left(1 - \frac{\phi_1 - \left(0.5 \cdot \left(0.5 + 0.5 \cdot \cos \left(2 \cdot \frac{\phi_1 + \phi_2}{2}\right)\right)\right) \cdot \frac{\left(\lambda_1 - \lambda_2\right) \cdot \left(\lambda_1 - \lambda_2\right)}{\phi_2}}{\phi_2}\right) \cdot \left(R \cdot \phi_2\right)} \]
          9. Taylor expanded in phi1 around inf

            \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(1, \color{blue}{\left(\frac{\phi_1}{\phi_2}\right)}\right), \mathsf{*.f64}\left(R, \phi_2\right)\right) \]
          10. Step-by-step derivation
            1. /-lowering-/.f6468.6%

              \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(\phi_1, \phi_2\right)\right), \mathsf{*.f64}\left(R, \phi_2\right)\right) \]
          11. Simplified68.6%

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

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

        Alternative 6: 31.9% accurate, 2.8× speedup?

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

          1. Initial program 46.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.1%

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(\phi_1, \phi_2\right)\right)\right), \left(\mathsf{neg}\left(\lambda_1\right)\right)\right)\right) \]
            10. neg-lowering-neg.f6413.7%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(\phi_1, \phi_2\right)\right)\right), \mathsf{neg.f64}\left(\lambda_1\right)\right)\right) \]
          7. Simplified13.7%

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

          if -6.2e170 < lambda2 < 9.8e148

          1. Initial program 68.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--.f6497.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. Simplified97.6%

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

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

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

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

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

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

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

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

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

          if 9.8e148 < lambda2

          1. Initial program 52.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--.f6493.2%

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

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

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

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

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

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

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \left(\phi_1 + \phi_2\right)\right)\right), \lambda_2\right)\right) \]
            5. +-lowering-+.f6452.5%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(\phi_1, \phi_2\right)\right)\right), \lambda_2\right)\right) \]
          7. Simplified52.5%

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

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

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

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

            \[\leadsto R \cdot \left(\color{blue}{\cos \left(0.5 \cdot \phi_1\right)} \cdot \lambda_2\right) \]
          11. Taylor expanded in phi1 around 0

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

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\lambda_2}\right) \]
          13. Simplified61.2%

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

          \[\leadsto \begin{array}{l} \mathbf{if}\;\lambda_2 \leq -6.2 \cdot 10^{+170}:\\ \;\;\;\;R \cdot \left(\left(0 - \lambda_1\right) \cdot \cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)\right)\\ \mathbf{elif}\;\lambda_2 \leq 9.8 \cdot 10^{+148}:\\ \;\;\;\;\phi_2 \cdot \left(R - \frac{R \cdot \phi_1}{\phi_2}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \lambda_2\\ \end{array} \]
        5. Add Preprocessing

        Alternative 7: 28.7% accurate, 12.2× speedup?

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

          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.1%

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

            \[\leadsto \color{blue}{R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
          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.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. Simplified19.2%

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

          if 2.39999999999999997e-282 < phi2 < 3.7999999999999997e-57

          1. Initial program 73.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--.f64100.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. Simplified100.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 lambda2 around inf

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

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

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

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

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \left(\phi_1 + \phi_2\right)\right)\right), \lambda_2\right)\right) \]
            5. +-lowering-+.f6420.8%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(\phi_1, \phi_2\right)\right)\right), \lambda_2\right)\right) \]
          7. Simplified20.8%

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

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

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\left(\frac{1}{2} \cdot \phi_1\right)\right), \lambda_2\right)\right) \]
            2. *-lowering-*.f6420.8%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_1\right)\right), \lambda_2\right)\right) \]
          10. Simplified20.8%

            \[\leadsto R \cdot \left(\color{blue}{\cos \left(0.5 \cdot \phi_1\right)} \cdot \lambda_2\right) \]
          11. Taylor expanded in phi1 around 0

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

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

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

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

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \left(\frac{1}{384} \cdot {\phi_1}^{2} - \frac{1}{8}\right)\right)\right), \lambda_2\right)\right) \]
            5. sub-negN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \left(\frac{1}{384} \cdot {\phi_1}^{2} + \left(\mathsf{neg}\left(\frac{1}{8}\right)\right)\right)\right)\right), \lambda_2\right)\right) \]
            6. metadata-evalN/A

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

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \mathsf{+.f64}\left(\left(\frac{1}{384} \cdot {\phi_1}^{2}\right), \frac{-1}{8}\right)\right)\right), \lambda_2\right)\right) \]
            8. *-commutativeN/A

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

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left({\phi_1}^{2}\right), \frac{1}{384}\right), \frac{-1}{8}\right)\right)\right), \lambda_2\right)\right) \]
            10. unpow2N/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(\phi_1 \cdot \phi_1\right), \frac{1}{384}\right), \frac{-1}{8}\right)\right)\right), \lambda_2\right)\right) \]
            11. *-lowering-*.f6430.2%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \frac{1}{384}\right), \frac{-1}{8}\right)\right)\right), \lambda_2\right)\right) \]
          13. Simplified30.2%

            \[\leadsto R \cdot \left(\color{blue}{\left(1 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(\left(\phi_1 \cdot \phi_1\right) \cdot 0.0026041666666666665 + -0.125\right)\right)} \cdot \lambda_2\right) \]

          if 3.7999999999999997e-57 < phi2

          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--.f6497.2%

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

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

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

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

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

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

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

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

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

          \[\leadsto \begin{array}{l} \mathbf{if}\;\phi_2 \leq 2.4 \cdot 10^{-282}:\\ \;\;\;\;\phi_1 \cdot \left(R \cdot \frac{\phi_2}{\phi_1} - R\right)\\ \mathbf{elif}\;\phi_2 \leq 3.8 \cdot 10^{-57}:\\ \;\;\;\;R \cdot \left(\lambda_2 \cdot \left(\left(\phi_1 \cdot \phi_1\right) \cdot \left(\left(\phi_1 \cdot \phi_1\right) \cdot 0.0026041666666666665 + -0.125\right) + 1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(\phi_2 \cdot \left(1 - \frac{\phi_1}{\phi_2}\right)\right)\\ \end{array} \]
        5. Add Preprocessing

        Alternative 8: 28.9% accurate, 17.3× speedup?

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

          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.1%

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

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

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

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

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\lambda_1, \left(1 + \left(\mathsf{neg}\left(\frac{\lambda_2}{\lambda_1}\right)\right)\right)\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, \phi_2\right)\right)\right) \]
            3. unsub-negN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\lambda_1, \left(1 - \frac{\lambda_2}{\lambda_1}\right)\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, \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, \mathsf{\_.f64}\left(1, \left(\frac{\lambda_2}{\lambda_1}\right)\right)\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, \phi_2\right)\right)\right) \]
            5. /-lowering-/.f6490.2%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\lambda_1, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(\lambda_2, \lambda_1\right)\right)\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, \phi_2\right)\right)\right) \]
          7. Simplified90.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\lambda_1, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(\lambda_2, \lambda_1\right)\right)\right), \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)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          9. Applied egg-rr92.2%

            \[\leadsto R \cdot \mathsf{hypot}\left(\left(\lambda_1 \cdot \left(1 - \frac{\lambda_2}{\lambda_1}\right)\right) \cdot \color{blue}{\left(\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)\right)}, \phi_1 - \phi_2\right) \]
          10. Taylor expanded in phi1 around -inf

            \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(-1 \cdot \phi_1\right)}\right) \]
          11. 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.f6421.3%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{neg.f64}\left(\phi_1\right)\right) \]
          12. Simplified21.3%

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

          if 2.10000000000000012e-282 < phi2 < 1.74999999999999991e-54

          1. Initial program 73.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--.f64100.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. Simplified100.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 lambda2 around inf

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

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

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

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

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \left(\phi_1 + \phi_2\right)\right)\right), \lambda_2\right)\right) \]
            5. +-lowering-+.f6420.8%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(\phi_1, \phi_2\right)\right)\right), \lambda_2\right)\right) \]
          7. Simplified20.8%

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

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

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\left(\frac{1}{2} \cdot \phi_1\right)\right), \lambda_2\right)\right) \]
            2. *-lowering-*.f6420.8%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_1\right)\right), \lambda_2\right)\right) \]
          10. Simplified20.8%

            \[\leadsto R \cdot \left(\color{blue}{\cos \left(0.5 \cdot \phi_1\right)} \cdot \lambda_2\right) \]
          11. Taylor expanded in phi1 around 0

            \[\leadsto \color{blue}{R \cdot \lambda_2} \]
          12. Step-by-step derivation
            1. *-lowering-*.f6422.3%

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\lambda_2}\right) \]
          13. Simplified22.3%

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

          if 1.74999999999999991e-54 < phi2

          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--.f6497.2%

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

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

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

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

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

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

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

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

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

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

        Alternative 9: 33.1% accurate, 23.5× speedup?

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

          1. Initial program 65.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--.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. Taylor expanded in phi2 around inf

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

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

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

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

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

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

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

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

          if 1.0500000000000001e149 < lambda2

          1. Initial program 52.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--.f6493.2%

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

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

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

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

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

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

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \left(\phi_1 + \phi_2\right)\right)\right), \lambda_2\right)\right) \]
            5. +-lowering-+.f6452.5%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(\phi_1, \phi_2\right)\right)\right), \lambda_2\right)\right) \]
          7. Simplified52.5%

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

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

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

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

            \[\leadsto R \cdot \left(\color{blue}{\cos \left(0.5 \cdot \phi_1\right)} \cdot \lambda_2\right) \]
          11. Taylor expanded in phi1 around 0

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

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\lambda_2}\right) \]
          13. Simplified61.2%

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

        Alternative 10: 27.7% accurate, 25.2× speedup?

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

          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.1%

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

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

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

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

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\lambda_1, \left(1 + \left(\mathsf{neg}\left(\frac{\lambda_2}{\lambda_1}\right)\right)\right)\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, \phi_2\right)\right)\right) \]
            3. unsub-negN/A

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\lambda_1, \left(1 - \frac{\lambda_2}{\lambda_1}\right)\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, \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, \mathsf{\_.f64}\left(1, \left(\frac{\lambda_2}{\lambda_1}\right)\right)\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, \phi_2\right)\right)\right) \]
            5. /-lowering-/.f6490.2%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\lambda_1, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(\lambda_2, \lambda_1\right)\right)\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, \phi_2\right)\right)\right) \]
          7. Simplified90.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\lambda_1, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(\lambda_2, \lambda_1\right)\right)\right), \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)\right), \mathsf{\_.f64}\left(\phi_1, \phi_2\right)\right)\right) \]
          9. Applied egg-rr92.2%

            \[\leadsto R \cdot \mathsf{hypot}\left(\left(\lambda_1 \cdot \left(1 - \frac{\lambda_2}{\lambda_1}\right)\right) \cdot \color{blue}{\left(\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)\right)}, \phi_1 - \phi_2\right) \]
          10. Taylor expanded in phi1 around -inf

            \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\left(-1 \cdot \phi_1\right)}\right) \]
          11. 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.f6421.3%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{neg.f64}\left(\phi_1\right)\right) \]
          12. Simplified21.3%

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

          if 2.04999999999999989e-282 < phi2 < 2.29999999999999986e-28

          1. Initial program 75.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--.f64100.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. Simplified100.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 lambda2 around inf

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

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

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

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

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \left(\phi_1 + \phi_2\right)\right)\right), \lambda_2\right)\right) \]
            5. +-lowering-+.f6419.4%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(\phi_1, \phi_2\right)\right)\right), \lambda_2\right)\right) \]
          7. Simplified19.4%

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

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

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\left(\frac{1}{2} \cdot \phi_1\right)\right), \lambda_2\right)\right) \]
            2. *-lowering-*.f6419.4%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_1\right)\right), \lambda_2\right)\right) \]
          10. Simplified19.4%

            \[\leadsto R \cdot \left(\color{blue}{\cos \left(0.5 \cdot \phi_1\right)} \cdot \lambda_2\right) \]
          11. Taylor expanded in phi1 around 0

            \[\leadsto \color{blue}{R \cdot \lambda_2} \]
          12. Step-by-step derivation
            1. *-lowering-*.f6420.7%

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\lambda_2}\right) \]
          13. Simplified20.7%

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

          if 2.29999999999999986e-28 < phi2

          1. Initial program 60.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--.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. Taylor expanded in phi2 around inf

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

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

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

          \[\leadsto \begin{array}{l} \mathbf{if}\;\phi_2 \leq 2.05 \cdot 10^{-282}:\\ \;\;\;\;\phi_1 \cdot \left(0 - R\right)\\ \mathbf{elif}\;\phi_2 \leq 2.3 \cdot 10^{-28}:\\ \;\;\;\;R \cdot \lambda_2\\ \mathbf{else}:\\ \;\;\;\;R \cdot \phi_2\\ \end{array} \]
        5. Add Preprocessing

        Alternative 11: 26.6% accurate, 41.0× speedup?

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \left(\phi_1 + \phi_2\right)\right)\right), \lambda_2\right)\right) \]
            5. +-lowering-+.f6419.5%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(\phi_1, \phi_2\right)\right)\right), \lambda_2\right)\right) \]
          7. Simplified19.5%

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

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

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\left(\frac{1}{2} \cdot \phi_1\right)\right), \lambda_2\right)\right) \]
            2. *-lowering-*.f6418.0%

              \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_1\right)\right), \lambda_2\right)\right) \]
          10. Simplified18.0%

            \[\leadsto R \cdot \left(\color{blue}{\cos \left(0.5 \cdot \phi_1\right)} \cdot \lambda_2\right) \]
          11. Taylor expanded in phi1 around 0

            \[\leadsto \color{blue}{R \cdot \lambda_2} \]
          12. Step-by-step derivation
            1. *-lowering-*.f6416.3%

              \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\lambda_2}\right) \]
          13. Simplified16.3%

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

          if 1.05000000000000003e-28 < phi2

          1. Initial program 60.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--.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. Taylor expanded in phi2 around inf

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

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

            \[\leadsto \color{blue}{R \cdot \phi_2} \]
        3. Recombined 2 regimes into one program.
        4. Add Preprocessing

        Alternative 12: 14.5% accurate, 109.7× speedup?

        \[\begin{array}{l} \\ R \cdot \lambda_2 \end{array} \]
        (FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R lambda2))
        double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
        	return R * lambda2;
        }
        
        real(8) function code(r, lambda1, lambda2, phi1, phi2)
            real(8), intent (in) :: r
            real(8), intent (in) :: lambda1
            real(8), intent (in) :: lambda2
            real(8), intent (in) :: phi1
            real(8), intent (in) :: phi2
            code = r * lambda2
        end function
        
        public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
        	return R * lambda2;
        }
        
        def code(R, lambda1, lambda2, phi1, phi2):
        	return R * lambda2
        
        function code(R, lambda1, lambda2, phi1, phi2)
        	return Float64(R * lambda2)
        end
        
        function tmp = code(R, lambda1, lambda2, phi1, phi2)
        	tmp = R * lambda2;
        end
        
        code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * lambda2), $MachinePrecision]
        
        \begin{array}{l}
        
        \\
        R \cdot \lambda_2
        \end{array}
        
        Derivation
        1. Initial program 64.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--.f6497.1%

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

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

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

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

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

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

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

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(\phi_1, \phi_2\right)\right)\right), \lambda_2\right)\right) \]
        7. Simplified17.7%

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

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

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\left(\frac{1}{2} \cdot \phi_1\right)\right), \lambda_2\right)\right) \]
          2. *-lowering-*.f6414.7%

            \[\leadsto \mathsf{*.f64}\left(R, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \phi_1\right)\right), \lambda_2\right)\right) \]
        10. Simplified14.7%

          \[\leadsto R \cdot \left(\color{blue}{\cos \left(0.5 \cdot \phi_1\right)} \cdot \lambda_2\right) \]
        11. Taylor expanded in phi1 around 0

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

            \[\leadsto \mathsf{*.f64}\left(R, \color{blue}{\lambda_2}\right) \]
        13. Simplified13.8%

          \[\leadsto \color{blue}{R \cdot \lambda_2} \]
        14. Add Preprocessing

        Reproduce

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