Average Error: 37.4 → 32.7
Time: 41.9s
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}\;\phi_2 \le 6.533615721542894 \cdot 10^{+124}:\\ \;\;\;\;\sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt[3]{\left(\left(\cos \left(\frac{\phi_2 + \phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2 + \phi_1}{2}\right)\right) \cdot \cos \left(\frac{\phi_2 + \phi_1}{2}\right)\right) \cdot \left(\left(\cos \left(\frac{\phi_2 + \phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2 + \phi_1}{2}\right)\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)} \cdot R\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(\phi_2 - \phi_1\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}\;\phi_2 \le 6.533615721542894 \cdot 10^{+124}:\\
\;\;\;\;\sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt[3]{\left(\left(\cos \left(\frac{\phi_2 + \phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2 + \phi_1}{2}\right)\right) \cdot \cos \left(\frac{\phi_2 + \phi_1}{2}\right)\right) \cdot \left(\left(\cos \left(\frac{\phi_2 + \phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2 + \phi_1}{2}\right)\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)} \cdot R\\

\mathbf{else}:\\
\;\;\;\;R \cdot \left(\phi_2 - \phi_1\right)\\

\end{array}
double f(double R, double lambda1, double lambda2, double phi1, double phi2) {
        double r3639069 = R;
        double r3639070 = lambda1;
        double r3639071 = lambda2;
        double r3639072 = r3639070 - r3639071;
        double r3639073 = phi1;
        double r3639074 = phi2;
        double r3639075 = r3639073 + r3639074;
        double r3639076 = 2.0;
        double r3639077 = r3639075 / r3639076;
        double r3639078 = cos(r3639077);
        double r3639079 = r3639072 * r3639078;
        double r3639080 = r3639079 * r3639079;
        double r3639081 = r3639073 - r3639074;
        double r3639082 = r3639081 * r3639081;
        double r3639083 = r3639080 + r3639082;
        double r3639084 = sqrt(r3639083);
        double r3639085 = r3639069 * r3639084;
        return r3639085;
}

double f(double R, double lambda1, double lambda2, double phi1, double phi2) {
        double r3639086 = phi2;
        double r3639087 = 6.533615721542894e+124;
        bool r3639088 = r3639086 <= r3639087;
        double r3639089 = lambda1;
        double r3639090 = lambda2;
        double r3639091 = r3639089 - r3639090;
        double r3639092 = r3639091 * r3639091;
        double r3639093 = phi1;
        double r3639094 = r3639086 + r3639093;
        double r3639095 = 2.0;
        double r3639096 = r3639094 / r3639095;
        double r3639097 = cos(r3639096);
        double r3639098 = r3639097 * r3639097;
        double r3639099 = r3639098 * r3639097;
        double r3639100 = r3639099 * r3639099;
        double r3639101 = cbrt(r3639100);
        double r3639102 = r3639092 * r3639101;
        double r3639103 = r3639093 - r3639086;
        double r3639104 = r3639103 * r3639103;
        double r3639105 = r3639102 + r3639104;
        double r3639106 = sqrt(r3639105);
        double r3639107 = R;
        double r3639108 = r3639106 * r3639107;
        double r3639109 = r3639086 - r3639093;
        double r3639110 = r3639107 * r3639109;
        double r3639111 = r3639088 ? r3639108 : r3639110;
        return r3639111;
}

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 2 regimes
  2. if phi2 < 6.533615721542894e+124

    1. Initial program 34.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 swap-sqr34.8

      \[\leadsto R \cdot \sqrt{\color{blue}{\left(\left(\lambda_1 - \lambda_2\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) \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)}\]
    4. Using strategy rm
    5. Applied add-cbrt-cube34.8

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

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

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

    if 6.533615721542894e+124 < phi2

    1. Initial program 56.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 swap-sqr56.0

      \[\leadsto R \cdot \sqrt{\color{blue}{\left(\left(\lambda_1 - \lambda_2\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) \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)}\]
    4. Using strategy rm
    5. Applied insert-posit1656.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\phi_2 \le 6.533615721542894 \cdot 10^{+124}:\\ \;\;\;\;\sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt[3]{\left(\left(\cos \left(\frac{\phi_2 + \phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2 + \phi_1}{2}\right)\right) \cdot \cos \left(\frac{\phi_2 + \phi_1}{2}\right)\right) \cdot \left(\left(\cos \left(\frac{\phi_2 + \phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2 + \phi_1}{2}\right)\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)} \cdot R\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(\phi_2 - \phi_1\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019135 
(FPCore (R lambda1 lambda2 phi1 phi2)
  :name "Equirectangular approximation to distance on a great circle"
  (* R (sqrt (+ (* (* (- lambda1 lambda2) (cos (/ (+ phi1 phi2) 2))) (* (- lambda1 lambda2) (cos (/ (+ phi1 phi2) 2)))) (* (- phi1 phi2) (- phi1 phi2))))))