Average Error: 15.3 → 0.3
Time: 6.6s
Precision: 64
\[r \cdot \frac{\sin b}{\cos \left(a + b\right)}\]
\[r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos a, \cos b, -\sin a \cdot \sin b\right)}\]
r \cdot \frac{\sin b}{\cos \left(a + b\right)}
r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos a, \cos b, -\sin a \cdot \sin b\right)}
double f(double r, double a, double b) {
        double r17471 = r;
        double r17472 = b;
        double r17473 = sin(r17472);
        double r17474 = a;
        double r17475 = r17474 + r17472;
        double r17476 = cos(r17475);
        double r17477 = r17473 / r17476;
        double r17478 = r17471 * r17477;
        return r17478;
}

double f(double r, double a, double b) {
        double r17479 = r;
        double r17480 = b;
        double r17481 = sin(r17480);
        double r17482 = a;
        double r17483 = cos(r17482);
        double r17484 = cos(r17480);
        double r17485 = sin(r17482);
        double r17486 = r17485 * r17481;
        double r17487 = -r17486;
        double r17488 = fma(r17483, r17484, r17487);
        double r17489 = r17481 / r17488;
        double r17490 = r17479 * r17489;
        return r17490;
}

Error

Bits error versus r

Bits error versus a

Bits error versus b

Derivation

  1. Initial program 15.3

    \[r \cdot \frac{\sin b}{\cos \left(a + b\right)}\]
  2. Using strategy rm
  3. Applied cos-sum0.3

    \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos a \cdot \cos b - \sin a \cdot \sin b}}\]
  4. Using strategy rm
  5. Applied fma-neg0.3

    \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\mathsf{fma}\left(\cos a, \cos b, -\sin a \cdot \sin b\right)}}\]
  6. Final simplification0.3

    \[\leadsto r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos a, \cos b, -\sin a \cdot \sin b\right)}\]

Reproduce

herbie shell --seed 2020056 +o rules:numerics
(FPCore (r a b)
  :name "r*sin(b)/cos(a+b), B"
  :precision binary64
  (* r (/ (sin b) (cos (+ a b)))))