| Alternative 1 | |
|---|---|
| Error | 0.2% |
| Cost | 13248 |
\[\sin y \cdot x + \cos y \cdot z
\]
(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 0.2
Simplified0.19
[Start]0.2 | \[ x \cdot \sin y + z \cdot \cos y
\] |
|---|---|
fma-def [=>]0.19 | \[ \color{blue}{\mathsf{fma}\left(x, \sin y, z \cdot \cos y\right)}
\] |
Taylor expanded in x around 0 0.2
Simplified0.19
[Start]0.2 | \[ \cos y \cdot z + \sin y \cdot x
\] |
|---|---|
*-commutative [<=]0.2 | \[ \cos y \cdot z + \color{blue}{x \cdot \sin y}
\] |
fma-def [=>]0.19 | \[ \color{blue}{\mathsf{fma}\left(\cos y, z, x \cdot \sin y\right)}
\] |
*-commutative [=>]0.19 | \[ \mathsf{fma}\left(\cos y, z, \color{blue}{\sin y \cdot x}\right)
\] |
Final simplification0.19
| Alternative 1 | |
|---|---|
| Error | 0.2% |
| Cost | 13248 |
| Alternative 2 | |
|---|---|
| Error | 15.92% |
| Cost | 7250 |
| Alternative 3 | |
|---|---|
| Error | 25.51% |
| Cost | 7120 |
| Alternative 4 | |
|---|---|
| Error | 26.44% |
| Cost | 6857 |
| Alternative 5 | |
|---|---|
| Error | 59.4% |
| Cost | 456 |
| Alternative 6 | |
|---|---|
| Error | 49.09% |
| Cost | 320 |
| Alternative 7 | |
|---|---|
| Error | 62.16% |
| Cost | 64 |
herbie shell --seed 2023089
(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))))