Average Error: 39.0 → 22.3
Time: 25.5s
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} \mathbf{if}\;\lambda_1 \leq -9.646905846161997 \cdot 10^{+118}:\\ \;\;\;\;R \cdot \left(\frac{{\cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)}^{2} \cdot \lambda_2}{\sqrt{{\cos \left(0.5 \cdot \phi_1\right)}^{2}}} - \lambda_1 \cdot \sqrt{{\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)}^{2}}\right)\\ \mathbf{elif}\;\lambda_1 \leq -6.246904993976676 \cdot 10^{+93}:\\ \;\;\;\;R \cdot \left(\phi_2 - \phi_1\right)\\ \mathbf{elif}\;\lambda_1 \leq -1.7398471697832115 \cdot 10^{+56}:\\ \;\;\;\;R \cdot \sqrt{\left({\phi_2}^{2} + \left({\cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)}^{2} \cdot {\lambda_1}^{2} + {\phi_1}^{2}\right)\right) - 2 \cdot \left(\phi_1 \cdot \phi_2\right)}\\ \mathbf{elif}\;\lambda_1 \leq -1.1746441344982227 \cdot 10^{-291}:\\ \;\;\;\;R \cdot \left(\phi_2 - \phi_1\right)\\ \mathbf{elif}\;\lambda_1 \leq 4.5327398704856855 \cdot 10^{-290}:\\ \;\;\;\;R \cdot \left(\frac{\lambda_2 \cdot \sqrt[3]{{\cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)}^{6}}}{\sqrt{{\cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)}^{2}}} - \lambda_1 \cdot \sqrt{{\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)}^{2}}\right)\\ \mathbf{elif}\;\lambda_1 \leq 1.2397414903679095 \cdot 10^{-62}:\\ \;\;\;\;R \cdot \left(\phi_2 - \phi_1\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(\frac{{\cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)}^{2} \cdot \lambda_2}{\sqrt{e^{\log \left({\cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)}^{2}\right)}}} - \lambda_1 \cdot \sqrt{{\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)}^{2}}\right)\\ \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}
\mathbf{if}\;\lambda_1 \leq -9.646905846161997 \cdot 10^{+118}:\\
\;\;\;\;R \cdot \left(\frac{{\cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)}^{2} \cdot \lambda_2}{\sqrt{{\cos \left(0.5 \cdot \phi_1\right)}^{2}}} - \lambda_1 \cdot \sqrt{{\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)}^{2}}\right)\\

\mathbf{elif}\;\lambda_1 \leq -6.246904993976676 \cdot 10^{+93}:\\
\;\;\;\;R \cdot \left(\phi_2 - \phi_1\right)\\

\mathbf{elif}\;\lambda_1 \leq -1.7398471697832115 \cdot 10^{+56}:\\
\;\;\;\;R \cdot \sqrt{\left({\phi_2}^{2} + \left({\cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)}^{2} \cdot {\lambda_1}^{2} + {\phi_1}^{2}\right)\right) - 2 \cdot \left(\phi_1 \cdot \phi_2\right)}\\

\mathbf{elif}\;\lambda_1 \leq -1.1746441344982227 \cdot 10^{-291}:\\
\;\;\;\;R \cdot \left(\phi_2 - \phi_1\right)\\

\mathbf{elif}\;\lambda_1 \leq 4.5327398704856855 \cdot 10^{-290}:\\
\;\;\;\;R \cdot \left(\frac{\lambda_2 \cdot \sqrt[3]{{\cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)}^{6}}}{\sqrt{{\cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)}^{2}}} - \lambda_1 \cdot \sqrt{{\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)}^{2}}\right)\\

\mathbf{elif}\;\lambda_1 \leq 1.2397414903679095 \cdot 10^{-62}:\\
\;\;\;\;R \cdot \left(\phi_2 - \phi_1\right)\\

\mathbf{else}:\\
\;\;\;\;R \cdot \left(\frac{{\cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)}^{2} \cdot \lambda_2}{\sqrt{e^{\log \left({\cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)}^{2}\right)}}} - \lambda_1 \cdot \sqrt{{\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)}^{2}}\right)\\

\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
 (if (<= lambda1 -9.646905846161997e+118)
   (*
    R
    (-
     (/
      (* (pow (cos (* 0.5 (+ phi1 phi2))) 2.0) lambda2)
      (sqrt (pow (cos (* 0.5 phi1)) 2.0)))
     (*
      lambda1
      (sqrt
       (pow
        (-
         (* (cos (* 0.5 phi1)) (cos (* 0.5 phi2)))
         (* (sin (* 0.5 phi1)) (sin (* 0.5 phi2))))
        2.0)))))
   (if (<= lambda1 -6.246904993976676e+93)
     (* R (- phi2 phi1))
     (if (<= lambda1 -1.7398471697832115e+56)
       (*
        R
        (sqrt
         (-
          (+
           (pow phi2 2.0)
           (+
            (* (pow (cos (* 0.5 (+ phi1 phi2))) 2.0) (pow lambda1 2.0))
            (pow phi1 2.0)))
          (* 2.0 (* phi1 phi2)))))
       (if (<= lambda1 -1.1746441344982227e-291)
         (* R (- phi2 phi1))
         (if (<= lambda1 4.5327398704856855e-290)
           (*
            R
            (-
             (/
              (* lambda2 (cbrt (pow (cos (* 0.5 (+ phi1 phi2))) 6.0)))
              (sqrt (pow (cos (* 0.5 (+ phi1 phi2))) 2.0)))
             (*
              lambda1
              (sqrt
               (pow
                (-
                 (* (cos (* 0.5 phi1)) (cos (* 0.5 phi2)))
                 (* (sin (* 0.5 phi1)) (sin (* 0.5 phi2))))
                2.0)))))
           (if (<= lambda1 1.2397414903679095e-62)
             (* R (- phi2 phi1))
             (*
              R
              (-
               (/
                (* (pow (cos (* 0.5 (+ phi1 phi2))) 2.0) lambda2)
                (sqrt (exp (log (pow (cos (* 0.5 (+ phi1 phi2))) 2.0)))))
               (*
                lambda1
                (sqrt
                 (pow
                  (-
                   (* (cos (* 0.5 phi1)) (cos (* 0.5 phi2)))
                   (* (sin (* 0.5 phi1)) (sin (* 0.5 phi2))))
                  2.0))))))))))))
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 tmp;
	if (lambda1 <= -9.646905846161997e+118) {
		tmp = R * (((pow(cos(0.5 * (phi1 + phi2)), 2.0) * lambda2) / sqrt(pow(cos(0.5 * phi1), 2.0))) - (lambda1 * sqrt(pow(((cos(0.5 * phi1) * cos(0.5 * phi2)) - (sin(0.5 * phi1) * sin(0.5 * phi2))), 2.0))));
	} else if (lambda1 <= -6.246904993976676e+93) {
		tmp = R * (phi2 - phi1);
	} else if (lambda1 <= -1.7398471697832115e+56) {
		tmp = R * sqrt((pow(phi2, 2.0) + ((pow(cos(0.5 * (phi1 + phi2)), 2.0) * pow(lambda1, 2.0)) + pow(phi1, 2.0))) - (2.0 * (phi1 * phi2)));
	} else if (lambda1 <= -1.1746441344982227e-291) {
		tmp = R * (phi2 - phi1);
	} else if (lambda1 <= 4.5327398704856855e-290) {
		tmp = R * (((lambda2 * cbrt(pow(cos(0.5 * (phi1 + phi2)), 6.0))) / sqrt(pow(cos(0.5 * (phi1 + phi2)), 2.0))) - (lambda1 * sqrt(pow(((cos(0.5 * phi1) * cos(0.5 * phi2)) - (sin(0.5 * phi1) * sin(0.5 * phi2))), 2.0))));
	} else if (lambda1 <= 1.2397414903679095e-62) {
		tmp = R * (phi2 - phi1);
	} else {
		tmp = R * (((pow(cos(0.5 * (phi1 + phi2)), 2.0) * lambda2) / sqrt(exp(log(pow(cos(0.5 * (phi1 + phi2)), 2.0))))) - (lambda1 * sqrt(pow(((cos(0.5 * phi1) * cos(0.5 * phi2)) - (sin(0.5 * phi1) * sin(0.5 * phi2))), 2.0))));
	}
	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 5 regimes
  2. if lambda1 < -9.64690584616199693e118

    1. Initial program 58.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. Using strategy rm
    3. Applied add-cube-cbrt_binary6458.1

      \[\leadsto R \cdot \sqrt{\left(\color{blue}{\left(\left(\sqrt[3]{\lambda_1 - \lambda_2} \cdot \sqrt[3]{\lambda_1 - \lambda_2}\right) \cdot \sqrt[3]{\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 associate-*l*_binary6458.1

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

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

      \[\leadsto R \cdot \color{blue}{\left(-\left(\sqrt{-{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)}^{2} \cdot {\left(\sqrt[3]{-1}\right)}^{3}} \cdot \lambda_1 + \frac{{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)}^{2} \cdot \left(\lambda_2 \cdot {\left(\sqrt[3]{-1}\right)}^{3}\right)}{\sqrt{-{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)}^{2} \cdot {\left(\sqrt[3]{-1}\right)}^{3}}}\right)\right)}\]
    7. Simplified23.0

      \[\leadsto R \cdot \color{blue}{\left(-\left(\sqrt{{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)}^{2} \cdot 1} \cdot \lambda_1 + \frac{{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)}^{2} \cdot \left(\lambda_2 \cdot -1\right)}{\sqrt{{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)}^{2} \cdot 1}}\right)\right)}\]
    8. Using strategy rm
    9. Applied distribute-rgt-in_binary6423.0

      \[\leadsto R \cdot \left(-\left(\sqrt{{\cos \color{blue}{\left(\phi_2 \cdot 0.5 + \phi_1 \cdot 0.5\right)}}^{2} \cdot 1} \cdot \lambda_1 + \frac{{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)}^{2} \cdot \left(\lambda_2 \cdot -1\right)}{\sqrt{{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)}^{2} \cdot 1}}\right)\right)\]
    10. Applied cos-sum_binary6417.1

      \[\leadsto R \cdot \left(-\left(\sqrt{{\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)}}^{2} \cdot 1} \cdot \lambda_1 + \frac{{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)}^{2} \cdot \left(\lambda_2 \cdot -1\right)}{\sqrt{{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)}^{2} \cdot 1}}\right)\right)\]
    11. Simplified17.1

      \[\leadsto R \cdot \left(-\left(\sqrt{{\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)}^{2} \cdot 1} \cdot \lambda_1 + \frac{{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)}^{2} \cdot \left(\lambda_2 \cdot -1\right)}{\sqrt{{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)}^{2} \cdot 1}}\right)\right)\]
    12. Simplified17.1

      \[\leadsto R \cdot \left(-\left(\sqrt{{\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)}^{2} \cdot 1} \cdot \lambda_1 + \frac{{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)}^{2} \cdot \left(\lambda_2 \cdot -1\right)}{\sqrt{{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)}^{2} \cdot 1}}\right)\right)\]
    13. Taylor expanded around 0 18.0

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

    if -9.64690584616199693e118 < lambda1 < -6.2469049939766764e93 or -1.7398471697832115e56 < lambda1 < -1.17464413449822267e-291 or 4.5327398704856855e-290 < lambda1 < 1.2397414903679095e-62

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

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

    if -6.2469049939766764e93 < lambda1 < -1.7398471697832115e56

    1. Initial program 28.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. Taylor expanded around 0 31.2

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

    if -1.17464413449822267e-291 < lambda1 < 4.5327398704856855e-290

    1. Initial program 34.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. Using strategy rm
    3. Applied add-cube-cbrt_binary6434.6

      \[\leadsto R \cdot \sqrt{\left(\color{blue}{\left(\left(\sqrt[3]{\lambda_1 - \lambda_2} \cdot \sqrt[3]{\lambda_1 - \lambda_2}\right) \cdot \sqrt[3]{\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 associate-*l*_binary6434.6

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

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

      \[\leadsto R \cdot \color{blue}{\left(-\left(\sqrt{-{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)}^{2} \cdot {\left(\sqrt[3]{-1}\right)}^{3}} \cdot \lambda_1 + \frac{{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)}^{2} \cdot \left(\lambda_2 \cdot {\left(\sqrt[3]{-1}\right)}^{3}\right)}{\sqrt{-{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)}^{2} \cdot {\left(\sqrt[3]{-1}\right)}^{3}}}\right)\right)}\]
    7. Simplified39.6

      \[\leadsto R \cdot \color{blue}{\left(-\left(\sqrt{{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)}^{2} \cdot 1} \cdot \lambda_1 + \frac{{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)}^{2} \cdot \left(\lambda_2 \cdot -1\right)}{\sqrt{{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)}^{2} \cdot 1}}\right)\right)}\]
    8. Using strategy rm
    9. Applied distribute-rgt-in_binary6439.6

      \[\leadsto R \cdot \left(-\left(\sqrt{{\cos \color{blue}{\left(\phi_2 \cdot 0.5 + \phi_1 \cdot 0.5\right)}}^{2} \cdot 1} \cdot \lambda_1 + \frac{{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)}^{2} \cdot \left(\lambda_2 \cdot -1\right)}{\sqrt{{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)}^{2} \cdot 1}}\right)\right)\]
    10. Applied cos-sum_binary6439.6

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

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

      \[\leadsto R \cdot \left(-\left(\sqrt{{\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)}^{2} \cdot 1} \cdot \lambda_1 + \frac{{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)}^{2} \cdot \left(\lambda_2 \cdot -1\right)}{\sqrt{{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)}^{2} \cdot 1}}\right)\right)\]
    13. Using strategy rm
    14. Applied add-cbrt-cube_binary6439.6

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

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

    if 1.2397414903679095e-62 < lambda1

    1. Initial program 49.1

      \[R \cdot \sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)}\]
    2. Using strategy rm
    3. Applied add-cube-cbrt_binary6449.2

      \[\leadsto R \cdot \sqrt{\left(\color{blue}{\left(\left(\sqrt[3]{\lambda_1 - \lambda_2} \cdot \sqrt[3]{\lambda_1 - \lambda_2}\right) \cdot \sqrt[3]{\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 associate-*l*_binary6449.2

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

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

      \[\leadsto R \cdot \color{blue}{\left(-\left(\sqrt{-{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)}^{2} \cdot {\left(\sqrt[3]{-1}\right)}^{3}} \cdot \lambda_1 + \frac{{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)}^{2} \cdot \left(\lambda_2 \cdot {\left(\sqrt[3]{-1}\right)}^{3}\right)}{\sqrt{-{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)}^{2} \cdot {\left(\sqrt[3]{-1}\right)}^{3}}}\right)\right)}\]
    7. Simplified24.3

      \[\leadsto R \cdot \color{blue}{\left(-\left(\sqrt{{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)}^{2} \cdot 1} \cdot \lambda_1 + \frac{{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)}^{2} \cdot \left(\lambda_2 \cdot -1\right)}{\sqrt{{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)}^{2} \cdot 1}}\right)\right)}\]
    8. Using strategy rm
    9. Applied distribute-rgt-in_binary6424.3

      \[\leadsto R \cdot \left(-\left(\sqrt{{\cos \color{blue}{\left(\phi_2 \cdot 0.5 + \phi_1 \cdot 0.5\right)}}^{2} \cdot 1} \cdot \lambda_1 + \frac{{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)}^{2} \cdot \left(\lambda_2 \cdot -1\right)}{\sqrt{{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)}^{2} \cdot 1}}\right)\right)\]
    10. Applied cos-sum_binary6424.3

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

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

      \[\leadsto R \cdot \left(-\left(\sqrt{{\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)}^{2} \cdot 1} \cdot \lambda_1 + \frac{{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)}^{2} \cdot \left(\lambda_2 \cdot -1\right)}{\sqrt{{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)}^{2} \cdot 1}}\right)\right)\]
    13. Using strategy rm
    14. Applied add-exp-log_binary6424.3

      \[\leadsto R \cdot \left(-\left(\sqrt{{\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)}^{2} \cdot 1} \cdot \lambda_1 + \frac{{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)}^{2} \cdot \left(\lambda_2 \cdot -1\right)}{\sqrt{\color{blue}{e^{\log \left({\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)}^{2}\right)}} \cdot 1}}\right)\right)\]
  3. Recombined 5 regimes into one program.
  4. Final simplification22.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;\lambda_1 \leq -9.646905846161997 \cdot 10^{+118}:\\ \;\;\;\;R \cdot \left(\frac{{\cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)}^{2} \cdot \lambda_2}{\sqrt{{\cos \left(0.5 \cdot \phi_1\right)}^{2}}} - \lambda_1 \cdot \sqrt{{\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)}^{2}}\right)\\ \mathbf{elif}\;\lambda_1 \leq -6.246904993976676 \cdot 10^{+93}:\\ \;\;\;\;R \cdot \left(\phi_2 - \phi_1\right)\\ \mathbf{elif}\;\lambda_1 \leq -1.7398471697832115 \cdot 10^{+56}:\\ \;\;\;\;R \cdot \sqrt{\left({\phi_2}^{2} + \left({\cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)}^{2} \cdot {\lambda_1}^{2} + {\phi_1}^{2}\right)\right) - 2 \cdot \left(\phi_1 \cdot \phi_2\right)}\\ \mathbf{elif}\;\lambda_1 \leq -1.1746441344982227 \cdot 10^{-291}:\\ \;\;\;\;R \cdot \left(\phi_2 - \phi_1\right)\\ \mathbf{elif}\;\lambda_1 \leq 4.5327398704856855 \cdot 10^{-290}:\\ \;\;\;\;R \cdot \left(\frac{\lambda_2 \cdot \sqrt[3]{{\cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)}^{6}}}{\sqrt{{\cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)}^{2}}} - \lambda_1 \cdot \sqrt{{\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)}^{2}}\right)\\ \mathbf{elif}\;\lambda_1 \leq 1.2397414903679095 \cdot 10^{-62}:\\ \;\;\;\;R \cdot \left(\phi_2 - \phi_1\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(\frac{{\cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)}^{2} \cdot \lambda_2}{\sqrt{e^{\log \left({\cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)}^{2}\right)}}} - \lambda_1 \cdot \sqrt{{\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)}^{2}}\right)\\ \end{array}\]

Reproduce

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