?

Average Error: 24.26% → 0.54%
Time: 14.0s
Precision: binary64
Cost: 39040

?

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

Error?

Derivation?

  1. Initial program 24.26

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

    \[\leadsto \frac{r \cdot \sin b}{\color{blue}{\mathsf{fma}\left(\cos a, \cos b, -\sin b \cdot \sin a\right)}} \]
  3. Taylor expanded in r around 0 0.52

    \[\leadsto \color{blue}{\frac{\sin b \cdot r}{\cos a \cdot \cos b - \sin a \cdot \sin b}} \]
  4. Simplified0.54

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

    [Start]0.52

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

    *-commutative [=>]0.52

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

    associate-/l* [=>]0.6

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

    associate-/r/ [=>]0.55

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

    *-commutative [<=]0.55

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

    fma-neg [=>]0.54

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

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

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

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

Alternatives

Alternative 1
Error0.55%
Cost32704
\[\sin b \cdot \frac{r}{\cos a \cdot \cos b - \sin b \cdot \sin a} \]
Alternative 2
Error0.59%
Cost32512
\[\frac{r}{\mathsf{fma}\left(\frac{\cos b}{\sin b}, \cos a, -\sin a\right)} \]
Alternative 3
Error23.2%
Cost19648
\[\frac{r \cdot \sin b}{\cos a \cdot \cos b} \]
Alternative 4
Error24.27%
Cost13248
\[\sin b \cdot \frac{r}{\cos \left(a + b\right)} \]
Alternative 5
Error24.57%
Cost6985
\[\begin{array}{l} \mathbf{if}\;b \leq -9 \cdot 10^{-8} \lor \neg \left(b \leq 1.85 \cdot 10^{-14}\right):\\ \;\;\;\;r \cdot \tan b\\ \mathbf{else}:\\ \;\;\;\;r \cdot \frac{b}{\cos a}\\ \end{array} \]
Alternative 6
Error24.58%
Cost6985
\[\begin{array}{l} \mathbf{if}\;b \leq -9 \cdot 10^{-8} \lor \neg \left(b \leq 1.85 \cdot 10^{-14}\right):\\ \;\;\;\;r \cdot \tan b\\ \mathbf{else}:\\ \;\;\;\;b \cdot \frac{r}{\cos a}\\ \end{array} \]
Alternative 7
Error61.72%
Cost6592
\[r \cdot \sin b \]
Alternative 8
Error40.04%
Cost6592
\[r \cdot \tan b \]
Alternative 9
Error66.23%
Cost192
\[r \cdot b \]

Error

Reproduce?

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