?

Average Error: 24.14% → 0.5%
Time: 16.5s
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 24.14

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

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

    [Start]24.14

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

    +-commutative [=>]24.14

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

    \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos b \cdot \cos a - \sin b \cdot \sin a}} \]
  4. Applied egg-rr0.52

    \[\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)}} \]
  5. Simplified0.52

    \[\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]0.52

    \[ 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+ [=>]0.51

    \[ 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 [<=]0.51

    \[ 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 [=>]0.52

    \[ 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 [<=]0.52

    \[ 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+ [=>]0.57

    \[ 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 0.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. Simplified0.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]0.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 [=>]0.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 [=>]0.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 [<=]0.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 [=>]0.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-rr0.5

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

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

Alternatives

Alternative 1
Error0.52%
Cost32704
\[r \cdot \frac{\sin b}{\cos b \cdot \cos a - \sin b \cdot \sin a} \]
Alternative 2
Error0.53%
Cost32704
\[\frac{r \cdot \sin b}{\cos b \cdot \cos a - \sin b \cdot \sin a} \]
Alternative 3
Error24.57%
Cost13385
\[\begin{array}{l} \mathbf{if}\;a \leq -4.3 \cdot 10^{-5} \lor \neg \left(a \leq 1500\right):\\ \;\;\;\;r \cdot \frac{\sin b}{\cos a}\\ \mathbf{else}:\\ \;\;\;\;\sin b \cdot \frac{r}{\cos b}\\ \end{array} \]
Alternative 4
Error24.55%
Cost13384
\[\begin{array}{l} \mathbf{if}\;a \leq -2.4 \cdot 10^{-5}:\\ \;\;\;\;r \cdot \frac{\sin b}{\cos a}\\ \mathbf{elif}\;a \leq 1500:\\ \;\;\;\;\sin b \cdot \frac{r}{\cos b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin b}{\frac{\cos a}{r}}\\ \end{array} \]
Alternative 5
Error24.14%
Cost13248
\[r \cdot \frac{\sin b}{\cos \left(b + a\right)} \]
Alternative 6
Error24.14%
Cost13248
\[\sin b \cdot \frac{r}{\cos \left(b + a\right)} \]
Alternative 7
Error45.89%
Cost13120
\[r \cdot \frac{\sin b}{\cos a} \]
Alternative 8
Error49.28%
Cost7232
\[\frac{\frac{r}{\cos \left(b + a\right)}}{b \cdot 0.16666666666666666 + \frac{1}{b}} \]
Alternative 9
Error50.19%
Cost6720
\[r \cdot \frac{b}{\cos a} \]
Alternative 10
Error50.19%
Cost6720
\[b \cdot \frac{r}{\cos a} \]
Alternative 11
Error65.84%
Cost192
\[r \cdot b \]

Error

Reproduce?

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