Average Error: 36.9 → 26.3
Time: 6.0m
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 -9.802319407823852 \cdot 10^{+159}:\\ \;\;\;\;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{elif}\;\phi_2 - \phi_1 \le 7.581301718743755 \cdot 10^{+137}:\\ \;\;\;\;R \cdot \sqrt{\left(\cos \left(\frac{1}{2} \cdot \left(\phi_2 + \phi_1\right)\right) \cdot \left(\left(\sqrt[3]{\cos \left(\frac{1}{2} \cdot \left(\phi_2 + \phi_1\right)\right)} \cdot \sqrt[3]{\cos \left(\frac{1}{2} \cdot \left(\phi_2 + \phi_1\right)\right)}\right) \cdot \sqrt[3]{\cos \left(\frac{1}{2} \cdot \left(\phi_2 + \phi_1\right)\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) < -9.802319407823852e+159

    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.8

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

      \[\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 -9.802319407823852e+159 < (- phi2 phi1) < 7.581301718743755e+137

    1. Initial program 22.7

      \[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 22.8

      \[\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 simplify22.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. Using strategy rm
    5. Applied add-cube-cbrt22.8

      \[\leadsto R \cdot \sqrt{\left(\cos \left(\frac{1}{2} \cdot \left(\phi_2 + \phi_1\right)\right) \cdot \color{blue}{\left(\left(\sqrt[3]{\cos \left(\frac{1}{2} \cdot \left(\phi_2 + \phi_1\right)\right)} \cdot \sqrt[3]{\cos \left(\frac{1}{2} \cdot \left(\phi_2 + \phi_1\right)\right)}\right) \cdot \sqrt[3]{\cos \left(\frac{1}{2} \cdot \left(\phi_2 + \phi_1\right)\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 7.581301718743755e+137 < (- phi2 phi1)

    1. Initial program 57.4

      \[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 13.3

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

Runtime

Time bar (total: 6.0m)Debug logProfile

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