Average Error: 24.4 → 24.1
Time: 45.3s
Precision: 64
Internal Precision: 1344
\[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)\]
\[\tan^{-1}_* \frac{\sqrt{(\left(\log_* (1 + (e^{\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)} - 1)^*)\right) \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) + \left(\sin \left(\frac{\phi_1 - \phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1 - \phi_2}{2}\right)\right))_*}}{\sqrt{(\left(-\left(\cos \left(\frac{\lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1}{2}\right) - \cos \left(\frac{\lambda_1}{2}\right) \cdot \sin \left(\frac{\lambda_2}{2}\right)\right)\right) \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\cos \left(\frac{\lambda_2}{2}\right) \cdot \sin \left(\frac{\lambda_1}{2}\right) - \cos \left(\frac{\lambda_1}{2}\right) \cdot \sin \left(\frac{\lambda_2}{2}\right)\right)\right) + \left(\cos \left(\frac{\phi_1 - \phi_2}{2}\right) \cdot \log \left(e^{\cos \left(\frac{\phi_1 - \phi_2}{2}\right)}\right)\right))_*}} \cdot \left(R \cdot 2\right)\]

Error

Bits error versus R

Bits error versus lambda1

Bits error versus lambda2

Bits error versus phi1

Bits error versus phi2

Derivation

  1. Initial program 24.4

    \[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. Initial simplification24.4

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

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

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

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

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

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

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

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

Runtime

Time bar (total: 45.3s)Debug logProfile

herbie shell --seed 2018250 +o rules:numerics
(FPCore (R lambda1 lambda2 phi1 phi2)
  :name "Distance on a great circle"
  (* R (* 2 (atan2 (sqrt (+ (pow (sin (/ (- phi1 phi2) 2)) 2) (* (* (* (cos phi1) (cos phi2)) (sin (/ (- lambda1 lambda2) 2))) (sin (/ (- lambda1 lambda2) 2))))) (sqrt (- 1 (+ (pow (sin (/ (- phi1 phi2) 2)) 2) (* (* (* (cos phi1) (cos phi2)) (sin (/ (- lambda1 lambda2) 2))) (sin (/ (- lambda1 lambda2) 2))))))))))