Average Error: 0.2 → 0.2
Time: 16.8s
Precision: 64
\[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B}\]
\[\mathsf{fma}\left(\frac{\cos B}{\sin B} \cdot x, -1, \frac{1}{\sin B}\right)\]
\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B}
\mathsf{fma}\left(\frac{\cos B}{\sin B} \cdot x, -1, \frac{1}{\sin B}\right)
double f(double B, double x) {
        double r53391 = x;
        double r53392 = 1.0;
        double r53393 = B;
        double r53394 = tan(r53393);
        double r53395 = r53392 / r53394;
        double r53396 = r53391 * r53395;
        double r53397 = -r53396;
        double r53398 = sin(r53393);
        double r53399 = r53392 / r53398;
        double r53400 = r53397 + r53399;
        return r53400;
}

double f(double B, double x) {
        double r53401 = B;
        double r53402 = cos(r53401);
        double r53403 = sin(r53401);
        double r53404 = r53402 / r53403;
        double r53405 = x;
        double r53406 = r53404 * r53405;
        double r53407 = 1.0;
        double r53408 = -r53407;
        double r53409 = r53407 / r53403;
        double r53410 = fma(r53406, r53408, r53409);
        return r53410;
}

Error

Bits error versus B

Bits error versus x

Derivation

  1. Initial program 0.2

    \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B}\]
  2. Simplified0.2

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{\tan B}, -1, \frac{1}{\sin B}\right)}\]
  3. Taylor expanded around inf 0.2

    \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{x \cdot \cos B}{\sin B}}, -1, \frac{1}{\sin B}\right)\]
  4. Simplified0.2

    \[\leadsto \mathsf{fma}\left(\color{blue}{\cos B \cdot \frac{x}{\sin B}}, -1, \frac{1}{\sin B}\right)\]
  5. Using strategy rm
  6. Applied clear-num0.2

    \[\leadsto \mathsf{fma}\left(\cos B \cdot \color{blue}{\frac{1}{\frac{\sin B}{x}}}, -1, \frac{1}{\sin B}\right)\]
  7. Using strategy rm
  8. Applied associate-/r/0.2

    \[\leadsto \mathsf{fma}\left(\cos B \cdot \color{blue}{\left(\frac{1}{\sin B} \cdot x\right)}, -1, \frac{1}{\sin B}\right)\]
  9. Applied associate-*r*0.2

    \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\cos B \cdot \frac{1}{\sin B}\right) \cdot x}, -1, \frac{1}{\sin B}\right)\]
  10. Simplified0.2

    \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{\cos B}{\sin B}} \cdot x, -1, \frac{1}{\sin B}\right)\]
  11. Final simplification0.2

    \[\leadsto \mathsf{fma}\left(\frac{\cos B}{\sin B} \cdot x, -1, \frac{1}{\sin B}\right)\]

Reproduce

herbie shell --seed 2019195 +o rules:numerics
(FPCore (B x)
  :name "VandenBroeck and Keller, Equation (24)"
  (+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))