Average Error: 36.5 → 0.1
Time: 23.5s
Precision: 64
Internal Precision: 1344
\[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)}\]
\[R \cdot \sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \left(\cos \left(\frac{1}{2} \cdot \phi_2\right) \cdot \cos \left(\frac{1}{2} \cdot \phi_1\right) - \sin \left(\frac{1}{2} \cdot \phi_1\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_2\right)\right)\right)^2 + \left(\phi_1 - \phi_2\right)^2}^*\]

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 36.5

    \[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. Initial simplification3.6

    \[\leadsto \sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_2 + \phi_1}{2}\right)\right)^2 + \left(\phi_1 - \phi_2\right)^2}^* \cdot R\]
  3. Using strategy rm
  4. Applied add-log-exp3.6

    \[\leadsto \sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{\log \left(e^{\cos \left(\frac{\phi_2 + \phi_1}{2}\right)}\right)}\right)^2 + \left(\phi_1 - \phi_2\right)^2}^* \cdot R\]
  5. Using strategy rm
  6. Applied expm1-log1p-u3.7

    \[\leadsto \sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \log \color{blue}{\left((e^{\log_* (1 + e^{\cos \left(\frac{\phi_2 + \phi_1}{2}\right)})} - 1)^*\right)}\right)^2 + \left(\phi_1 - \phi_2\right)^2}^* \cdot R\]
  7. Taylor expanded around -inf 3.6

    \[\leadsto \sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{\cos \left(\frac{1}{2} \cdot \left(\phi_1 + \phi_2\right)\right)}\right)^2 + \left(\phi_1 - \phi_2\right)^2}^* \cdot R\]
  8. Using strategy rm
  9. Applied distribute-lft-in3.6

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

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

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

Runtime

Time bar (total: 23.5s)Debug logProfile

BaselineHerbieOracleSpan%
Regimes0.10.10.10.10%
herbie shell --seed 2018340 +o rules:numerics
(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))))))