Average Error: 15.2 → 0.3
Time: 21.3s
Precision: 64
\[r \cdot \frac{\sin b}{\cos \left(a + b\right)}\]
\[r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos a, \cos b, \left(-\sin b\right) \cdot \sin a\right)}\]
r \cdot \frac{\sin b}{\cos \left(a + b\right)}
r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos a, \cos b, \left(-\sin b\right) \cdot \sin a\right)}
double f(double r, double a, double b) {
        double r924585 = r;
        double r924586 = b;
        double r924587 = sin(r924586);
        double r924588 = a;
        double r924589 = r924588 + r924586;
        double r924590 = cos(r924589);
        double r924591 = r924587 / r924590;
        double r924592 = r924585 * r924591;
        return r924592;
}

double f(double r, double a, double b) {
        double r924593 = r;
        double r924594 = b;
        double r924595 = sin(r924594);
        double r924596 = a;
        double r924597 = cos(r924596);
        double r924598 = cos(r924594);
        double r924599 = -r924595;
        double r924600 = sin(r924596);
        double r924601 = r924599 * r924600;
        double r924602 = fma(r924597, r924598, r924601);
        double r924603 = r924595 / r924602;
        double r924604 = r924593 * r924603;
        return r924604;
}

Error

Bits error versus r

Bits error versus a

Bits error versus b

Derivation

  1. Initial program 15.2

    \[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, \left(-\sin b\right) \cdot \sin a\right)}\]

Reproduce

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