Average Error: 39.5 → 23.1
Time: 23.2s
Precision: binary64
\[[lambda1, lambda2]=\mathsf{sort}([lambda1, lambda2])\]
\[[phi1, phi2]=\mathsf{sort}([phi1, phi2])\]
\[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)} \]
\[\begin{array}{l} t_0 := \cos \left(0.5 \cdot \phi_2\right)\\ t_1 := \sin \left(0.5 \cdot \phi_1\right)\\ t_2 := \sin \left(0.5 \cdot \phi_2\right)\\ t_3 := t_1 \cdot t_2\\ t_4 := \cos \left(0.5 \cdot \phi_1\right)\\ \mathbf{if}\;\lambda_1 - \lambda_2 \leq -3.250801521433806 \cdot 10^{+194}:\\ \;\;\;\;R \cdot \left(\left(t_4 \cdot t_0 - t_3\right) \cdot \left(\lambda_2 - \lambda_1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_5 := R \cdot \left(\phi_2 - \phi_1\right)\\ \mathbf{if}\;\lambda_1 - \lambda_2 \leq -1.4797657161965226 \cdot 10^{+186}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;\lambda_1 - \lambda_2 \leq -1.858726378974967 \cdot 10^{+135}:\\ \;\;\;\;R \cdot \left(\left(t_1 \cdot \left(\lambda_1 \cdot t_2\right) + t_4 \cdot \left(\lambda_2 \cdot t_0\right)\right) - \left(\lambda_2 \cdot \log \left(e^{t_3}\right) + t_4 \cdot \left(\lambda_1 \cdot t_0\right)\right)\right)\\ \mathbf{elif}\;\lambda_1 - \lambda_2 \leq -2.91600759841242 \cdot 10^{+52} \lor \neg \left(\lambda_1 - \lambda_2 \leq -1.3869924756902689 \cdot 10^{+45}\right):\\ \;\;\;\;t_5\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_6 := \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\\ t_7 := \sqrt[3]{{\left(\lambda_1 - \lambda_2\right)}^{2} \cdot \left(t_6 \cdot t_6\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)}\\ R \cdot \left(\left|t_7\right| \cdot \sqrt{t_7}\right) \end{array}\\ \end{array}\\ \end{array} \]
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)}
\begin{array}{l}
t_0 := \cos \left(0.5 \cdot \phi_2\right)\\
t_1 := \sin \left(0.5 \cdot \phi_1\right)\\
t_2 := \sin \left(0.5 \cdot \phi_2\right)\\
t_3 := t_1 \cdot t_2\\
t_4 := \cos \left(0.5 \cdot \phi_1\right)\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -3.250801521433806 \cdot 10^{+194}:\\
\;\;\;\;R \cdot \left(\left(t_4 \cdot t_0 - t_3\right) \cdot \left(\lambda_2 - \lambda_1\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_5 := R \cdot \left(\phi_2 - \phi_1\right)\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -1.4797657161965226 \cdot 10^{+186}:\\
\;\;\;\;t_5\\

\mathbf{elif}\;\lambda_1 - \lambda_2 \leq -1.858726378974967 \cdot 10^{+135}:\\
\;\;\;\;R \cdot \left(\left(t_1 \cdot \left(\lambda_1 \cdot t_2\right) + t_4 \cdot \left(\lambda_2 \cdot t_0\right)\right) - \left(\lambda_2 \cdot \log \left(e^{t_3}\right) + t_4 \cdot \left(\lambda_1 \cdot t_0\right)\right)\right)\\

\mathbf{elif}\;\lambda_1 - \lambda_2 \leq -2.91600759841242 \cdot 10^{+52} \lor \neg \left(\lambda_1 - \lambda_2 \leq -1.3869924756902689 \cdot 10^{+45}\right):\\
\;\;\;\;t_5\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_6 := \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\\
t_7 := \sqrt[3]{{\left(\lambda_1 - \lambda_2\right)}^{2} \cdot \left(t_6 \cdot t_6\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)}\\
R \cdot \left(\left|t_7\right| \cdot \sqrt{t_7}\right)
\end{array}\\


\end{array}\\


\end{array}
(FPCore (R lambda1 lambda2 phi1 phi2)
 :precision binary64
 (*
  R
  (sqrt
   (+
    (*
     (* (- lambda1 lambda2) (cos (/ (+ phi1 phi2) 2.0)))
     (* (- lambda1 lambda2) (cos (/ (+ phi1 phi2) 2.0))))
    (* (- phi1 phi2) (- phi1 phi2))))))
(FPCore (R lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (cos (* 0.5 phi2)))
        (t_1 (sin (* 0.5 phi1)))
        (t_2 (sin (* 0.5 phi2)))
        (t_3 (* t_1 t_2))
        (t_4 (cos (* 0.5 phi1))))
   (if (<= (- lambda1 lambda2) -3.250801521433806e+194)
     (* R (* (- (* t_4 t_0) t_3) (- lambda2 lambda1)))
     (let* ((t_5 (* R (- phi2 phi1))))
       (if (<= (- lambda1 lambda2) -1.4797657161965226e+186)
         t_5
         (if (<= (- lambda1 lambda2) -1.858726378974967e+135)
           (*
            R
            (-
             (+ (* t_1 (* lambda1 t_2)) (* t_4 (* lambda2 t_0)))
             (+ (* lambda2 (log (exp t_3))) (* t_4 (* lambda1 t_0)))))
           (if (or (<= (- lambda1 lambda2) -2.91600759841242e+52)
                   (not (<= (- lambda1 lambda2) -1.3869924756902689e+45)))
             t_5
             (let* ((t_6 (cos (/ (+ phi1 phi2) 2.0)))
                    (t_7
                     (cbrt
                      (+
                       (* (pow (- lambda1 lambda2) 2.0) (* t_6 t_6))
                       (* (- phi1 phi2) (- phi1 phi2))))))
               (* R (* (fabs t_7) (sqrt t_7)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	return R * sqrt((((lambda1 - lambda2) * cos((phi1 + phi2) / 2.0)) * ((lambda1 - lambda2) * cos((phi1 + phi2) / 2.0))) + ((phi1 - phi2) * (phi1 - phi2)));
}
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = cos(0.5 * phi2);
	double t_1 = sin(0.5 * phi1);
	double t_2 = sin(0.5 * phi2);
	double t_3 = t_1 * t_2;
	double t_4 = cos(0.5 * phi1);
	double tmp;
	if ((lambda1 - lambda2) <= -3.250801521433806e+194) {
		tmp = R * (((t_4 * t_0) - t_3) * (lambda2 - lambda1));
	} else {
		double t_5 = R * (phi2 - phi1);
		double tmp_1;
		if ((lambda1 - lambda2) <= -1.4797657161965226e+186) {
			tmp_1 = t_5;
		} else if ((lambda1 - lambda2) <= -1.858726378974967e+135) {
			tmp_1 = R * (((t_1 * (lambda1 * t_2)) + (t_4 * (lambda2 * t_0))) - ((lambda2 * log(exp(t_3))) + (t_4 * (lambda1 * t_0))));
		} else if (((lambda1 - lambda2) <= -2.91600759841242e+52) || !((lambda1 - lambda2) <= -1.3869924756902689e+45)) {
			tmp_1 = t_5;
		} else {
			double t_6 = cos((phi1 + phi2) / 2.0);
			double t_7 = cbrt((pow((lambda1 - lambda2), 2.0) * (t_6 * t_6)) + ((phi1 - phi2) * (phi1 - phi2)));
			tmp_1 = R * (fabs(t_7) * sqrt(t_7));
		}
		tmp = tmp_1;
	}
	return tmp;
}

Error

Bits error versus R

Bits error versus lambda1

Bits error versus lambda2

Bits error versus phi1

Bits error versus phi2

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 4 regimes
  2. if (-.f64 lambda1 lambda2) < -3.25080152143380584e194

    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. Taylor expanded around -inf 33.0

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

      \[\leadsto R \cdot \color{blue}{\left(\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right) \cdot \left(\lambda_2 - \lambda_1\right)\right)} \]
    4. Using strategy rm
    5. Applied distribute-rgt-in_binary6433.0

      \[\leadsto R \cdot \left(\cos \color{blue}{\left(\phi_2 \cdot 0.5 + \phi_1 \cdot 0.5\right)} \cdot \left(\lambda_2 - \lambda_1\right)\right) \]
    6. Applied cos-sum_binary6428.5

      \[\leadsto R \cdot \left(\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)} \cdot \left(\lambda_2 - \lambda_1\right)\right) \]
    7. Simplified28.5

      \[\leadsto R \cdot \left(\left(\color{blue}{\cos \left(0.5 \cdot \phi_1\right) \cdot \cos \left(0.5 \cdot \phi_2\right)} - \sin \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right)\right) \cdot \left(\lambda_2 - \lambda_1\right)\right) \]
    8. Simplified28.5

      \[\leadsto R \cdot \left(\left(\cos \left(0.5 \cdot \phi_1\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \color{blue}{\sin \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)}\right) \cdot \left(\lambda_2 - \lambda_1\right)\right) \]
    9. Using strategy rm
    10. Applied cancel-sign-sub-inv_binary6428.5

      \[\leadsto R \cdot \left(\color{blue}{\left(\cos \left(0.5 \cdot \phi_1\right) \cdot \cos \left(0.5 \cdot \phi_2\right) + \left(-\sin \left(0.5 \cdot \phi_1\right)\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)} \cdot \left(\lambda_2 - \lambda_1\right)\right) \]
    11. Simplified28.5

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

    if -3.25080152143380584e194 < (-.f64 lambda1 lambda2) < -1.4797657161965226e186 or -1.8587263789749671e135 < (-.f64 lambda1 lambda2) < -2.9160075984124197e52 or -1.3869924756902689e45 < (-.f64 lambda1 lambda2)

    1. Initial program 25.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. Taylor expanded around -inf 18.1

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

    if -1.4797657161965226e186 < (-.f64 lambda1 lambda2) < -1.8587263789749671e135

    1. Initial program 51.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. Taylor expanded around -inf 35.9

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

      \[\leadsto R \cdot \color{blue}{\left(\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right) \cdot \left(\lambda_2 - \lambda_1\right)\right)} \]
    4. Using strategy rm
    5. Applied distribute-rgt-in_binary6435.9

      \[\leadsto R \cdot \left(\cos \color{blue}{\left(\phi_2 \cdot 0.5 + \phi_1 \cdot 0.5\right)} \cdot \left(\lambda_2 - \lambda_1\right)\right) \]
    6. Applied cos-sum_binary6433.8

      \[\leadsto R \cdot \left(\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)} \cdot \left(\lambda_2 - \lambda_1\right)\right) \]
    7. Simplified33.8

      \[\leadsto R \cdot \left(\left(\color{blue}{\cos \left(0.5 \cdot \phi_1\right) \cdot \cos \left(0.5 \cdot \phi_2\right)} - \sin \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right)\right) \cdot \left(\lambda_2 - \lambda_1\right)\right) \]
    8. Simplified33.8

      \[\leadsto R \cdot \left(\left(\cos \left(0.5 \cdot \phi_1\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \color{blue}{\sin \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)}\right) \cdot \left(\lambda_2 - \lambda_1\right)\right) \]
    9. Taylor expanded around 0 33.8

      \[\leadsto \color{blue}{R \cdot \left(\left(\sin \left(0.5 \cdot \phi_1\right) \cdot \left(\sin \left(0.5 \cdot \phi_2\right) \cdot \lambda_1\right) + \cos \left(0.5 \cdot \phi_1\right) \cdot \left(\lambda_2 \cdot \cos \left(0.5 \cdot \phi_2\right)\right)\right) - \left(\lambda_2 \cdot \left(\sin \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right) + \cos \left(0.5 \cdot \phi_1\right) \cdot \left(\cos \left(0.5 \cdot \phi_2\right) \cdot \lambda_1\right)\right)\right)} \]
    10. Simplified33.8

      \[\leadsto \color{blue}{R \cdot \left(\left(\sin \left(0.5 \cdot \phi_1\right) \cdot \left(\sin \left(0.5 \cdot \phi_2\right) \cdot \lambda_1\right) + \cos \left(0.5 \cdot \phi_1\right) \cdot \left(\lambda_2 \cdot \cos \left(0.5 \cdot \phi_2\right)\right)\right) - \left(\lambda_2 \cdot \left(\sin \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right) + \cos \left(0.5 \cdot \phi_1\right) \cdot \left(\lambda_1 \cdot \cos \left(0.5 \cdot \phi_2\right)\right)\right)\right)} \]
    11. Using strategy rm
    12. Applied add-log-exp_binary6433.8

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

    if -2.9160075984124197e52 < (-.f64 lambda1 lambda2) < -1.3869924756902689e45

    1. Initial program 22.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. Using strategy rm
    3. Applied add-cube-cbrt_binary6423.2

      \[\leadsto R \cdot \sqrt{\color{blue}{\left(\sqrt[3]{\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)} \cdot \sqrt[3]{\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) \cdot \sqrt[3]{\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)}}} \]
    4. Applied sqrt-prod_binary6423.2

      \[\leadsto R \cdot \color{blue}{\left(\sqrt{\sqrt[3]{\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)} \cdot \sqrt[3]{\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)}} \cdot \sqrt{\sqrt[3]{\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)} \]
    5. Simplified23.2

      \[\leadsto R \cdot \left(\color{blue}{\left|\sqrt[3]{{\left(\lambda_1 - \lambda_2\right)}^{2} \cdot \left(\cos \left(\frac{\phi_2 + \phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2 + \phi_1}{2}\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)}\right|} \cdot \sqrt{\sqrt[3]{\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) \]
    6. Simplified23.2

      \[\leadsto R \cdot \left(\left|\sqrt[3]{{\left(\lambda_1 - \lambda_2\right)}^{2} \cdot \left(\cos \left(\frac{\phi_2 + \phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2 + \phi_1}{2}\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)}\right| \cdot \color{blue}{\sqrt{\sqrt[3]{{\left(\lambda_1 - \lambda_2\right)}^{2} \cdot \left(\cos \left(\frac{\phi_2 + \phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2 + \phi_1}{2}\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)}}}\right) \]
  3. Recombined 4 regimes into one program.
  4. Final simplification23.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;\lambda_1 - \lambda_2 \leq -3.250801521433806 \cdot 10^{+194}:\\ \;\;\;\;R \cdot \left(\left(\cos \left(0.5 \cdot \phi_1\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \sin \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right) \cdot \left(\lambda_2 - \lambda_1\right)\right)\\ \mathbf{elif}\;\lambda_1 - \lambda_2 \leq -1.4797657161965226 \cdot 10^{+186}:\\ \;\;\;\;R \cdot \left(\phi_2 - \phi_1\right)\\ \mathbf{elif}\;\lambda_1 - \lambda_2 \leq -1.858726378974967 \cdot 10^{+135}:\\ \;\;\;\;R \cdot \left(\left(\sin \left(0.5 \cdot \phi_1\right) \cdot \left(\lambda_1 \cdot \sin \left(0.5 \cdot \phi_2\right)\right) + \cos \left(0.5 \cdot \phi_1\right) \cdot \left(\lambda_2 \cdot \cos \left(0.5 \cdot \phi_2\right)\right)\right) - \left(\lambda_2 \cdot \log \left(e^{\sin \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)}\right) + \cos \left(0.5 \cdot \phi_1\right) \cdot \left(\lambda_1 \cdot \cos \left(0.5 \cdot \phi_2\right)\right)\right)\right)\\ \mathbf{elif}\;\lambda_1 - \lambda_2 \leq -2.91600759841242 \cdot 10^{+52} \lor \neg \left(\lambda_1 - \lambda_2 \leq -1.3869924756902689 \cdot 10^{+45}\right):\\ \;\;\;\;R \cdot \left(\phi_2 - \phi_1\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(\left|\sqrt[3]{{\left(\lambda_1 - \lambda_2\right)}^{2} \cdot \left(\cos \left(\frac{\phi_1 + \phi_2}{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| \cdot \sqrt{\sqrt[3]{{\left(\lambda_1 - \lambda_2\right)}^{2} \cdot \left(\cos \left(\frac{\phi_1 + \phi_2}{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)\\ \end{array} \]

Reproduce

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