Average Error: 39.2 → 0.2
Time: 6.7s
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)}\]
\[\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \sqrt[3]{{\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)}^{3}}, \phi_1 - \phi_2\right) \cdot R\]
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)}
\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \sqrt[3]{{\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)}^{3}}, \phi_1 - \phi_2\right) \cdot R
double f(double R, double lambda1, double lambda2, double phi1, double phi2) {
        double r87620 = R;
        double r87621 = lambda1;
        double r87622 = lambda2;
        double r87623 = r87621 - r87622;
        double r87624 = phi1;
        double r87625 = phi2;
        double r87626 = r87624 + r87625;
        double r87627 = 2.0;
        double r87628 = r87626 / r87627;
        double r87629 = cos(r87628);
        double r87630 = r87623 * r87629;
        double r87631 = r87630 * r87630;
        double r87632 = r87624 - r87625;
        double r87633 = r87632 * r87632;
        double r87634 = r87631 + r87633;
        double r87635 = sqrt(r87634);
        double r87636 = r87620 * r87635;
        return r87636;
}

double f(double R, double lambda1, double lambda2, double phi1, double phi2) {
        double r87637 = lambda1;
        double r87638 = lambda2;
        double r87639 = r87637 - r87638;
        double r87640 = phi2;
        double r87641 = 0.5;
        double r87642 = r87640 * r87641;
        double r87643 = cos(r87642);
        double r87644 = phi1;
        double r87645 = r87644 * r87641;
        double r87646 = cos(r87645);
        double r87647 = r87643 * r87646;
        double r87648 = sin(r87642);
        double r87649 = sin(r87645);
        double r87650 = r87648 * r87649;
        double r87651 = r87647 - r87650;
        double r87652 = 3.0;
        double r87653 = pow(r87651, r87652);
        double r87654 = cbrt(r87653);
        double r87655 = r87639 * r87654;
        double r87656 = r87644 - r87640;
        double r87657 = hypot(r87655, r87656);
        double r87658 = R;
        double r87659 = r87657 * r87658;
        return r87659;
}

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. Initial program 39.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. Simplified3.7

    \[\leadsto \color{blue}{\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right) \cdot R}\]
  3. Using strategy rm
  4. Applied pow13.7

    \[\leadsto \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right) \cdot \color{blue}{{R}^{1}}\]
  5. Applied pow13.7

    \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)\right)}^{1}} \cdot {R}^{1}\]
  6. Applied pow-prod-down3.7

    \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right) \cdot R\right)}^{1}}\]
  7. Using strategy rm
  8. Applied add-cbrt-cube3.7

    \[\leadsto {\left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_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)}}, \phi_1 - \phi_2\right) \cdot R\right)}^{1}\]
  9. Simplified3.7

    \[\leadsto {\left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \sqrt[3]{\color{blue}{{\left(\cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right)}^{3}}}, \phi_1 - \phi_2\right) \cdot R\right)}^{1}\]
  10. Taylor expanded around inf 3.7

    \[\leadsto {\left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \sqrt[3]{{\color{blue}{\left(\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)\right)}}^{3}}, \phi_1 - \phi_2\right) \cdot R\right)}^{1}\]
  11. Using strategy rm
  12. Applied distribute-lft-in3.7

    \[\leadsto {\left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \sqrt[3]{{\left(\cos \color{blue}{\left(0.5 \cdot \phi_2 + 0.5 \cdot \phi_1\right)}\right)}^{3}}, \phi_1 - \phi_2\right) \cdot R\right)}^{1}\]
  13. Applied cos-sum0.2

    \[\leadsto {\left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \sqrt[3]{{\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)}}^{3}}, \phi_1 - \phi_2\right) \cdot R\right)}^{1}\]
  14. Simplified0.2

    \[\leadsto {\left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \sqrt[3]{{\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)}^{3}}, \phi_1 - \phi_2\right) \cdot R\right)}^{1}\]
  15. Simplified0.2

    \[\leadsto {\left(\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \sqrt[3]{{\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)}^{3}}, \phi_1 - \phi_2\right) \cdot R\right)}^{1}\]
  16. Final simplification0.2

    \[\leadsto \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \sqrt[3]{{\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)}^{3}}, \phi_1 - \phi_2\right) \cdot R\]

Reproduce

herbie shell --seed 2020018 +o rules:numerics
(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))))))