Average Error: 14.7 → 0.3
Time: 21.0s
Precision: binary64
Cost: 39040
\[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
\[r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \left(-\sin b\right) \cdot \sin a\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) (* (- (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), (-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(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[((-N[Sin[b], $MachinePrecision]) * N[Sin[a], $MachinePrecision]), $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, \left(-\sin b\right) \cdot \sin a\right)}

Error

Derivation

  1. Initial program 14.7

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

    \[\leadsto \color{blue}{r \cdot \frac{\sin b}{\cos \left(b + a\right)}} \]
    Proof
    (*.f64 r (/.f64 (sin.f64 b) (cos.f64 (+.f64 b a)))): 0 points increase in error, 0 points decrease in error
    (*.f64 r (/.f64 (sin.f64 b) (cos.f64 (Rewrite<= +-commutative_binary64 (+.f64 a b))))): 0 points increase in error, 0 points decrease in error
  3. Applied egg-rr0.3

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

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

Alternatives

Alternative 1
Error0.3
Cost39040
\[r \cdot \frac{\sin b}{\mathsf{fma}\left(\sin b, -\sin a, \cos b \cdot \cos a\right)} \]
Alternative 2
Error0.3
Cost32704
\[\sin b \cdot \frac{r}{\cos b \cdot \cos a - \sin b \cdot \sin a} \]
Alternative 3
Error0.3
Cost32704
\[\frac{r \cdot \sin b}{\cos b \cdot \cos a - \sin b \cdot \sin a} \]
Alternative 4
Error0.3
Cost32704
\[r \cdot \frac{\sin b}{\cos b \cdot \cos a - \sin b \cdot \sin a} \]
Alternative 5
Error15.8
Cost13384
\[\begin{array}{l} t_0 := r \cdot \frac{\sin b}{\cos a}\\ \mathbf{if}\;a \leq -2.640883016558579 \cdot 10^{-8}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;a \leq 1.827704240141859 \cdot 10^{+58}:\\ \;\;\;\;r \cdot \tan b\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error15.9
Cost13384
\[\begin{array}{l} \mathbf{if}\;a \leq -2.640883016558579 \cdot 10^{-8}:\\ \;\;\;\;r \cdot \frac{\sin b}{\cos a}\\ \mathbf{elif}\;a \leq 1.827704240141859 \cdot 10^{+58}:\\ \;\;\;\;r \cdot \tan b\\ \mathbf{else}:\\ \;\;\;\;\sin b \cdot \frac{r}{\cos a}\\ \end{array} \]
Alternative 7
Error14.8
Cost13248
\[\frac{r}{\frac{\cos \left(b + a\right)}{\sin b}} \]
Alternative 8
Error14.8
Cost13248
\[r \cdot \frac{\sin b}{\cos \left(b - a\right)} \]
Alternative 9
Error14.9
Cost7112
\[\begin{array}{l} \mathbf{if}\;b \leq -1.2040225253424659 \cdot 10^{-5}:\\ \;\;\;\;r \cdot \tan b\\ \mathbf{elif}\;b \leq 0.0007977977107322805:\\ \;\;\;\;r \cdot \frac{b}{\cos a}\\ \mathbf{else}:\\ \;\;\;\;r \cdot \frac{1}{\frac{1}{\tan b}}\\ \end{array} \]
Alternative 10
Error14.9
Cost6984
\[\begin{array}{l} t_0 := r \cdot \tan b\\ \mathbf{if}\;b \leq -1.2040225253424659 \cdot 10^{-5}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;b \leq 0.0007977977107322805:\\ \;\;\;\;b \cdot \frac{r}{\cos a}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 11
Error14.9
Cost6984
\[\begin{array}{l} t_0 := r \cdot \tan b\\ \mathbf{if}\;b \leq -1.2040225253424659 \cdot 10^{-5}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;b \leq 0.0007977977107322805:\\ \;\;\;\;\frac{r \cdot b}{\cos a}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 12
Error14.9
Cost6984
\[\begin{array}{l} t_0 := r \cdot \tan b\\ \mathbf{if}\;b \leq -1.2040225253424659 \cdot 10^{-5}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;b \leq 0.0007977977107322805:\\ \;\;\;\;r \cdot \frac{b}{\cos a}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 13
Error25.4
Cost6592
\[r \cdot \tan b \]
Alternative 14
Error41.5
Cost832
\[\frac{1}{-0.3333333333333333 \cdot \frac{b}{r} + \frac{1}{r \cdot b}} \]
Alternative 15
Error41.9
Cost192
\[r \cdot b \]

Error

Reproduce

herbie shell --seed 2022291 
(FPCore (r a b)
  :name "rsin B"
  :precision binary64
  (* r (/ (sin b) (cos (+ a b)))))