| Alternative 1 | |
|---|---|
| Error | 0.2% |
| Cost | 13248 |
\[\cos y \cdot x - z \cdot \sin y
\]
(FPCore (x y z) :precision binary64 (- (* x (cos y)) (* z (sin y))))
(FPCore (x y z) :precision binary64 (fma (cos y) x (* z (- (sin y)))))
double code(double x, double y, double z) {
return (x * cos(y)) - (z * sin(y));
}
double code(double x, double y, double z) {
return fma(cos(y), x, (z * -sin(y)));
}
function code(x, y, z) return Float64(Float64(x * cos(y)) - Float64(z * sin(y))) end
function code(x, y, z) return fma(cos(y), x, Float64(z * Float64(-sin(y)))) end
code[x_, y_, z_] := N[(N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(N[Cos[y], $MachinePrecision] * x + N[(z * (-N[Sin[y], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]
x \cdot \cos y - z \cdot \sin y
\mathsf{fma}\left(\cos y, x, z \cdot \left(-\sin y\right)\right)
Initial program 0.2
Taylor expanded in x around 0 0.2
Simplified0.2
[Start]0.2 | \[ -1 \cdot \left(z \cdot \sin y\right) + \cos y \cdot x
\] |
|---|---|
+-commutative [=>]0.2 | \[ \color{blue}{\cos y \cdot x + -1 \cdot \left(z \cdot \sin y\right)}
\] |
mul-1-neg [=>]0.2 | \[ \cos y \cdot x + \color{blue}{\left(-z \cdot \sin y\right)}
\] |
distribute-rgt-neg-out [<=]0.2 | \[ \cos y \cdot x + \color{blue}{z \cdot \left(-\sin y\right)}
\] |
fma-udef [<=]0.2 | \[ \color{blue}{\mathsf{fma}\left(\cos y, x, z \cdot \left(-\sin y\right)\right)}
\] |
distribute-rgt-neg-out [=>]0.2 | \[ \mathsf{fma}\left(\cos y, x, \color{blue}{-z \cdot \sin y}\right)
\] |
distribute-lft-neg-in [=>]0.2 | \[ \mathsf{fma}\left(\cos y, x, \color{blue}{\left(-z\right) \cdot \sin y}\right)
\] |
Final simplification0.2
| Alternative 1 | |
|---|---|
| Error | 0.2% |
| Cost | 13248 |
| Alternative 2 | |
|---|---|
| Error | 13.79% |
| Cost | 7890 |
| Alternative 3 | |
|---|---|
| Error | 29.41% |
| Cost | 7451 |
| Alternative 4 | |
|---|---|
| Error | 16.27% |
| Cost | 7250 |
| Alternative 5 | |
|---|---|
| Error | 25.44% |
| Cost | 6857 |
| Alternative 6 | |
|---|---|
| Error | 59.97% |
| Cost | 520 |
| Alternative 7 | |
|---|---|
| Error | 49.06% |
| Cost | 320 |
| Alternative 8 | |
|---|---|
| Error | 60.73% |
| Cost | 64 |
herbie shell --seed 2023102
(FPCore (x y z)
:name "Diagrams.ThreeD.Transform:aboutX from diagrams-lib-1.3.0.3, A"
:precision binary64
(- (* x (cos y)) (* z (sin y))))