?

Average Accuracy: 99.6% → 99.7%
Time: 5.4s
Precision: binary64
Cost: 6720

?

\[\left(\left(x - \frac{16}{116}\right) \cdot 3\right) \cdot y \]
\[\mathsf{fma}\left(x, 3, -0.41379310344827586\right) \cdot y \]
(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

Error?

Target

Original99.6%
Target99.6%
Herbie99.7%
\[y \cdot \left(x \cdot 3 - 0.41379310344827586\right) \]

Derivation?

  1. Initial program 99.6%

    \[\left(\left(x - \frac{16}{116}\right) \cdot 3\right) \cdot y \]
  2. Simplified99.7%

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, 3, -0.41379310344827586\right) \cdot y} \]
    Proof

    [Start]99.6

    \[ \left(\left(x - \frac{16}{116}\right) \cdot 3\right) \cdot y \]

    *-commutative [=>]99.6

    \[ \color{blue}{\left(3 \cdot \left(x - \frac{16}{116}\right)\right)} \cdot y \]

    sub-neg [=>]99.6

    \[ \left(3 \cdot \color{blue}{\left(x + \left(-\frac{16}{116}\right)\right)}\right) \cdot y \]

    distribute-lft-in [=>]99.6

    \[ \color{blue}{\left(3 \cdot x + 3 \cdot \left(-\frac{16}{116}\right)\right)} \cdot y \]

    *-commutative [=>]99.6

    \[ \left(\color{blue}{x \cdot 3} + 3 \cdot \left(-\frac{16}{116}\right)\right) \cdot y \]

    fma-def [=>]99.7

    \[ \color{blue}{\mathsf{fma}\left(x, 3, 3 \cdot \left(-\frac{16}{116}\right)\right)} \cdot y \]

    metadata-eval [=>]99.7

    \[ \mathsf{fma}\left(x, 3, 3 \cdot \left(-\color{blue}{0.13793103448275862}\right)\right) \cdot y \]

    metadata-eval [=>]99.7

    \[ \mathsf{fma}\left(x, 3, 3 \cdot \color{blue}{-0.13793103448275862}\right) \cdot y \]

    metadata-eval [=>]99.7

    \[ \mathsf{fma}\left(x, 3, \color{blue}{-0.41379310344827586}\right) \cdot y \]
  3. Final simplification99.7%

    \[\leadsto \mathsf{fma}\left(x, 3, -0.41379310344827586\right) \cdot y \]

Alternatives

Alternative 1
Accuracy97.4%
Cost585
\[\begin{array}{l} \mathbf{if}\;x \leq -0.14 \lor \neg \left(x \leq 0.135\right):\\ \;\;\;\;3 \cdot \left(x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;-0.41379310344827586 \cdot y\\ \end{array} \]
Alternative 2
Accuracy97.4%
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -0.14:\\ \;\;\;\;x \cdot \left(3 \cdot y\right)\\ \mathbf{elif}\;x \leq 0.135:\\ \;\;\;\;-0.41379310344827586 \cdot y\\ \mathbf{else}:\\ \;\;\;\;3 \cdot \left(x \cdot y\right)\\ \end{array} \]
Alternative 3
Accuracy97.3%
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -0.14:\\ \;\;\;\;\frac{y}{\frac{0.3333333333333333}{x}}\\ \mathbf{elif}\;x \leq 0.135:\\ \;\;\;\;-0.41379310344827586 \cdot y\\ \mathbf{else}:\\ \;\;\;\;3 \cdot \left(x \cdot y\right)\\ \end{array} \]
Alternative 4
Accuracy99.5%
Cost448
\[3 \cdot \left(y \cdot \left(x + -0.13793103448275862\right)\right) \]
Alternative 5
Accuracy99.6%
Cost448
\[y \cdot \left(-0.41379310344827586 + x \cdot 3\right) \]
Alternative 6
Accuracy56.7%
Cost192
\[-0.41379310344827586 \cdot y \]

Error

Reproduce?

herbie shell --seed 2023129 
(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))