| Alternative 1 | |
|---|---|
| Error | 0.1 |
| 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.1
Taylor expanded in x around 0 0.1
Simplified0.1
[Start]0.1 | \[ \cos y \cdot z + \sin y \cdot x
\] |
|---|---|
*-commutative [<=]0.1 | \[ \cos y \cdot z + \color{blue}{x \cdot \sin y}
\] |
fma-def [=>]0.1 | \[ \color{blue}{\mathsf{fma}\left(\cos y, z, x \cdot \sin y\right)}
\] |
*-commutative [=>]0.1 | \[ \mathsf{fma}\left(\cos y, z, \color{blue}{\sin y \cdot x}\right)
\] |
Final simplification0.1
| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 13248 |
| Alternative 2 | |
|---|---|
| Error | 16.7 |
| Cost | 7252 |
| Alternative 3 | |
|---|---|
| Error | 9.4 |
| Cost | 6985 |
| Alternative 4 | |
|---|---|
| Error | 16.1 |
| Cost | 6857 |
| Alternative 5 | |
|---|---|
| Error | 31.1 |
| Cost | 320 |
| Alternative 6 | |
|---|---|
| Error | 39.6 |
| Cost | 64 |
herbie shell --seed 2022356
(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))))