| Alternative 1 | |
|---|---|
| Error | 0.2 |
| Cost | 6976 |
\[x + z \cdot \mathsf{fma}\left(6, y, x \cdot -6\right)
\]
(FPCore (x y z) :precision binary64 (+ x (* (* (- y x) 6.0) z)))
(FPCore (x y z) :precision binary64 (+ x (fma -6.0 (* x z) (* z (* 6.0 y)))))
double code(double x, double y, double z) {
return x + (((y - x) * 6.0) * z);
}
double code(double x, double y, double z) {
return x + fma(-6.0, (x * z), (z * (6.0 * y)));
}
function code(x, y, z) return Float64(x + Float64(Float64(Float64(y - x) * 6.0) * z)) end
function code(x, y, z) return Float64(x + fma(-6.0, Float64(x * z), Float64(z * Float64(6.0 * y)))) end
code[x_, y_, z_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(x + N[(-6.0 * N[(x * z), $MachinePrecision] + N[(z * N[(6.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x + \left(\left(y - x\right) \cdot 6\right) \cdot z
x + \mathsf{fma}\left(-6, x \cdot z, z \cdot \left(6 \cdot y\right)\right)
| Original | 0.2 |
|---|---|
| Target | 0.2 |
| Herbie | 0.2 |
Initial program 0.2
Taylor expanded in y around 0 0.2
Simplified0.2
[Start]0.2 | \[ x + \left(-6 \cdot \left(z \cdot x\right) + 6 \cdot \left(y \cdot z\right)\right)
\] |
|---|---|
*-commutative [=>]0.2 | \[ x + \left(-6 \cdot \left(z \cdot x\right) + 6 \cdot \color{blue}{\left(z \cdot y\right)}\right)
\] |
associate-*l* [<=]0.2 | \[ x + \left(-6 \cdot \left(z \cdot x\right) + \color{blue}{\left(6 \cdot z\right) \cdot y}\right)
\] |
fma-def [=>]0.2 | \[ x + \color{blue}{\mathsf{fma}\left(-6, z \cdot x, \left(6 \cdot z\right) \cdot y\right)}
\] |
*-commutative [=>]0.2 | \[ x + \mathsf{fma}\left(-6, z \cdot x, \color{blue}{\left(z \cdot 6\right)} \cdot y\right)
\] |
associate-*r* [<=]0.2 | \[ x + \mathsf{fma}\left(-6, z \cdot x, \color{blue}{z \cdot \left(6 \cdot y\right)}\right)
\] |
Final simplification0.2
| Alternative 1 | |
|---|---|
| Error | 0.2 |
| Cost | 6976 |
| Alternative 2 | |
|---|---|
| Error | 8.7 |
| Cost | 713 |
| Alternative 3 | |
|---|---|
| Error | 8.6 |
| Cost | 712 |
| Alternative 4 | |
|---|---|
| Error | 8.6 |
| Cost | 712 |
| Alternative 5 | |
|---|---|
| Error | 8.6 |
| Cost | 712 |
| Alternative 6 | |
|---|---|
| Error | 0.2 |
| Cost | 576 |
| Alternative 7 | |
|---|---|
| Error | 23.7 |
| Cost | 448 |
| Alternative 8 | |
|---|---|
| Error | 35.4 |
| Cost | 64 |
herbie shell --seed 2023010
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, E"
:precision binary64
:herbie-target
(- x (* (* 6.0 z) (- x y)))
(+ x (* (* (- y x) 6.0) z)))