| Alternative 1 | |
|---|---|
| Error | 0.3 |
| Cost | 45888 |
\[\begin{array}{l}
t_0 := \sin b \cdot \sin a\\
r \cdot \frac{\sin b}{t_0 \cdot -2 + \left(t_0 + \cos b \cdot \cos a\right)}
\end{array}
\]
(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 15.2
Simplified15.2
[Start]15.2 | \[ r \cdot \frac{\sin b}{\cos \left(a + b\right)}
\] |
|---|---|
+-commutative [=>]15.2 | \[ r \cdot \frac{\sin b}{\cos \color{blue}{\left(b + a\right)}}
\] |
Applied egg-rr0.3
Simplified0.3
[Start]0.3 | \[ 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 [=>]0.3 | \[ 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 [=>]0.3 | \[ 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 [=>]0.3 | \[ 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 simplification0.3
| Alternative 1 | |
|---|---|
| Error | 0.3 |
| Cost | 45888 |
| Alternative 2 | |
|---|---|
| Error | 0.3 |
| Cost | 32704 |
| Alternative 3 | |
|---|---|
| Error | 15.4 |
| Cost | 13385 |
| Alternative 4 | |
|---|---|
| Error | 15.4 |
| Cost | 13384 |
| Alternative 5 | |
|---|---|
| Error | 15.4 |
| Cost | 13384 |
| Alternative 6 | |
|---|---|
| Error | 15.2 |
| Cost | 13248 |
| Alternative 7 | |
|---|---|
| Error | 15.2 |
| Cost | 13248 |
| Alternative 8 | |
|---|---|
| Error | 15.2 |
| Cost | 13248 |
| Alternative 9 | |
|---|---|
| Error | 28.2 |
| Cost | 13120 |
| Alternative 10 | |
|---|---|
| Error | 28.1 |
| Cost | 6985 |
| Alternative 11 | |
|---|---|
| Error | 28.1 |
| Cost | 6985 |
| Alternative 12 | |
|---|---|
| Error | 38.8 |
| Cost | 6592 |
| Alternative 13 | |
|---|---|
| Error | 41.2 |
| Cost | 832 |
| Alternative 14 | |
|---|---|
| Error | 41.6 |
| Cost | 192 |
herbie shell --seed 2023073
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))