Average Error: 15.3 → 0.3
Time: 7.5s
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 r19383 = r;
        double r19384 = b;
        double r19385 = sin(r19384);
        double r19386 = a;
        double r19387 = r19386 + r19384;
        double r19388 = cos(r19387);
        double r19389 = r19385 / r19388;
        double r19390 = r19383 * r19389;
        return r19390;
}

double f(double r, double a, double b) {
        double r19391 = r;
        double r19392 = b;
        double r19393 = sin(r19392);
        double r19394 = a;
        double r19395 = cos(r19394);
        double r19396 = cos(r19392);
        double r19397 = sin(r19394);
        double r19398 = r19397 * r19393;
        double r19399 = -r19398;
        double r19400 = fma(r19395, r19396, r19399);
        double r19401 = r19393 / r19400;
        double r19402 = r19391 * r19401;
        return r19402;
}

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