Average Error: 37.5 → 30.9
Time: 27.6s
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)}^2 + {\left(\phi_1 - \phi_2\right)}^2}\]
\[\begin{array}{l} \mathbf{if}\;\phi_1 \le -1.6627596580110054 \cdot 10^{+149}:\\ \;\;\;\;R \cdot \left(\phi_2 - \phi_1\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \sqrt{{\left(\lambda_1 - \lambda_2\right)}^2 \cdot {\left(\cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right)}^2 + {\left(\phi_1 - \phi_2\right)}^2}\\ \end{array}\]

Error

Bits error versus R

Bits error versus lambda1

Bits error versus lambda2

Bits error versus phi1

Bits error versus phi2

Derivation

  1. Split input into 2 regimes.
  2. if phi1 < -1.6627596580110054e+149

    1. Initial program 59.9

      \[R \cdot \sqrt{{\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right)}^2 + {\left(\phi_1 - \phi_2\right)}^2}\]
    2. Applied taylor 0.0

      \[\leadsto R \cdot \left(\phi_2 - \phi_1\right)\]
    3. Taylor expanded around 0 0.0

      \[\leadsto R \cdot \color{blue}{\left(\phi_2 - \phi_1\right)}\]

    if -1.6627596580110054e+149 < phi1

    1. Initial program 34.7

      \[R \cdot \sqrt{{\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right)}^2 + {\left(\phi_1 - \phi_2\right)}^2}\]
    2. Using strategy rm
    3. Applied square-prod 34.8

      \[\leadsto R \cdot \sqrt{\color{blue}{{\left(\lambda_1 - \lambda_2\right)}^2 \cdot {\left(\cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right)}^2} + {\left(\phi_1 - \phi_2\right)}^2}\]
  3. Recombined 2 regimes into one program.
  4. Removed slow pow expressions

Runtime

Time bar (total: 27.6s) Debug logProfile

Please include this information when filing a bug report:

herbie shell --seed '#(1064524629 4159152179 2999149171 575749698 4006532819 692958815)'
(FPCore (R lambda1 lambda2 phi1 phi2)
  :name "Equirectangular approximation to distance on a great circle"
  (* R (sqrt (+ (sqr (* (- lambda1 lambda2) (cos (/ (+ phi1 phi2) 2)))) (sqr (- phi1 phi2))))))