Average Error: 37.6 → 26.3
Time: 7.5m
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)}\]
\[\begin{array}{l} \mathbf{if}\;\phi_2 - \phi_1 \le -1.4030670556456484 \cdot 10^{+173}:\\ \;\;\;\;R \cdot \left(\frac{{\left(\cos \left(\frac{1}{2} \cdot \left(\phi_1 + \phi_2\right)\right)\right)}^{2} \cdot \left(\lambda_1 \cdot \left(\phi_1 \cdot \lambda_2\right)\right)}{{\phi_2}^{2}} + \left(\phi_1 + \frac{{\left(\cos \left(\frac{1}{2} \cdot \left(\phi_1 + \phi_2\right)\right)\right)}^{2} \cdot \left(\lambda_1 \cdot \lambda_2\right)}{\phi_2}\right)\right)\\ \mathbf{if}\;\phi_2 - \phi_1 \le 1.4329139041545177 \cdot 10^{+133}:\\ \;\;\;\;R \cdot \sqrt{\left(\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_2\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_1\right)\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_2\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_1\right)\right)\right) \cdot \left(\lambda_2 \cdot \lambda_2 + \lambda_1 \cdot \left(\lambda_1 - \lambda_2 \cdot 2\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)}\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(\phi_2 - \phi_1\right)\\ \end{array}\]

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. Split input into 3 regimes
  2. if (- phi2 phi1) < -1.4030670556456484e+173

    1. Initial program 60.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. Taylor expanded around inf 60.9

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

      \[\leadsto \color{blue}{R \cdot \sqrt{\left(\cos \left(\frac{1}{2} \cdot \left(\phi_2 + \phi_1\right)\right) \cdot \cos \left(\frac{1}{2} \cdot \left(\phi_2 + \phi_1\right)\right)\right) \cdot \left(\lambda_2 \cdot \lambda_2 + \lambda_1 \cdot \left(\lambda_1 - \lambda_2 \cdot 2\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)}}\]
    4. Taylor expanded around -inf 52.6

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

    if -1.4030670556456484e+173 < (- phi2 phi1) < 1.4329139041545177e+133

    1. Initial program 24.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. Taylor expanded around inf 24.6

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

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

      \[\leadsto R \cdot \sqrt{\left(\cos \left(\frac{1}{2} \cdot \left(\phi_2 + \phi_1\right)\right) \cdot \cos \color{blue}{\left(\frac{1}{2} \cdot \phi_2 + \frac{1}{2} \cdot \phi_1\right)}\right) \cdot \left(\lambda_2 \cdot \lambda_2 + \lambda_1 \cdot \left(\lambda_1 - \lambda_2 \cdot 2\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)}\]
    6. Applied cos-sum24.7

      \[\leadsto R \cdot \sqrt{\left(\cos \left(\frac{1}{2} \cdot \left(\phi_2 + \phi_1\right)\right) \cdot \color{blue}{\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_2\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_1\right)\right)}\right) \cdot \left(\lambda_2 \cdot \lambda_2 + \lambda_1 \cdot \left(\lambda_1 - \lambda_2 \cdot 2\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)}\]
    7. Using strategy rm
    8. Applied distribute-lft-in24.7

      \[\leadsto R \cdot \sqrt{\left(\cos \color{blue}{\left(\frac{1}{2} \cdot \phi_2 + \frac{1}{2} \cdot \phi_1\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_2\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_1\right)\right)\right) \cdot \left(\lambda_2 \cdot \lambda_2 + \lambda_1 \cdot \left(\lambda_1 - \lambda_2 \cdot 2\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)}\]
    9. Applied cos-sum23.7

      \[\leadsto R \cdot \sqrt{\left(\color{blue}{\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_2\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_1\right)\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_2\right) \cdot \sin \left(\frac{1}{2} \cdot \phi_1\right)\right)\right) \cdot \left(\lambda_2 \cdot \lambda_2 + \lambda_1 \cdot \left(\lambda_1 - \lambda_2 \cdot 2\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)}\]

    if 1.4329139041545177e+133 < (- phi2 phi1)

    1. Initial program 56.9

      \[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. Taylor expanded around 0 14.3

      \[\leadsto R \cdot \color{blue}{\left(\phi_2 - \phi_1\right)}\]
  3. Recombined 3 regimes into one program.

Runtime

Time bar (total: 7.5m)Debug logProfile

herbie shell --seed '#(1072936661 1621281212 3440817831 3219514234 460296804 1258167384)' 
(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))))))