?

Average Accuracy: 76.6% → 99.5%
Time: 15.5s
Precision: binary64
Cost: 39040

?

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

Error?

Derivation?

  1. Initial program 76.6%

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

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

    [Start]76.6

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

    cos-sum [=>]99.5

    \[ \frac{r \cdot \sin b}{\color{blue}{\cos a \cdot \cos b - \sin a \cdot \sin b}} \]

    fma-neg [=>]99.5

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

    *-commutative [=>]99.5

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

    \[\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)} \]
    Proof

    [Start]99.5

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

    log1p-expm1-u [=>]99.5

    \[ \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. Taylor expanded in r around 0 99.5%

    \[\leadsto \color{blue}{\frac{\sin b \cdot r}{\cos a \cdot \cos b - \sin a \cdot \sin b}} \]
  5. Simplified99.5%

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

    [Start]99.5

    \[ \frac{\sin b \cdot r}{\cos a \cdot \cos b - \sin a \cdot \sin b} \]

    associate-/l* [=>]99.4

    \[ \color{blue}{\frac{\sin b}{\frac{\cos a \cdot \cos b - \sin a \cdot \sin b}{r}}} \]

    associate-/r/ [=>]99.5

    \[ \color{blue}{\frac{\sin b}{\cos a \cdot \cos b - \sin a \cdot \sin b} \cdot r} \]

    *-commutative [<=]99.5

    \[ \frac{\sin b}{\cos a \cdot \cos b - \color{blue}{\sin b \cdot \sin a}} \cdot r \]

    fma-neg [=>]99.5

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

    distribute-rgt-neg-in [=>]99.5

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

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

Alternatives

Alternative 1
Accuracy99.5%
Cost32704
\[r \cdot \frac{\sin b}{\cos a \cdot \cos b - \sin b \cdot \sin a} \]
Alternative 2
Accuracy99.4%
Cost32512
\[\frac{r}{\mathsf{fma}\left(\frac{\cos b}{\sin b}, \cos a, -\sin a\right)} \]
Alternative 3
Accuracy77.6%
Cost19648
\[\frac{\sin b \cdot r}{\cos a \cdot \cos b} \]
Alternative 4
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{\sin b \cdot r}{\cos b}\\ \mathbf{else}:\\ \;\;\;\;r \cdot \frac{b}{\cos a}\\ \end{array} \]
Alternative 5
Accuracy76.4%
Cost13384
\[\begin{array}{l} \mathbf{if}\;b \leq -3.7 \cdot 10^{-6}:\\ \;\;\;\;r \cdot \tan b\\ \mathbf{elif}\;b \leq 2.8 \cdot 10^{-5}:\\ \;\;\;\;r \cdot \frac{b}{\cos a}\\ \mathbf{else}:\\ \;\;\;\;\frac{r}{\frac{\cos b}{\sin b}}\\ \end{array} \]
Alternative 6
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 \frac{b}{\cos a}\\ \mathbf{else}:\\ \;\;\;\;\frac{r}{\frac{\cos b}{\sin b}}\\ \end{array} \]
Alternative 7
Accuracy76.6%
Cost13248
\[\sin b \cdot \frac{r}{\cos \left(b + a\right)} \]
Alternative 8
Accuracy76.6%
Cost13248
\[r \cdot \frac{\sin b}{\cos \left(b + a\right)} \]
Alternative 9
Accuracy76.6%
Cost13248
\[\frac{\sin b \cdot r}{\cos \left(b + a\right)} \]
Alternative 10
Accuracy76.5%
Cost6985
\[\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 \tan b\\ \mathbf{else}:\\ \;\;\;\;r \cdot \frac{b}{\cos a}\\ \end{array} \]
Alternative 11
Accuracy38.3%
Cost6592
\[\sin b \cdot r \]
Alternative 12
Accuracy60.3%
Cost6592
\[r \cdot \tan b \]
Alternative 13
Accuracy34.7%
Cost576
\[\frac{r}{b \cdot -0.3333333333333333 + \frac{1}{b}} \]
Alternative 14
Accuracy33.8%
Cost192
\[b \cdot r \]

Error

Reproduce?

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