?

Average Error: 14.5 → 0.3
Time: 14.5s
Precision: binary64
Cost: 51840

?

\[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
\[\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)} \]
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (cos (+ a b))))
(FPCore (r a b)
 :precision binary64
 (/
  (* r (sin b))
  (fma (cos a) (cos b) (- (log1p (expm1 (* (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) {
	return (r * sin(b)) / fma(cos(a), cos(b), -log1p(expm1((sin(b) * sin(a)))));
}
function code(r, a, b)
	return Float64(Float64(r * sin(b)) / cos(Float64(a + b)))
end
function code(r, a, b)
	return Float64(Float64(r * sin(b)) / fma(cos(a), cos(b), Float64(-log1p(expm1(Float64(sin(b) * sin(a)))))))
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_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision] + (-N[Log[1 + N[(Exp[N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]
\frac{r \cdot \sin b}{\cos \left(a + b\right)}
\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)}

Error?

Derivation?

  1. Initial program 14.5

    \[\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 \sin a\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)} \]
  4. 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)} \]

Alternatives

Alternative 1
Error0.3
Cost39040
\[\frac{r \cdot \sin b}{\mathsf{fma}\left(\cos a, \cos b, \sin b \cdot \left(-\sin a\right)\right)} \]
Alternative 2
Error0.3
Cost32704
\[r \cdot \frac{\sin b}{\cos a \cdot \cos b - \sin b \cdot \sin a} \]
Alternative 3
Error0.3
Cost32704
\[\frac{r \cdot \sin b}{\cos a \cdot \cos b - \sin b \cdot \sin a} \]
Alternative 4
Error0.4
Cost32512
\[\frac{r}{\mathsf{fma}\left(\frac{\cos b}{\sin b}, \cos a, -\sin a\right)} \]
Alternative 5
Error13.9
Cost19648
\[\frac{r \cdot \sin b}{\cos a \cdot \cos b} \]
Alternative 6
Error14.7
Cost13384
\[\begin{array}{l} \mathbf{if}\;b \leq -1.55 \cdot 10^{-5}:\\ \;\;\;\;r \cdot \tan b\\ \mathbf{elif}\;b \leq 0.018:\\ \;\;\;\;r \cdot \frac{b}{\cos a}\\ \mathbf{else}:\\ \;\;\;\;\sin b \cdot \frac{r}{\cos b}\\ \end{array} \]
Alternative 7
Error14.5
Cost13248
\[r \cdot \frac{\sin b}{\cos \left(b + a\right)} \]
Alternative 8
Error14.6
Cost6985
\[\begin{array}{l} \mathbf{if}\;b \leq -1.12 \cdot 10^{-5} \lor \neg \left(b \leq 0.018\right):\\ \;\;\;\;r \cdot \tan b\\ \mathbf{else}:\\ \;\;\;\;r \cdot \frac{b}{\cos a}\\ \end{array} \]
Alternative 9
Error39.3
Cost6592
\[r \cdot \sin b \]
Alternative 10
Error25.1
Cost6592
\[r \cdot \tan b \]
Alternative 11
Error41.6
Cost576
\[\frac{r}{b \cdot -0.3333333333333333 + \frac{1}{b}} \]
Alternative 12
Error42.1
Cost192
\[r \cdot b \]

Error

Reproduce?

herbie shell --seed 2023066 
(FPCore (r a b)
  :name "rsin A (should all be same)"
  :precision binary64
  (/ (* r (sin b)) (cos (+ a b))))