?

Average Accuracy: 76.8% → 99.5%
Time: 20.6s
Precision: binary64
Cost: 39040

?

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

Error?

Derivation?

  1. Initial program 76.8%

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

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

    [Start]76.8

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

    +-commutative [=>]76.8

    \[ 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}{\cos b \cdot \cos a - \sin b \cdot \sin a}} \]
    Proof

    [Start]76.8

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

    cos-sum [=>]99.5

    \[ r \cdot \frac{\sin b}{\color{blue}{\cos b \cdot \cos a - \sin b \cdot \sin a}} \]
  4. Applied egg-rr99.5%

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

    [Start]99.5

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

    prod-diff [=>]99.5

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

    *-commutative [<=]99.5

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

    fma-neg [<=]99.5

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

    cancel-sign-sub-inv [=>]99.5

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

    associate-+l+ [=>]99.5

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

    distribute-lft-neg-in [<=]99.5

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

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

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

    *-commutative [<=]99.5

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

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

    [Start]99.5

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

    associate-+r+ [=>]99.5

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

    +-commutative [<=]99.5

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

    fma-udef [=>]99.5

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

    *-commutative [<=]99.5

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

    associate-+r+ [=>]99.4

    \[ r \cdot \frac{\sin b}{\color{blue}{\left(\left(\sin b \cdot \left(-\sin a\right) + \cos b \cdot \cos a\right) + \sin b \cdot \left(-\sin a\right)\right) + \sin b \cdot \sin a}} \]
  6. Taylor expanded in a around inf 99.5%

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

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

    [Start]99.5

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

    +-commutative [=>]99.5

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

    mul-1-neg [=>]99.5

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

    sub-neg [<=]99.5

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

    +-inverses [=>]99.5

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

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

    [Start]99.5

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

    fma-udef [=>]99.5

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

    +-rgt-identity [=>]99.5

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

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

Alternatives

Alternative 1
Accuracy99.5%
Cost32704
\[r \cdot \frac{\sin b}{\cos b \cdot \cos a - \sin b \cdot \sin a} \]
Alternative 2
Accuracy75.6%
Cost13384
\[\begin{array}{l} \mathbf{if}\;a \leq -5.6 \cdot 10^{+15}:\\ \;\;\;\;\sin b \cdot \frac{r}{\cos a}\\ \mathbf{elif}\;a \leq 8.2 \cdot 10^{+15}:\\ \;\;\;\;\sin b \cdot \frac{r}{\cos b}\\ \mathbf{else}:\\ \;\;\;\;r \cdot \frac{\sin b}{\cos a}\\ \end{array} \]
Alternative 3
Accuracy75.7%
Cost13384
\[\begin{array}{l} \mathbf{if}\;a \leq -5.6 \cdot 10^{+15}:\\ \;\;\;\;\sin b \cdot \frac{r}{\cos a}\\ \mathbf{elif}\;a \leq 8.2 \cdot 10^{+15}:\\ \;\;\;\;r \cdot \frac{\sin b}{\cos b}\\ \mathbf{else}:\\ \;\;\;\;r \cdot \frac{\sin b}{\cos a}\\ \end{array} \]
Alternative 4
Accuracy75.6%
Cost13384
\[\begin{array}{l} \mathbf{if}\;a \leq -5.6 \cdot 10^{+15}:\\ \;\;\;\;\frac{\sin b}{\frac{\cos a}{r}}\\ \mathbf{elif}\;a \leq 8.2 \cdot 10^{+15}:\\ \;\;\;\;r \cdot \frac{\sin b}{\cos b}\\ \mathbf{else}:\\ \;\;\;\;r \cdot \frac{\sin b}{\cos a}\\ \end{array} \]
Alternative 5
Accuracy75.6%
Cost13384
\[\begin{array}{l} \mathbf{if}\;a \leq -5.6 \cdot 10^{+15}:\\ \;\;\;\;\frac{\sin b}{\frac{\cos a}{r}}\\ \mathbf{elif}\;a \leq 8.2 \cdot 10^{+15}:\\ \;\;\;\;\frac{r \cdot \sin b}{\cos b}\\ \mathbf{else}:\\ \;\;\;\;r \cdot \frac{\sin b}{\cos a}\\ \end{array} \]
Alternative 6
Accuracy76.8%
Cost13248
\[r \cdot \frac{\sin b}{\cos \left(b + a\right)} \]
Alternative 7
Accuracy55.0%
Cost13120
\[r \cdot \frac{\sin b}{\cos a} \]
Alternative 8
Accuracy55.0%
Cost13120
\[\sin b \cdot \frac{r}{\cos a} \]
Alternative 9
Accuracy55.3%
Cost6985
\[\begin{array}{l} \mathbf{if}\;b \leq -2.3 \lor \neg \left(b \leq 12600000\right):\\ \;\;\;\;r \cdot \sin b\\ \mathbf{else}:\\ \;\;\;\;r \cdot \frac{b}{\cos a}\\ \end{array} \]
Alternative 10
Accuracy55.3%
Cost6985
\[\begin{array}{l} \mathbf{if}\;b \leq -1.35 \lor \neg \left(b \leq 19000\right):\\ \;\;\;\;r \cdot \sin b\\ \mathbf{else}:\\ \;\;\;\;b \cdot \frac{r}{\cos a}\\ \end{array} \]
Alternative 11
Accuracy39.0%
Cost6592
\[r \cdot \sin b \]
Alternative 12
Accuracy34.5%
Cost192
\[r \cdot b \]

Error

Reproduce?

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