Average Error: 24.2 → 13.8
Time: 45.2s
Precision: 64
\[R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\sin \left(\frac{\phi_1 - \phi_2}{2}\right)\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}}{\sqrt{1 - \left({\left(\sin \left(\frac{\phi_1 - \phi_2}{2}\right)\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right)\]
\[R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\left(\left(\cos \phi_1 \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) + {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \sin \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right)}^{2}}}{\sqrt{\left(1 - {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \sin \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right)}^{2}\right) - \left(\cos \phi_2 \cdot \left(\cos \phi_1 \cdot \log \left(e^{\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}\right)\right)\right) \cdot \sqrt[3]{{\left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}^{3}}}}\right)\]
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\sin \left(\frac{\phi_1 - \phi_2}{2}\right)\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}}{\sqrt{1 - \left({\left(\sin \left(\frac{\phi_1 - \phi_2}{2}\right)\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right)
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\left(\left(\cos \phi_1 \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) + {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \sin \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right)}^{2}}}{\sqrt{\left(1 - {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \sin \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right)}^{2}\right) - \left(\cos \phi_2 \cdot \left(\cos \phi_1 \cdot \log \left(e^{\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}\right)\right)\right) \cdot \sqrt[3]{{\left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}^{3}}}}\right)
double f(double R, double lambda1, double lambda2, double phi1, double phi2) {
        double r70510 = R;
        double r70511 = 2.0;
        double r70512 = phi1;
        double r70513 = phi2;
        double r70514 = r70512 - r70513;
        double r70515 = r70514 / r70511;
        double r70516 = sin(r70515);
        double r70517 = pow(r70516, r70511);
        double r70518 = cos(r70512);
        double r70519 = cos(r70513);
        double r70520 = r70518 * r70519;
        double r70521 = lambda1;
        double r70522 = lambda2;
        double r70523 = r70521 - r70522;
        double r70524 = r70523 / r70511;
        double r70525 = sin(r70524);
        double r70526 = r70520 * r70525;
        double r70527 = r70526 * r70525;
        double r70528 = r70517 + r70527;
        double r70529 = sqrt(r70528);
        double r70530 = 1.0;
        double r70531 = r70530 - r70528;
        double r70532 = sqrt(r70531);
        double r70533 = atan2(r70529, r70532);
        double r70534 = r70511 * r70533;
        double r70535 = r70510 * r70534;
        return r70535;
}

double f(double R, double lambda1, double lambda2, double phi1, double phi2) {
        double r70536 = R;
        double r70537 = 2.0;
        double r70538 = phi1;
        double r70539 = cos(r70538);
        double r70540 = lambda1;
        double r70541 = lambda2;
        double r70542 = r70540 - r70541;
        double r70543 = r70542 / r70537;
        double r70544 = sin(r70543);
        double r70545 = r70539 * r70544;
        double r70546 = phi2;
        double r70547 = cos(r70546);
        double r70548 = r70545 * r70547;
        double r70549 = r70548 * r70544;
        double r70550 = r70538 / r70537;
        double r70551 = sin(r70550);
        double r70552 = r70546 / r70537;
        double r70553 = cos(r70552);
        double r70554 = r70551 * r70553;
        double r70555 = sin(r70552);
        double r70556 = cos(r70550);
        double r70557 = r70555 * r70556;
        double r70558 = r70554 - r70557;
        double r70559 = pow(r70558, r70537);
        double r70560 = r70549 + r70559;
        double r70561 = sqrt(r70560);
        double r70562 = 1.0;
        double r70563 = r70562 - r70559;
        double r70564 = exp(r70544);
        double r70565 = log(r70564);
        double r70566 = r70539 * r70565;
        double r70567 = r70547 * r70566;
        double r70568 = 3.0;
        double r70569 = pow(r70544, r70568);
        double r70570 = cbrt(r70569);
        double r70571 = r70567 * r70570;
        double r70572 = r70563 - r70571;
        double r70573 = sqrt(r70572);
        double r70574 = atan2(r70561, r70573);
        double r70575 = r70537 * r70574;
        double r70576 = r70536 * r70575;
        return r70576;
}

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 24.2

    \[R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\sin \left(\frac{\phi_1 - \phi_2}{2}\right)\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}}{\sqrt{1 - \left({\left(\sin \left(\frac{\phi_1 - \phi_2}{2}\right)\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right)\]
  2. Simplified24.2

    \[\leadsto \color{blue}{R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \left(\cos \phi_2 \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \cos \phi_1\right)\right) + {\left(\sin \left(\frac{\phi_1 - \phi_2}{2}\right)\right)}^{2}}}{\sqrt{\left(1 - {\left(\sin \left(\frac{\phi_1 - \phi_2}{2}\right)\right)}^{2}\right) - \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \left(\cos \phi_2 \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \cos \phi_1\right)\right)}}\right)}\]
  3. Using strategy rm
  4. Applied div-sub24.2

    \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \left(\cos \phi_2 \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \cos \phi_1\right)\right) + {\left(\sin \color{blue}{\left(\frac{\phi_1}{2} - \frac{\phi_2}{2}\right)}\right)}^{2}}}{\sqrt{\left(1 - {\left(\sin \left(\frac{\phi_1 - \phi_2}{2}\right)\right)}^{2}\right) - \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \left(\cos \phi_2 \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \cos \phi_1\right)\right)}}\right)\]
  5. Applied sin-diff23.6

    \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \left(\cos \phi_2 \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \cos \phi_1\right)\right) + {\color{blue}{\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}}^{2}}}{\sqrt{\left(1 - {\left(\sin \left(\frac{\phi_1 - \phi_2}{2}\right)\right)}^{2}\right) - \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \left(\cos \phi_2 \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \cos \phi_1\right)\right)}}\right)\]
  6. Simplified23.6

    \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \left(\cos \phi_2 \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \cos \phi_1\right)\right) + {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \color{blue}{\sin \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)}\right)}^{2}}}{\sqrt{\left(1 - {\left(\sin \left(\frac{\phi_1 - \phi_2}{2}\right)\right)}^{2}\right) - \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \left(\cos \phi_2 \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \cos \phi_1\right)\right)}}\right)\]
  7. Using strategy rm
  8. Applied div-sub23.6

    \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \left(\cos \phi_2 \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \cos \phi_1\right)\right) + {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \sin \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right)}^{2}}}{\sqrt{\left(1 - {\left(\sin \color{blue}{\left(\frac{\phi_1}{2} - \frac{\phi_2}{2}\right)}\right)}^{2}\right) - \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \left(\cos \phi_2 \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \cos \phi_1\right)\right)}}\right)\]
  9. Applied sin-diff13.8

    \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \left(\cos \phi_2 \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \cos \phi_1\right)\right) + {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \sin \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right)}^{2}}}{\sqrt{\left(1 - {\color{blue}{\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}}^{2}\right) - \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \left(\cos \phi_2 \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \cos \phi_1\right)\right)}}\right)\]
  10. Simplified13.8

    \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \left(\cos \phi_2 \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \cos \phi_1\right)\right) + {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \sin \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right)}^{2}}}{\sqrt{\left(1 - {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \color{blue}{\sin \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)}\right)}^{2}\right) - \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \left(\cos \phi_2 \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \cos \phi_1\right)\right)}}\right)\]
  11. Using strategy rm
  12. Applied add-log-exp13.8

    \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \left(\cos \phi_2 \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \cos \phi_1\right)\right) + {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \sin \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right)}^{2}}}{\sqrt{\left(1 - {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \sin \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right)}^{2}\right) - \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \left(\cos \phi_2 \cdot \left(\color{blue}{\log \left(e^{\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}\right)} \cdot \cos \phi_1\right)\right)}}\right)\]
  13. Using strategy rm
  14. Applied add-cbrt-cube13.8

    \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \left(\cos \phi_2 \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \cos \phi_1\right)\right) + {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \sin \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right)}^{2}}}{\sqrt{\left(1 - {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \sin \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right)}^{2}\right) - \color{blue}{\sqrt[3]{\left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}} \cdot \left(\cos \phi_2 \cdot \left(\log \left(e^{\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}\right) \cdot \cos \phi_1\right)\right)}}\right)\]
  15. Simplified13.8

    \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \left(\cos \phi_2 \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \cos \phi_1\right)\right) + {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \sin \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right)}^{2}}}{\sqrt{\left(1 - {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \sin \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right)}^{2}\right) - \sqrt[3]{\color{blue}{{\left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}^{3}}} \cdot \left(\cos \phi_2 \cdot \left(\log \left(e^{\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}\right) \cdot \cos \phi_1\right)\right)}}\right)\]
  16. Final simplification13.8

    \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\left(\left(\cos \phi_1 \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) + {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \sin \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right)}^{2}}}{\sqrt{\left(1 - {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \sin \left(\frac{\phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1}{2}\right)\right)}^{2}\right) - \left(\cos \phi_2 \cdot \left(\cos \phi_1 \cdot \log \left(e^{\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}\right)\right)\right) \cdot \sqrt[3]{{\left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}^{3}}}}\right)\]

Reproduce

herbie shell --seed 2019196 
(FPCore (R lambda1 lambda2 phi1 phi2)
  :name "Distance on a great circle"
  (* R (* 2.0 (atan2 (sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* (* (* (cos phi1) (cos phi2)) (sin (/ (- lambda1 lambda2) 2.0))) (sin (/ (- lambda1 lambda2) 2.0))))) (sqrt (- 1.0 (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* (* (* (cos phi1) (cos phi2)) (sin (/ (- lambda1 lambda2) 2.0))) (sin (/ (- lambda1 lambda2) 2.0))))))))))