Average Error: 37.0 → 3.7
Time: 31.5s
Precision: 64
\[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)}\]
\[\mathsf{hypot}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \mathsf{log1p}\left(\left(\mathsf{log1p}\left(\left(\mathsf{expm1}\left(\left(\mathsf{expm1}\left(\left(\cos \left(\frac{\phi_2 + \phi_1}{2}\right)\right)\right)\right)\right)\right)\right)\right)\right)\right), \left(\phi_1 - \phi_2\right)\right) \cdot R\]
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)}
\mathsf{hypot}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \mathsf{log1p}\left(\left(\mathsf{log1p}\left(\left(\mathsf{expm1}\left(\left(\mathsf{expm1}\left(\left(\cos \left(\frac{\phi_2 + \phi_1}{2}\right)\right)\right)\right)\right)\right)\right)\right)\right)\right), \left(\phi_1 - \phi_2\right)\right) \cdot R
double f(double R, double lambda1, double lambda2, double phi1, double phi2) {
        double r2133295 = R;
        double r2133296 = lambda1;
        double r2133297 = lambda2;
        double r2133298 = r2133296 - r2133297;
        double r2133299 = phi1;
        double r2133300 = phi2;
        double r2133301 = r2133299 + r2133300;
        double r2133302 = 2.0;
        double r2133303 = r2133301 / r2133302;
        double r2133304 = cos(r2133303);
        double r2133305 = r2133298 * r2133304;
        double r2133306 = r2133305 * r2133305;
        double r2133307 = r2133299 - r2133300;
        double r2133308 = r2133307 * r2133307;
        double r2133309 = r2133306 + r2133308;
        double r2133310 = sqrt(r2133309);
        double r2133311 = r2133295 * r2133310;
        return r2133311;
}

double f(double R, double lambda1, double lambda2, double phi1, double phi2) {
        double r2133312 = lambda1;
        double r2133313 = lambda2;
        double r2133314 = r2133312 - r2133313;
        double r2133315 = phi2;
        double r2133316 = phi1;
        double r2133317 = r2133315 + r2133316;
        double r2133318 = 2.0;
        double r2133319 = r2133317 / r2133318;
        double r2133320 = cos(r2133319);
        double r2133321 = expm1(r2133320);
        double r2133322 = expm1(r2133321);
        double r2133323 = log1p(r2133322);
        double r2133324 = log1p(r2133323);
        double r2133325 = r2133314 * r2133324;
        double r2133326 = r2133316 - r2133315;
        double r2133327 = hypot(r2133325, r2133326);
        double r2133328 = R;
        double r2133329 = r2133327 * r2133328;
        return r2133329;
}

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 37.0

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

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

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

    \[\leadsto \mathsf{hypot}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \mathsf{log1p}\left(\color{blue}{\left(\mathsf{log1p}\left(\left(\mathsf{expm1}\left(\left(\mathsf{expm1}\left(\left(\cos \left(\frac{\phi_2 + \phi_1}{2}\right)\right)\right)\right)\right)\right)\right)\right)}\right)\right), \left(\phi_1 - \phi_2\right)\right) \cdot R\]
  7. Final simplification3.7

    \[\leadsto \mathsf{hypot}\left(\left(\left(\lambda_1 - \lambda_2\right) \cdot \mathsf{log1p}\left(\left(\mathsf{log1p}\left(\left(\mathsf{expm1}\left(\left(\mathsf{expm1}\left(\left(\cos \left(\frac{\phi_2 + \phi_1}{2}\right)\right)\right)\right)\right)\right)\right)\right)\right)\right), \left(\phi_1 - \phi_2\right)\right) \cdot R\]

Reproduce

herbie shell --seed 2019130 +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))))))