Average Error: 14.9 → 0.3
Time: 11.9s
Precision: binary64
\[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
\[\begin{array}{l} t_0 := \sin b \cdot \sin a\\ \frac{r \cdot \sin b}{\mathsf{fma}\left(1, \cos a \cdot \cos b, -\mathsf{log1p}\left(\mathsf{expm1}\left(t_0\right)\right)\right) + \mathsf{fma}\left(-\sin b, \sin a, t_0\right)} \end{array} \]
\frac{r \cdot \sin b}{\cos \left(a + b\right)}
\begin{array}{l}
t_0 := \sin b \cdot \sin a\\
\frac{r \cdot \sin b}{\mathsf{fma}\left(1, \cos a \cdot \cos b, -\mathsf{log1p}\left(\mathsf{expm1}\left(t_0\right)\right)\right) + \mathsf{fma}\left(-\sin b, \sin a, t_0\right)}
\end{array}
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (cos (+ a b))))
(FPCore (r a b)
 :precision binary64
 (let* ((t_0 (* (sin b) (sin a))))
   (/
    (* r (sin b))
    (+
     (fma 1.0 (* (cos a) (cos b)) (- (log1p (expm1 t_0))))
     (fma (- (sin b)) (sin a) t_0)))))
double code(double r, double a, double b) {
	return (r * sin(b)) / cos((a + b));
}
double code(double r, double a, double b) {
	double t_0 = sin(b) * sin(a);
	return (r * sin(b)) / (fma(1.0, (cos(a) * cos(b)), -log1p(expm1(t_0))) + fma(-sin(b), sin(a), t_0));
}

Error

Bits error versus r

Bits error versus a

Bits error versus b

Derivation

  1. Initial program 14.9

    \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
  2. Applied egg-rr0.3

    \[\leadsto \frac{r \cdot \sin b}{\color{blue}{\mathsf{fma}\left(1, \cos a \cdot \cos b, -\sin b \cdot \left(\sin a \cdot 1\right)\right) + \mathsf{fma}\left(-\sin b, \sin a \cdot 1, \sin b \cdot \left(\sin a \cdot 1\right)\right)}} \]
  3. Applied egg-rr0.3

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

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

Reproduce

herbie shell --seed 2022130 
(FPCore (r a b)
  :name "rsin A"
  :precision binary64
  (/ (* r (sin b)) (cos (+ a b))))