| Alternative 1 | |
|---|---|
| Accuracy | 99.8% |
| Cost | 19520 |
\[\mathsf{fma}\left(x, \sin y, \cos y \cdot z\right)
\]
(FPCore (x y z) :precision binary64 (+ (* x (sin y)) (* z (cos y))))
(FPCore (x y z) :precision binary64 (fma (cos y) z (* (sin y) x)))
double code(double x, double y, double z) {
return (x * sin(y)) + (z * cos(y));
}
double code(double x, double y, double z) {
return fma(cos(y), z, (sin(y) * x));
}
function code(x, y, z) return Float64(Float64(x * sin(y)) + Float64(z * cos(y))) end
function code(x, y, z) return fma(cos(y), z, Float64(sin(y) * x)) end
code[x_, y_, z_] := N[(N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(N[Cos[y], $MachinePrecision] * z + N[(N[Sin[y], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]
x \cdot \sin y + z \cdot \cos y
\mathsf{fma}\left(\cos y, z, \sin y \cdot x\right)
Initial program 99.8%
Simplified99.8%
[Start]99.8 | \[ x \cdot \sin y + z \cdot \cos y
\] |
|---|---|
fma-def [=>]99.8 | \[ \color{blue}{\mathsf{fma}\left(x, \sin y, z \cdot \cos y\right)}
\] |
Taylor expanded in x around 0 99.8%
Simplified99.8%
[Start]99.8 | \[ \cos y \cdot z + \sin y \cdot x
\] |
|---|---|
*-commutative [<=]99.8 | \[ \cos y \cdot z + \color{blue}{x \cdot \sin y}
\] |
fma-def [=>]99.8 | \[ \color{blue}{\mathsf{fma}\left(\cos y, z, x \cdot \sin y\right)}
\] |
*-commutative [=>]99.8 | \[ \mathsf{fma}\left(\cos y, z, \color{blue}{\sin y \cdot x}\right)
\] |
Final simplification99.8%
| Alternative 1 | |
|---|---|
| Accuracy | 99.8% |
| Cost | 19520 |
| Alternative 2 | |
|---|---|
| Accuracy | 99.8% |
| Cost | 13248 |
| Alternative 3 | |
|---|---|
| Accuracy | 75.3% |
| Cost | 7516 |
| Alternative 4 | |
|---|---|
| Accuracy | 85.5% |
| Cost | 6985 |
| Alternative 5 | |
|---|---|
| Accuracy | 75.3% |
| Cost | 6857 |
| Alternative 6 | |
|---|---|
| Accuracy | 40.2% |
| Cost | 588 |
| Alternative 7 | |
|---|---|
| Accuracy | 51.9% |
| Cost | 320 |
| Alternative 8 | |
|---|---|
| Accuracy | 39.3% |
| Cost | 64 |
herbie shell --seed 2023133
(FPCore (x y z)
:name "Diagrams.ThreeD.Transform:aboutX from diagrams-lib-1.3.0.3, B"
:precision binary64
(+ (* x (sin y)) (* z (cos y))))