Average Error: 15.5 → 0.3
Time: 7.4s
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 r18688 = r;
        double r18689 = b;
        double r18690 = sin(r18689);
        double r18691 = a;
        double r18692 = r18691 + r18689;
        double r18693 = cos(r18692);
        double r18694 = r18690 / r18693;
        double r18695 = r18688 * r18694;
        return r18695;
}

double f(double r, double a, double b) {
        double r18696 = r;
        double r18697 = b;
        double r18698 = sin(r18697);
        double r18699 = a;
        double r18700 = cos(r18699);
        double r18701 = cos(r18697);
        double r18702 = sin(r18699);
        double r18703 = r18702 * r18698;
        double r18704 = -r18703;
        double r18705 = fma(r18700, r18701, r18704);
        double r18706 = r18698 / r18705;
        double r18707 = r18696 * r18706;
        return r18707;
}

Error

Bits error versus r

Bits error versus a

Bits error versus b

Derivation

  1. Initial program 15.5

    \[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 2019354 +o rules:numerics
(FPCore (r a b)
  :name "r*sin(b)/cos(a+b), B"
  :precision binary64
  (* r (/ (sin b) (cos (+ a b)))))