| Alternative 1 | |
|---|---|
| Error | 2.85% |
| Cost | 585 |
\[\begin{array}{l}
\mathbf{if}\;x \leq -0.14 \lor \neg \left(x \leq 0.14\right):\\
\;\;\;\;3 \cdot \left(x \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;-0.41379310344827586 \cdot y\\
\end{array}
\]
(FPCore (x y) :precision binary64 (* (* (- x (/ 16.0 116.0)) 3.0) y))
(FPCore (x y) :precision binary64 (* (fma x 3.0 -0.41379310344827586) y))
double code(double x, double y) {
return ((x - (16.0 / 116.0)) * 3.0) * y;
}
double code(double x, double y) {
return fma(x, 3.0, -0.41379310344827586) * y;
}
function code(x, y) return Float64(Float64(Float64(x - Float64(16.0 / 116.0)) * 3.0) * y) end
function code(x, y) return Float64(fma(x, 3.0, -0.41379310344827586) * y) end
code[x_, y_] := N[(N[(N[(x - N[(16.0 / 116.0), $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision] * y), $MachinePrecision]
code[x_, y_] := N[(N[(x * 3.0 + -0.41379310344827586), $MachinePrecision] * y), $MachinePrecision]
\left(\left(x - \frac{16}{116}\right) \cdot 3\right) \cdot y
\mathsf{fma}\left(x, 3, -0.41379310344827586\right) \cdot y
| Original | 0.28% |
|---|---|
| Target | 0.27% |
| Herbie | 0.27% |
Initial program 0.28
Simplified0.27
[Start]0.28 | \[ \left(\left(x - \frac{16}{116}\right) \cdot 3\right) \cdot y
\] |
|---|---|
*-commutative [=>]0.28 | \[ \color{blue}{\left(3 \cdot \left(x - \frac{16}{116}\right)\right)} \cdot y
\] |
sub-neg [=>]0.28 | \[ \left(3 \cdot \color{blue}{\left(x + \left(-\frac{16}{116}\right)\right)}\right) \cdot y
\] |
distribute-lft-in [=>]0.27 | \[ \color{blue}{\left(3 \cdot x + 3 \cdot \left(-\frac{16}{116}\right)\right)} \cdot y
\] |
*-commutative [=>]0.27 | \[ \left(\color{blue}{x \cdot 3} + 3 \cdot \left(-\frac{16}{116}\right)\right) \cdot y
\] |
fma-def [=>]0.27 | \[ \color{blue}{\mathsf{fma}\left(x, 3, 3 \cdot \left(-\frac{16}{116}\right)\right)} \cdot y
\] |
metadata-eval [=>]0.27 | \[ \mathsf{fma}\left(x, 3, 3 \cdot \left(-\color{blue}{0.13793103448275862}\right)\right) \cdot y
\] |
metadata-eval [=>]0.27 | \[ \mathsf{fma}\left(x, 3, 3 \cdot \color{blue}{-0.13793103448275862}\right) \cdot y
\] |
metadata-eval [=>]0.27 | \[ \mathsf{fma}\left(x, 3, \color{blue}{-0.41379310344827586}\right) \cdot y
\] |
Final simplification0.27
| Alternative 1 | |
|---|---|
| Error | 2.85% |
| Cost | 585 |
| Alternative 2 | |
|---|---|
| Error | 2.85% |
| Cost | 584 |
| Alternative 3 | |
|---|---|
| Error | 0.28% |
| Cost | 576 |
| Alternative 4 | |
|---|---|
| Error | 0.48% |
| Cost | 448 |
| Alternative 5 | |
|---|---|
| Error | 0.47% |
| Cost | 448 |
| Alternative 6 | |
|---|---|
| Error | 0.27% |
| Cost | 448 |
| Alternative 7 | |
|---|---|
| Error | 42.79% |
| Cost | 192 |
herbie shell --seed 2023102
(FPCore (x y)
:name "Data.Colour.CIE:cieLAB from colour-2.3.3, A"
:precision binary64
:herbie-target
(* y (- (* x 3.0) 0.41379310344827586))
(* (* (- x (/ 16.0 116.0)) 3.0) y))