Average Error: 38.5 → 32.0
Time: 15.4s
Precision: 64
\[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 - \lambda_2 \le -4.330543006634275624428183352875814499184 \cdot 10^{206}:\\ \;\;\;\;R \cdot \left(\frac{\phi_2 \cdot \left(\lambda_2 \cdot \phi_1\right)}{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right) \cdot {\lambda_1}^{2}} + \left(\frac{\phi_2 \cdot \phi_1}{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right) \cdot \lambda_1} + \lambda_2 \cdot \cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)\right)\right)\\ \mathbf{elif}\;\lambda_1 - \lambda_2 \le -8.378816055247020241265646955025761601071 \cdot 10^{155}:\\ \;\;\;\;R \cdot \left(\left(-\frac{\phi_2 \cdot \left({\left(\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)\right)}^{2} \cdot \left(\lambda_1 \cdot \phi_1\right)\right)}{{\lambda_2}^{2}} \cdot \sqrt{\frac{1}{{\left(\left({\left(\sin \left(0.5 \cdot \phi_1\right)\right)}^{2} \cdot {\left(\sin \left(0.5 \cdot \phi_2\right)\right)}^{2} + {\left(\cos \left(0.5 \cdot \phi_1\right)\right)}^{2} \cdot {\left(\cos \left(0.5 \cdot \phi_2\right)\right)}^{2}\right) - 2 \cdot \left(\cos \left(0.5 \cdot \phi_1\right) \cdot \left(\sin \left(0.5 \cdot \phi_1\right) \cdot \left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)\right)\right)\right)}^{3}}}\right) - \sqrt{\frac{1}{\left({\left(\sin \left(0.5 \cdot \phi_1\right)\right)}^{2} \cdot {\left(\sin \left(0.5 \cdot \phi_2\right)\right)}^{2} + {\left(\cos \left(0.5 \cdot \phi_1\right)\right)}^{2} \cdot {\left(\cos \left(0.5 \cdot \phi_2\right)\right)}^{2}\right) - 2 \cdot \left(\cos \left(0.5 \cdot \phi_1\right) \cdot \left(\sin \left(0.5 \cdot \phi_1\right) \cdot \left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)\right)\right)}} \cdot \left({\left(\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)\right)}^{2} \cdot \lambda_1 + \frac{\phi_2 \cdot \phi_1}{\lambda_2}\right)\right)\\ \mathbf{elif}\;\lambda_1 - \lambda_2 \le -1.377196716013941703520320204259099357965 \cdot 10^{151}:\\ \;\;\;\;R \cdot \left(\frac{\phi_2 \cdot \left(\lambda_2 \cdot \phi_1\right)}{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right) \cdot {\lambda_1}^{2}} + \left(\frac{\phi_2 \cdot \phi_1}{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right) \cdot \lambda_1} + \lambda_2 \cdot \cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)\right)\right)\\ \mathbf{elif}\;\lambda_1 - \lambda_2 \le 6.500549118149245808362649594715217315713 \cdot 10^{144}:\\ \;\;\;\;R \cdot \sqrt{\left(\left({\lambda_2}^{2} \cdot {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \cos \left(0.5 \cdot \phi_1\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right)\right)}^{2} + {\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 {\lambda_1}^{2}\right) - 2 \cdot \left(\lambda_2 \cdot \left({\left(\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)\right)}^{2} \cdot \lambda_1\right)\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)}\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(\lambda_1 - \lambda_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 - \lambda_2 \le -4.330543006634275624428183352875814499184 \cdot 10^{206}:\\
\;\;\;\;R \cdot \left(\frac{\phi_2 \cdot \left(\lambda_2 \cdot \phi_1\right)}{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right) \cdot {\lambda_1}^{2}} + \left(\frac{\phi_2 \cdot \phi_1}{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right) \cdot \lambda_1} + \lambda_2 \cdot \cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)\right)\right)\\

\mathbf{elif}\;\lambda_1 - \lambda_2 \le -8.378816055247020241265646955025761601071 \cdot 10^{155}:\\
\;\;\;\;R \cdot \left(\left(-\frac{\phi_2 \cdot \left({\left(\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)\right)}^{2} \cdot \left(\lambda_1 \cdot \phi_1\right)\right)}{{\lambda_2}^{2}} \cdot \sqrt{\frac{1}{{\left(\left({\left(\sin \left(0.5 \cdot \phi_1\right)\right)}^{2} \cdot {\left(\sin \left(0.5 \cdot \phi_2\right)\right)}^{2} + {\left(\cos \left(0.5 \cdot \phi_1\right)\right)}^{2} \cdot {\left(\cos \left(0.5 \cdot \phi_2\right)\right)}^{2}\right) - 2 \cdot \left(\cos \left(0.5 \cdot \phi_1\right) \cdot \left(\sin \left(0.5 \cdot \phi_1\right) \cdot \left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)\right)\right)\right)}^{3}}}\right) - \sqrt{\frac{1}{\left({\left(\sin \left(0.5 \cdot \phi_1\right)\right)}^{2} \cdot {\left(\sin \left(0.5 \cdot \phi_2\right)\right)}^{2} + {\left(\cos \left(0.5 \cdot \phi_1\right)\right)}^{2} \cdot {\left(\cos \left(0.5 \cdot \phi_2\right)\right)}^{2}\right) - 2 \cdot \left(\cos \left(0.5 \cdot \phi_1\right) \cdot \left(\sin \left(0.5 \cdot \phi_1\right) \cdot \left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)\right)\right)}} \cdot \left({\left(\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)\right)}^{2} \cdot \lambda_1 + \frac{\phi_2 \cdot \phi_1}{\lambda_2}\right)\right)\\

\mathbf{elif}\;\lambda_1 - \lambda_2 \le -1.377196716013941703520320204259099357965 \cdot 10^{151}:\\
\;\;\;\;R \cdot \left(\frac{\phi_2 \cdot \left(\lambda_2 \cdot \phi_1\right)}{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right) \cdot {\lambda_1}^{2}} + \left(\frac{\phi_2 \cdot \phi_1}{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right) \cdot \lambda_1} + \lambda_2 \cdot \cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)\right)\right)\\

\mathbf{elif}\;\lambda_1 - \lambda_2 \le 6.500549118149245808362649594715217315713 \cdot 10^{144}:\\
\;\;\;\;R \cdot \sqrt{\left(\left({\lambda_2}^{2} \cdot {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \cos \left(0.5 \cdot \phi_1\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right)\right)}^{2} + {\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 {\lambda_1}^{2}\right) - 2 \cdot \left(\lambda_2 \cdot \left({\left(\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)\right)}^{2} \cdot \lambda_1\right)\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)}\\

\mathbf{else}:\\
\;\;\;\;R \cdot \left(\lambda_1 - \lambda_2\right)\\

\end{array}
double f(double R, double lambda1, double lambda2, double phi1, double phi2) {
        double r82986 = R;
        double r82987 = lambda1;
        double r82988 = lambda2;
        double r82989 = r82987 - r82988;
        double r82990 = phi1;
        double r82991 = phi2;
        double r82992 = r82990 + r82991;
        double r82993 = 2.0;
        double r82994 = r82992 / r82993;
        double r82995 = cos(r82994);
        double r82996 = r82989 * r82995;
        double r82997 = r82996 * r82996;
        double r82998 = r82990 - r82991;
        double r82999 = r82998 * r82998;
        double r83000 = r82997 + r82999;
        double r83001 = sqrt(r83000);
        double r83002 = r82986 * r83001;
        return r83002;
}

double f(double R, double lambda1, double lambda2, double phi1, double phi2) {
        double r83003 = lambda1;
        double r83004 = lambda2;
        double r83005 = r83003 - r83004;
        double r83006 = -4.3305430066342756e+206;
        bool r83007 = r83005 <= r83006;
        double r83008 = R;
        double r83009 = phi2;
        double r83010 = phi1;
        double r83011 = r83004 * r83010;
        double r83012 = r83009 * r83011;
        double r83013 = 0.5;
        double r83014 = r83009 + r83010;
        double r83015 = r83013 * r83014;
        double r83016 = cos(r83015);
        double r83017 = 2.0;
        double r83018 = pow(r83003, r83017);
        double r83019 = r83016 * r83018;
        double r83020 = r83012 / r83019;
        double r83021 = r83009 * r83010;
        double r83022 = r83016 * r83003;
        double r83023 = r83021 / r83022;
        double r83024 = r83004 * r83016;
        double r83025 = r83023 + r83024;
        double r83026 = r83020 + r83025;
        double r83027 = r83008 * r83026;
        double r83028 = -8.37881605524702e+155;
        bool r83029 = r83005 <= r83028;
        double r83030 = pow(r83016, r83017);
        double r83031 = r83003 * r83010;
        double r83032 = r83030 * r83031;
        double r83033 = r83009 * r83032;
        double r83034 = pow(r83004, r83017);
        double r83035 = r83033 / r83034;
        double r83036 = 1.0;
        double r83037 = r83013 * r83010;
        double r83038 = sin(r83037);
        double r83039 = pow(r83038, r83017);
        double r83040 = r83013 * r83009;
        double r83041 = sin(r83040);
        double r83042 = pow(r83041, r83017);
        double r83043 = r83039 * r83042;
        double r83044 = cos(r83037);
        double r83045 = pow(r83044, r83017);
        double r83046 = cos(r83040);
        double r83047 = pow(r83046, r83017);
        double r83048 = r83045 * r83047;
        double r83049 = r83043 + r83048;
        double r83050 = r83046 * r83041;
        double r83051 = r83038 * r83050;
        double r83052 = r83044 * r83051;
        double r83053 = r83017 * r83052;
        double r83054 = r83049 - r83053;
        double r83055 = 3.0;
        double r83056 = pow(r83054, r83055);
        double r83057 = r83036 / r83056;
        double r83058 = sqrt(r83057);
        double r83059 = r83035 * r83058;
        double r83060 = -r83059;
        double r83061 = r83036 / r83054;
        double r83062 = sqrt(r83061);
        double r83063 = r83030 * r83003;
        double r83064 = r83021 / r83004;
        double r83065 = r83063 + r83064;
        double r83066 = r83062 * r83065;
        double r83067 = r83060 - r83066;
        double r83068 = r83008 * r83067;
        double r83069 = -1.3771967160139417e+151;
        bool r83070 = r83005 <= r83069;
        double r83071 = 6.500549118149246e+144;
        bool r83072 = r83005 <= r83071;
        double r83073 = r83046 * r83044;
        double r83074 = r83041 * r83038;
        double r83075 = r83073 - r83074;
        double r83076 = pow(r83075, r83017);
        double r83077 = r83034 * r83076;
        double r83078 = r83009 * r83013;
        double r83079 = cos(r83078);
        double r83080 = r83010 * r83013;
        double r83081 = cos(r83080);
        double r83082 = r83079 * r83081;
        double r83083 = sin(r83078);
        double r83084 = sin(r83080);
        double r83085 = r83083 * r83084;
        double r83086 = r83082 - r83085;
        double r83087 = pow(r83086, r83017);
        double r83088 = r83087 * r83018;
        double r83089 = r83077 + r83088;
        double r83090 = r83004 * r83063;
        double r83091 = r83017 * r83090;
        double r83092 = r83089 - r83091;
        double r83093 = r83010 - r83009;
        double r83094 = r83093 * r83093;
        double r83095 = r83092 + r83094;
        double r83096 = sqrt(r83095);
        double r83097 = r83008 * r83096;
        double r83098 = r83008 * r83005;
        double r83099 = r83072 ? r83097 : r83098;
        double r83100 = r83070 ? r83027 : r83099;
        double r83101 = r83029 ? r83068 : r83100;
        double r83102 = r83007 ? r83027 : r83101;
        return r83102;
}

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 (- lambda1 lambda2) < -4.3305430066342756e+206 or -8.37881605524702e+155 < (- lambda1 lambda2) < -1.3771967160139417e+151

    1. Initial program 63.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 -inf 56.5

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

    if -4.3305430066342756e+206 < (- lambda1 lambda2) < -8.37881605524702e+155

    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 64.0

      \[\leadsto R \cdot \sqrt{\color{blue}{\left(\left({\lambda_2}^{2} \cdot {\left(\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)\right)}^{2} + {\left(\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)\right)}^{2} \cdot {\lambda_1}^{2}\right) - 2 \cdot \left(\lambda_2 \cdot \left({\left(\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)\right)}^{2} \cdot \lambda_1\right)\right)\right)} + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)}\]
    3. Using strategy rm
    4. Applied distribute-lft-in64.0

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

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

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

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

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

      \[\leadsto R \cdot \sqrt{\left(\left({\lambda_2}^{2} \cdot {\color{blue}{\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \cos \left(0.5 \cdot \phi_1\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right)\right)}}^{2} + {\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 {\lambda_1}^{2}\right) - 2 \cdot \left(\lambda_2 \cdot \left({\left(\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)\right)}^{2} \cdot \lambda_1\right)\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)}\]
    11. Taylor expanded around inf 55.5

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

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

    if -1.3771967160139417e+151 < (- lambda1 lambda2) < 6.500549118149246e+144

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

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

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

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

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

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

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

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

    if 6.500549118149246e+144 < (- lambda1 lambda2)

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

      \[\leadsto R \cdot \sqrt{\color{blue}{\left(\left({\lambda_2}^{2} \cdot {\left(\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)\right)}^{2} + {\left(\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)\right)}^{2} \cdot {\lambda_1}^{2}\right) - 2 \cdot \left(\lambda_2 \cdot \left({\left(\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)\right)}^{2} \cdot \lambda_1\right)\right)\right)} + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)}\]
    3. Taylor expanded around 0 38.6

      \[\leadsto R \cdot \color{blue}{\left(\lambda_1 - \lambda_2\right)}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification32.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;\lambda_1 - \lambda_2 \le -4.330543006634275624428183352875814499184 \cdot 10^{206}:\\ \;\;\;\;R \cdot \left(\frac{\phi_2 \cdot \left(\lambda_2 \cdot \phi_1\right)}{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right) \cdot {\lambda_1}^{2}} + \left(\frac{\phi_2 \cdot \phi_1}{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right) \cdot \lambda_1} + \lambda_2 \cdot \cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)\right)\right)\\ \mathbf{elif}\;\lambda_1 - \lambda_2 \le -8.378816055247020241265646955025761601071 \cdot 10^{155}:\\ \;\;\;\;R \cdot \left(\left(-\frac{\phi_2 \cdot \left({\left(\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)\right)}^{2} \cdot \left(\lambda_1 \cdot \phi_1\right)\right)}{{\lambda_2}^{2}} \cdot \sqrt{\frac{1}{{\left(\left({\left(\sin \left(0.5 \cdot \phi_1\right)\right)}^{2} \cdot {\left(\sin \left(0.5 \cdot \phi_2\right)\right)}^{2} + {\left(\cos \left(0.5 \cdot \phi_1\right)\right)}^{2} \cdot {\left(\cos \left(0.5 \cdot \phi_2\right)\right)}^{2}\right) - 2 \cdot \left(\cos \left(0.5 \cdot \phi_1\right) \cdot \left(\sin \left(0.5 \cdot \phi_1\right) \cdot \left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)\right)\right)\right)}^{3}}}\right) - \sqrt{\frac{1}{\left({\left(\sin \left(0.5 \cdot \phi_1\right)\right)}^{2} \cdot {\left(\sin \left(0.5 \cdot \phi_2\right)\right)}^{2} + {\left(\cos \left(0.5 \cdot \phi_1\right)\right)}^{2} \cdot {\left(\cos \left(0.5 \cdot \phi_2\right)\right)}^{2}\right) - 2 \cdot \left(\cos \left(0.5 \cdot \phi_1\right) \cdot \left(\sin \left(0.5 \cdot \phi_1\right) \cdot \left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)\right)\right)}} \cdot \left({\left(\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)\right)}^{2} \cdot \lambda_1 + \frac{\phi_2 \cdot \phi_1}{\lambda_2}\right)\right)\\ \mathbf{elif}\;\lambda_1 - \lambda_2 \le -1.377196716013941703520320204259099357965 \cdot 10^{151}:\\ \;\;\;\;R \cdot \left(\frac{\phi_2 \cdot \left(\lambda_2 \cdot \phi_1\right)}{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right) \cdot {\lambda_1}^{2}} + \left(\frac{\phi_2 \cdot \phi_1}{\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right) \cdot \lambda_1} + \lambda_2 \cdot \cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)\right)\right)\\ \mathbf{elif}\;\lambda_1 - \lambda_2 \le 6.500549118149245808362649594715217315713 \cdot 10^{144}:\\ \;\;\;\;R \cdot \sqrt{\left(\left({\lambda_2}^{2} \cdot {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \cos \left(0.5 \cdot \phi_1\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right)\right)}^{2} + {\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 {\lambda_1}^{2}\right) - 2 \cdot \left(\lambda_2 \cdot \left({\left(\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)\right)}^{2} \cdot \lambda_1\right)\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)}\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(\lambda_1 - \lambda_2\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020001 
(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))) (* (- lambda1 lambda2) (cos (/ (+ phi1 phi2) 2)))) (* (- phi1 phi2) (- phi1 phi2))))))