| Alternative 1 | |
|---|---|
| Error | 0.38% |
| Cost | 7360 |
\[\mathsf{fma}\left(-3, x, 6 \cdot \left(x \cdot z\right)\right) + 6 \cdot \left(y \cdot \left(0.6666666666666666 - z\right)\right)
\]
(FPCore (x y z) :precision binary64 (+ x (* (* (- y x) 6.0) (- (/ 2.0 3.0) z))))
(FPCore (x y z) :precision binary64 (fma (- y x) (fma z -6.0 4.0) x))
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((y - x), fma(z, -6.0, 4.0), x);
}
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(Float64(y - x), fma(z, -6.0, 4.0), x) 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[(N[(y - x), $MachinePrecision] * N[(z * -6.0 + 4.0), $MachinePrecision] + x), $MachinePrecision]
x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)
\mathsf{fma}\left(y - x, \mathsf{fma}\left(z, -6, 4\right), x\right)
Initial program 0.66
Simplified0.3
[Start]0.66 | \[ x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)
\] |
|---|---|
+-commutative [=>]0.66 | \[ \color{blue}{\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) + x}
\] |
associate-*l* [=>]0.35 | \[ \color{blue}{\left(y - x\right) \cdot \left(6 \cdot \left(\frac{2}{3} - z\right)\right)} + x
\] |
fma-def [=>]0.32 | \[ \color{blue}{\mathsf{fma}\left(y - x, 6 \cdot \left(\frac{2}{3} - z\right), x\right)}
\] |
sub-neg [=>]0.32 | \[ \mathsf{fma}\left(y - x, 6 \cdot \color{blue}{\left(\frac{2}{3} + \left(-z\right)\right)}, x\right)
\] |
distribute-lft-in [=>]0.31 | \[ \mathsf{fma}\left(y - x, \color{blue}{6 \cdot \frac{2}{3} + 6 \cdot \left(-z\right)}, x\right)
\] |
+-commutative [=>]0.31 | \[ \mathsf{fma}\left(y - x, \color{blue}{6 \cdot \left(-z\right) + 6 \cdot \frac{2}{3}}, x\right)
\] |
neg-mul-1 [=>]0.31 | \[ \mathsf{fma}\left(y - x, 6 \cdot \color{blue}{\left(-1 \cdot z\right)} + 6 \cdot \frac{2}{3}, x\right)
\] |
associate-*r* [=>]0.31 | \[ \mathsf{fma}\left(y - x, \color{blue}{\left(6 \cdot -1\right) \cdot z} + 6 \cdot \frac{2}{3}, x\right)
\] |
*-commutative [=>]0.31 | \[ \mathsf{fma}\left(y - x, \color{blue}{z \cdot \left(6 \cdot -1\right)} + 6 \cdot \frac{2}{3}, x\right)
\] |
fma-def [=>]0.3 | \[ \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.3 | \[ \mathsf{fma}\left(y - x, \mathsf{fma}\left(z, \color{blue}{-6}, 6 \cdot \frac{2}{3}\right), x\right)
\] |
metadata-eval [=>]0.3 | \[ \mathsf{fma}\left(y - x, \mathsf{fma}\left(z, -6, 6 \cdot \color{blue}{0.6666666666666666}\right), x\right)
\] |
metadata-eval [=>]0.3 | \[ \mathsf{fma}\left(y - x, \mathsf{fma}\left(z, -6, \color{blue}{4}\right), x\right)
\] |
Final simplification0.3
| Alternative 1 | |
|---|---|
| Error | 0.38% |
| Cost | 7360 |
| Alternative 2 | |
|---|---|
| Error | 32.97% |
| Cost | 1636 |
| Alternative 3 | |
|---|---|
| Error | 51.09% |
| Cost | 1508 |
| Alternative 4 | |
|---|---|
| Error | 51.08% |
| Cost | 1508 |
| Alternative 5 | |
|---|---|
| Error | 33.3% |
| Cost | 1504 |
| Alternative 6 | |
|---|---|
| Error | 32.38% |
| Cost | 1504 |
| Alternative 7 | |
|---|---|
| Error | 32.47% |
| Cost | 1504 |
| Alternative 8 | |
|---|---|
| Error | 50.92% |
| Cost | 1376 |
| Alternative 9 | |
|---|---|
| Error | 0.48% |
| Cost | 1088 |
| Alternative 10 | |
|---|---|
| Error | 0.52% |
| Cost | 832 |
| Alternative 11 | |
|---|---|
| Error | 2.83% |
| Cost | 713 |
| Alternative 12 | |
|---|---|
| Error | 0.66% |
| Cost | 704 |
| Alternative 13 | |
|---|---|
| Error | 53.44% |
| Cost | 456 |
| Alternative 14 | |
|---|---|
| Error | 67.15% |
| Cost | 192 |
herbie shell --seed 2023115
(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))))