Average Error: 36.8 → 3.9
Time: 49.3s
Precision: 64
Internal Precision: 1408
\[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)}\]
\[\sqrt{\left((e^{\log \left(1 + \log \left(e^{\cos \left(\frac{\phi_1 + \phi_2}{2}\right)}\right)\right)} - 1)^* \cdot \left(\lambda_1 - \lambda_2\right)\right)^2 + \left(\phi_1 - \phi_2\right)^2}^* \cdot R\]

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 36.8

    \[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. Applied simplify3.8

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

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

    \[\leadsto \sqrt{\left((e^{\color{blue}{\log \left(1 + \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right)}} - 1)^* \cdot \left(\lambda_1 - \lambda_2\right)\right)^2 + \left(\phi_1 - \phi_2\right)^2}^* \cdot R\]
  7. Using strategy rm
  8. Applied add-log-exp3.9

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

Runtime

Time bar (total: 49.3s)Debug logProfile

herbie shell --seed '#(1070833653 108281690 3330367898 3632331308 3494323072 43156186)' +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))))))