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

Error

Derivation

  1. Initial program 14.8

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

    \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\mathsf{fma}\left(\cos b, \cos a, -\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. Taylor expanded in b around inf 0.3

    \[\leadsto r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, -\sin b \cdot \left(\sin a \cdot 1\right)\right) + \mathsf{fma}\left(-\sin b, \sin a \cdot 1, \color{blue}{\sin a \cdot \sin b}\right)} \]
  4. Taylor expanded in b around inf 0.3

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

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

Alternatives

Alternative 1
Error0.3
Cost39040
\[r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \sin a \cdot \left(-\sin b\right)\right)} \]
Alternative 2
Error0.3
Cost32704
\[\frac{r \cdot \sin b}{\cos b \cdot \cos a - \sin b \cdot \sin a} \]
Alternative 3
Error0.4
Cost32704
\[\sin b \cdot \frac{r}{\cos b \cdot \cos a - \sin b \cdot \sin a} \]
Alternative 4
Error15.7
Cost13512
\[\begin{array}{l} t_0 := \sin b \cdot \left(r \cdot \frac{1}{\cos a}\right)\\ \mathbf{if}\;a \leq -142667178061.19138:\\ \;\;\;\;t_0\\ \mathbf{elif}\;a \leq 4.337008163156099 \cdot 10^{-31}:\\ \;\;\;\;r \cdot \tan b\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error14.8
Cost13512
\[\begin{array}{l} t_0 := \frac{r}{\frac{\cos a}{b} - \sin a}\\ \mathbf{if}\;a \leq -142667178061.19138:\\ \;\;\;\;t_0\\ \mathbf{elif}\;a \leq 4.337008163156099 \cdot 10^{-31}:\\ \;\;\;\;r \cdot \tan b\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error15.6
Cost13384
\[\begin{array}{l} t_0 := r \cdot \frac{\sin b}{\cos a}\\ \mathbf{if}\;a \leq -142667178061.19138:\\ \;\;\;\;t_0\\ \mathbf{elif}\;a \leq 4.337008163156099 \cdot 10^{-31}:\\ \;\;\;\;r \cdot \tan b\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error15.6
Cost13384
\[\begin{array}{l} \mathbf{if}\;a \leq -142667178061.19138:\\ \;\;\;\;\frac{\sin b}{\frac{\cos a}{r}}\\ \mathbf{elif}\;a \leq 4.337008163156099 \cdot 10^{-31}:\\ \;\;\;\;r \cdot \tan b\\ \mathbf{else}:\\ \;\;\;\;r \cdot \frac{\sin b}{\cos a}\\ \end{array} \]
Alternative 8
Error15.7
Cost13384
\[\begin{array}{l} \mathbf{if}\;a \leq -142667178061.19138:\\ \;\;\;\;\sin b \cdot \frac{r}{\cos a}\\ \mathbf{elif}\;a \leq 4.337008163156099 \cdot 10^{-31}:\\ \;\;\;\;r \cdot \tan b\\ \mathbf{else}:\\ \;\;\;\;r \cdot \frac{\sin b}{\cos a}\\ \end{array} \]
Alternative 9
Error15.7
Cost13384
\[\begin{array}{l} \mathbf{if}\;a \leq -142667178061.19138:\\ \;\;\;\;\sin b \cdot \frac{r}{\cos a}\\ \mathbf{elif}\;a \leq 4.337008163156099 \cdot 10^{-31}:\\ \;\;\;\;r \cdot \tan b\\ \mathbf{else}:\\ \;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\ \end{array} \]
Alternative 10
Error14.8
Cost13248
\[\frac{\sin b}{\frac{\cos \left(b + a\right)}{r}} \]
Alternative 11
Error14.8
Cost13248
\[\sin b \cdot \frac{r}{\cos \left(b + a\right)} \]
Alternative 12
Error15.0
Cost6984
\[\begin{array}{l} t_0 := r \cdot \tan b\\ \mathbf{if}\;b \leq -122.22465916837005:\\ \;\;\;\;t_0\\ \mathbf{elif}\;b \leq 0.00370631197242191:\\ \;\;\;\;b \cdot \frac{r}{\cos a}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 13
Error39.0
Cost6592
\[r \cdot \sin b \]
Alternative 14
Error25.5
Cost6592
\[r \cdot \tan b \]
Alternative 15
Error41.3
Cost576
\[\frac{r}{b \cdot -0.3333333333333333 + \frac{1}{b}} \]
Alternative 16
Error41.9
Cost192
\[r \cdot b \]

Error

Reproduce

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