| Alternative 1 | |
|---|---|
| Error | 0.32% |
| Cost | 13248 |
\[\mathsf{fma}\left(y - x, \mathsf{fma}\left(z, -6, 4\right), x\right)
\]
(FPCore (x y z) :precision binary64 (+ x (* (* (- y x) 6.0) (- (/ 2.0 3.0) z))))
(FPCore (x y z) :precision binary64 (fma 4.0 y (fma (fma 6.0 z -3.0) x (* z (* y -6.0)))))
double code(double x, double y, double z) {
return x + (((y - x) * 6.0) * ((2.0 / 3.0) - z));
}
double code(double x, double y, double z) {
return fma(4.0, y, fma(fma(6.0, z, -3.0), x, (z * (y * -6.0))));
}
function code(x, y, z) return Float64(x + Float64(Float64(Float64(y - x) * 6.0) * Float64(Float64(2.0 / 3.0) - z))) end
function code(x, y, z) return fma(4.0, y, fma(fma(6.0, z, -3.0), x, Float64(z * Float64(y * -6.0)))) end
code[x_, y_, z_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(4.0 * y + N[(N[(6.0 * z + -3.0), $MachinePrecision] * x + N[(z * N[(y * -6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)
\mathsf{fma}\left(4, y, \mathsf{fma}\left(\mathsf{fma}\left(6, z, -3\right), x, z \cdot \left(y \cdot -6\right)\right)\right)
Initial program 0.58
Simplified0.32
[Start]0.58 | \[ x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)
\] |
|---|---|
+-commutative [=>]0.58 | \[ \color{blue}{\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) + x}
\] |
associate-*l* [=>]0.34 | \[ \color{blue}{\left(y - x\right) \cdot \left(6 \cdot \left(\frac{2}{3} - z\right)\right)} + x
\] |
fma-def [=>]0.34 | \[ \color{blue}{\mathsf{fma}\left(y - x, 6 \cdot \left(\frac{2}{3} - z\right), x\right)}
\] |
sub-neg [=>]0.34 | \[ \mathsf{fma}\left(y - x, 6 \cdot \color{blue}{\left(\frac{2}{3} + \left(-z\right)\right)}, x\right)
\] |
distribute-lft-in [=>]0.32 | \[ \mathsf{fma}\left(y - x, \color{blue}{6 \cdot \frac{2}{3} + 6 \cdot \left(-z\right)}, x\right)
\] |
+-commutative [=>]0.32 | \[ \mathsf{fma}\left(y - x, \color{blue}{6 \cdot \left(-z\right) + 6 \cdot \frac{2}{3}}, x\right)
\] |
neg-mul-1 [=>]0.32 | \[ \mathsf{fma}\left(y - x, 6 \cdot \color{blue}{\left(-1 \cdot z\right)} + 6 \cdot \frac{2}{3}, x\right)
\] |
associate-*r* [=>]0.32 | \[ \mathsf{fma}\left(y - x, \color{blue}{\left(6 \cdot -1\right) \cdot z} + 6 \cdot \frac{2}{3}, x\right)
\] |
*-commutative [=>]0.32 | \[ \mathsf{fma}\left(y - x, \color{blue}{z \cdot \left(6 \cdot -1\right)} + 6 \cdot \frac{2}{3}, x\right)
\] |
fma-def [=>]0.32 | \[ \mathsf{fma}\left(y - x, \color{blue}{\mathsf{fma}\left(z, 6 \cdot -1, 6 \cdot \frac{2}{3}\right)}, x\right)
\] |
metadata-eval [=>]0.32 | \[ \mathsf{fma}\left(y - x, \mathsf{fma}\left(z, \color{blue}{-6}, 6 \cdot \frac{2}{3}\right), x\right)
\] |
metadata-eval [=>]0.32 | \[ \mathsf{fma}\left(y - x, \mathsf{fma}\left(z, -6, 6 \cdot \color{blue}{0.6666666666666666}\right), x\right)
\] |
metadata-eval [=>]0.32 | \[ \mathsf{fma}\left(y - x, \mathsf{fma}\left(z, -6, \color{blue}{4}\right), x\right)
\] |
Applied egg-rr0.32
Taylor expanded in x around 0 0.32
Simplified0.31
[Start]0.32 | \[ 4 \cdot y + \left(\left(6 \cdot z - 3\right) \cdot x + -6 \cdot \left(y \cdot z\right)\right)
\] |
|---|---|
fma-def [=>]0.32 | \[ \color{blue}{\mathsf{fma}\left(4, y, \left(6 \cdot z - 3\right) \cdot x + -6 \cdot \left(y \cdot z\right)\right)}
\] |
fma-def [=>]0.32 | \[ \mathsf{fma}\left(4, y, \color{blue}{\mathsf{fma}\left(6 \cdot z - 3, x, -6 \cdot \left(y \cdot z\right)\right)}\right)
\] |
fma-neg [=>]0.32 | \[ \mathsf{fma}\left(4, y, \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(6, z, -3\right)}, x, -6 \cdot \left(y \cdot z\right)\right)\right)
\] |
metadata-eval [=>]0.32 | \[ \mathsf{fma}\left(4, y, \mathsf{fma}\left(\mathsf{fma}\left(6, z, \color{blue}{-3}\right), x, -6 \cdot \left(y \cdot z\right)\right)\right)
\] |
associate-*r* [=>]0.31 | \[ \mathsf{fma}\left(4, y, \mathsf{fma}\left(\mathsf{fma}\left(6, z, -3\right), x, \color{blue}{\left(-6 \cdot y\right) \cdot z}\right)\right)
\] |
*-commutative [<=]0.31 | \[ \mathsf{fma}\left(4, y, \mathsf{fma}\left(\mathsf{fma}\left(6, z, -3\right), x, \color{blue}{z \cdot \left(-6 \cdot y\right)}\right)\right)
\] |
Final simplification0.31
| Alternative 1 | |
|---|---|
| Error | 0.32% |
| Cost | 13248 |
| Alternative 2 | |
|---|---|
| Error | 32.26% |
| Cost | 1504 |
| Alternative 3 | |
|---|---|
| Error | 31.38% |
| Cost | 1504 |
| Alternative 4 | |
|---|---|
| Error | 31.56% |
| Cost | 1504 |
| Alternative 5 | |
|---|---|
| Error | 50.38% |
| Cost | 1376 |
| Alternative 6 | |
|---|---|
| Error | 50.35% |
| Cost | 1376 |
| Alternative 7 | |
|---|---|
| Error | 50.31% |
| Cost | 1376 |
| Alternative 8 | |
|---|---|
| Error | 27.48% |
| Cost | 978 |
| Alternative 9 | |
|---|---|
| Error | 0.32% |
| Cost | 960 |
| Alternative 10 | |
|---|---|
| Error | 3.08% |
| Cost | 840 |
| Alternative 11 | |
|---|---|
| Error | 0.45% |
| Cost | 832 |
| Alternative 12 | |
|---|---|
| Error | 55.27% |
| Cost | 721 |
| Alternative 13 | |
|---|---|
| Error | 3.07% |
| Cost | 713 |
| Alternative 14 | |
|---|---|
| Error | 0.58% |
| Cost | 704 |
| Alternative 15 | |
|---|---|
| Error | 0.51% |
| Cost | 704 |
| Alternative 16 | |
|---|---|
| Error | 67.95% |
| Cost | 192 |
herbie shell --seed 2023090
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, D"
:precision binary64
(+ x (* (* (- y x) 6.0) (- (/ 2.0 3.0) z))))