| Alternative 1 | |
|---|---|
| Accuracy | 99.5% |
| Cost | 32704 |
\[r \cdot \frac{\sin b}{\cos b \cdot \cos a - \sin b \cdot \sin a}
\]
(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)
(fma (- (sin b)) (sin a) (fma (- (sin a)) (sin 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 r * (sin(b) / fma(cos(b), cos(a), fma(-sin(b), sin(a), fma(-sin(a), sin(b), (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), fma(Float64(-sin(b)), sin(a), fma(Float64(-sin(a)), sin(b), 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] + N[((-N[Sin[a], $MachinePrecision]) * N[Sin[b], $MachinePrecision] + N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $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, \mathsf{fma}\left(-\sin b, \sin a, \mathsf{fma}\left(-\sin a, \sin b, \sin b \cdot \sin a\right)\right)\right)}
Initial program 75.7%
Simplified75.7%
[Start]75.7 | \[ r \cdot \frac{\sin b}{\cos \left(a + b\right)}
\] |
|---|---|
+-commutative [=>]75.7 | \[ r \cdot \frac{\sin b}{\cos \color{blue}{\left(b + a\right)}}
\] |
Applied egg-rr99.5%
Simplified99.5%
[Start]99.5 | \[ r \cdot \frac{\sin b}{\cos b \cdot \cos a + \left(\left(-\sin b\right) \cdot \sin a + \mathsf{fma}\left(-\sin a, \sin b, \sin b \cdot \sin a\right)\right)}
\] |
|---|---|
fma-def [=>]99.5 | \[ r \cdot \frac{\sin b}{\color{blue}{\mathsf{fma}\left(\cos b, \cos a, \left(-\sin b\right) \cdot \sin a + \mathsf{fma}\left(-\sin a, \sin b, \sin b \cdot \sin a\right)\right)}}
\] |
fma-def [=>]99.5 | \[ r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \color{blue}{\mathsf{fma}\left(-\sin b, \sin a, \mathsf{fma}\left(-\sin a, \sin b, \sin b \cdot \sin a\right)\right)}\right)}
\] |
*-commutative [=>]99.5 | \[ r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \mathsf{fma}\left(-\sin b, \sin a, \mathsf{fma}\left(-\sin a, \sin b, \color{blue}{\sin a \cdot \sin b}\right)\right)\right)}
\] |
Final simplification99.5%
| Alternative 1 | |
|---|---|
| Accuracy | 99.5% |
| Cost | 32704 |
| Alternative 2 | |
|---|---|
| Accuracy | 75.4% |
| Cost | 13385 |
| Alternative 3 | |
|---|---|
| Accuracy | 75.4% |
| Cost | 13384 |
| Alternative 4 | |
|---|---|
| Accuracy | 75.4% |
| Cost | 13384 |
| Alternative 5 | |
|---|---|
| Accuracy | 75.4% |
| Cost | 13384 |
| Alternative 6 | |
|---|---|
| Accuracy | 75.7% |
| Cost | 13248 |
| Alternative 7 | |
|---|---|
| Accuracy | 75.7% |
| Cost | 13248 |
| Alternative 8 | |
|---|---|
| Accuracy | 53.9% |
| Cost | 13120 |
| Alternative 9 | |
|---|---|
| Accuracy | 53.9% |
| Cost | 13120 |
| Alternative 10 | |
|---|---|
| Accuracy | 53.9% |
| Cost | 7113 |
| Alternative 11 | |
|---|---|
| Accuracy | 53.9% |
| Cost | 6985 |
| Alternative 12 | |
|---|---|
| Accuracy | 53.8% |
| Cost | 6985 |
| Alternative 13 | |
|---|---|
| Accuracy | 38.3% |
| Cost | 6592 |
| Alternative 14 | |
|---|---|
| Accuracy | 33.8% |
| Cost | 192 |
herbie shell --seed 2023125
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))