Average Error: 23.9 → 24.1
Time: 36.1s
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)\]
\[\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{\sqrt[3]{\sin \left(\frac{\phi_1 - \phi_2}{2}\right) \cdot \left(\sin \left(\frac{\phi_1 - \phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1 - \phi_2}{2}\right)\right)} \cdot \sin \left(\frac{\phi_1 - \phi_2}{2}\right) + \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \cos \phi_1\right) \cdot \left(\cos \phi_2 \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}{\sqrt{\sqrt[3]{\left(\cos \left(\frac{\phi_1 - \phi_2}{2}\right) \cdot \cos \left(\frac{\phi_1 - \phi_2}{2}\right)\right) \cdot \left(\sqrt[3]{\cos \left(\frac{\phi_1 - \phi_2}{2}\right)} \cdot \left(\sqrt[3]{\cos \left(\frac{\phi_1 - \phi_2}{2}\right)} \cdot \sqrt[3]{\cos \left(\frac{\phi_1 - \phi_2}{2}\right)}\right)\right)} \cdot \cos \left(\frac{\phi_1 - \phi_2}{2}\right) - \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \cos \phi_1\right) \cdot \left(\cos \phi_2 \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\]

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 23.9

    \[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 simplification23.9

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

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

    \[\leadsto \tan^{-1}_* \frac{\sqrt{\left(\cos \phi_2 \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \cos \phi_1\right) + \sin \left(\frac{\phi_1 - \phi_2}{2}\right) \cdot \sqrt[3]{\left(\sin \left(\frac{\phi_1 - \phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1 - \phi_2}{2}\right)\right) \cdot \sin \left(\frac{\phi_1 - \phi_2}{2}\right)}}}{\sqrt{\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 \cos \left(\frac{\phi_1 - \phi_2}{2}\right) - \left(\cos \phi_2 \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \cos \phi_1\right)}} \cdot \left(R \cdot 2\right)\]
  7. Using strategy rm
  8. Applied add-cube-cbrt24.1

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

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

Runtime

Time bar (total: 36.1s)Debug logProfile

herbie shell --seed 2018248 
(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))))))))))