Average Error: 14.6 → 0.3
Time: 20.6s
Precision: binary64
\[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
\[\begin{array}{l} t_0 := \mathsf{log1p}\left(\mathsf{expm1}\left(\sin b \cdot \sin a\right)\right)\\ \frac{r \cdot \sin b}{\mathsf{fma}\left(\cos a, \cos b, -t_0\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 (log1p (expm1 (* (sin b) (sin a))))))
   (/
    (* r (sin b))
    (+ (fma (cos a) (cos b) (- 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 = log1p(expm1((sin(b) * sin(a))));
	return (r * sin(b)) / (fma(cos(a), cos(b), -t_0) + fma(-sin(b), sin(a), t_0));
}
function code(r, a, b)
	return Float64(Float64(r * sin(b)) / cos(Float64(a + b)))
end
function code(r, a, b)
	t_0 = log1p(expm1(Float64(sin(b) * sin(a))))
	return Float64(Float64(r * sin(b)) / Float64(fma(cos(a), cos(b), Float64(-t_0)) + fma(Float64(-sin(b)), sin(a), t_0)))
end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[r_, a_, b_] := Block[{t$95$0 = N[Log[1 + N[(Exp[N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]}, N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision] + (-t$95$0)), $MachinePrecision] + N[((-N[Sin[b], $MachinePrecision]) * N[Sin[a], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\frac{r \cdot \sin b}{\cos \left(a + b\right)}
\begin{array}{l}
t_0 := \mathsf{log1p}\left(\mathsf{expm1}\left(\sin b \cdot \sin a\right)\right)\\
\frac{r \cdot \sin b}{\mathsf{fma}\left(\cos a, \cos b, -t_0\right) + \mathsf{fma}\left(-\sin b, \sin a, t_0\right)}
\end{array}

Error

Bits error versus r

Bits error versus a

Bits error versus b

Derivation

  1. Initial program 14.6

    \[\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(\cos a, \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(\cos a, \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. Applied egg-rr0.3

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

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

Reproduce

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