?

Average Accuracy: 76.6% → 99.5%
Time: 16.0s
Precision: binary64
Cost: 51840

?

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

Error?

Derivation?

  1. Initial program 76.6%

    \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
  2. Simplified76.6%

    \[\leadsto \color{blue}{r \cdot \frac{\sin b}{\cos \left(b + a\right)}} \]
    Proof

    [Start]76.6

    \[ r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]

    +-commutative [=>]76.6

    \[ r \cdot \frac{\sin b}{\cos \color{blue}{\left(b + a\right)}} \]
  3. Applied egg-rr99.5%

    \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\mathsf{fma}\left(\cos b, \cos a, -\sin b \cdot \sin a\right)}} \]
  4. Applied egg-rr99.5%

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

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

Alternatives

Alternative 1
Accuracy99.5%
Cost39040
\[r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \sin b \cdot \left(-\sin a\right)\right)} \]
Alternative 2
Accuracy99.5%
Cost32704
\[r \cdot \frac{\sin b}{\cos b \cdot \cos a - \sin b \cdot \sin a} \]
Alternative 3
Accuracy99.4%
Cost32512
\[\frac{r}{\mathsf{fma}\left(\frac{\cos b}{\sin b}, \cos a, -\sin a\right)} \]
Alternative 4
Accuracy77.6%
Cost19648
\[r \cdot \frac{\sin b}{\cos b \cdot \cos a} \]
Alternative 5
Accuracy76.4%
Cost13385
\[\begin{array}{l} \mathbf{if}\;b \leq -5.8 \cdot 10^{-6} \lor \neg \left(b \leq 4.5 \cdot 10^{-6}\right):\\ \;\;\;\;r \cdot \frac{\sin b}{\cos b}\\ \mathbf{else}:\\ \;\;\;\;r \cdot \left(b \cdot \frac{1}{\cos a}\right)\\ \end{array} \]
Alternative 6
Accuracy76.4%
Cost13385
\[\begin{array}{l} \mathbf{if}\;b \leq -4 \cdot 10^{-6} \lor \neg \left(b \leq 6.5 \cdot 10^{-6}\right):\\ \;\;\;\;\frac{r \cdot \sin b}{\cos b}\\ \mathbf{else}:\\ \;\;\;\;r \cdot \left(b \cdot \frac{1}{\cos a}\right)\\ \end{array} \]
Alternative 7
Accuracy76.4%
Cost13384
\[\begin{array}{l} \mathbf{if}\;b \leq -3.7 \cdot 10^{-6}:\\ \;\;\;\;r \cdot \frac{\sin b}{\cos b}\\ \mathbf{elif}\;b \leq 2.8 \cdot 10^{-5}:\\ \;\;\;\;r \cdot \left(b \cdot \frac{1}{\cos a}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{r}{\frac{\cos b}{\sin b}}\\ \end{array} \]
Alternative 8
Accuracy76.4%
Cost13384
\[\begin{array}{l} \mathbf{if}\;b \leq -7.5 \cdot 10^{-6}:\\ \;\;\;\;\frac{\sin b}{\frac{\cos b}{r}}\\ \mathbf{elif}\;b \leq 2.95 \cdot 10^{-5}:\\ \;\;\;\;r \cdot \left(b \cdot \frac{1}{\cos a}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{r}{\frac{\cos b}{\sin b}}\\ \end{array} \]
Alternative 9
Accuracy76.6%
Cost13248
\[r \cdot \frac{\sin b}{\cos \left(b + a\right)} \]
Alternative 10
Accuracy54.4%
Cost13120
\[r \cdot \frac{\sin b}{\cos a} \]
Alternative 11
Accuracy54.5%
Cost7113
\[\begin{array}{l} \mathbf{if}\;b \leq -5.4 \cdot 10^{+17} \lor \neg \left(b \leq 55\right):\\ \;\;\;\;\frac{\sin b}{\frac{1}{r}}\\ \mathbf{else}:\\ \;\;\;\;r \cdot \left(b \cdot \frac{1}{\cos a}\right)\\ \end{array} \]
Alternative 12
Accuracy54.5%
Cost6985
\[\begin{array}{l} \mathbf{if}\;b \leq -5.4 \cdot 10^{+17} \lor \neg \left(b \leq 55\right):\\ \;\;\;\;\frac{\sin b}{\frac{1}{r}}\\ \mathbf{else}:\\ \;\;\;\;r \cdot \frac{b}{\cos a}\\ \end{array} \]
Alternative 13
Accuracy50.0%
Cost6720
\[r \cdot \frac{b}{\cos a} \]
Alternative 14
Accuracy33.8%
Cost192
\[r \cdot b \]

Error

Reproduce?

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