?

Average Accuracy: 99.6% → 99.7%
Time: 10.0s
Precision: binary64
Cost: 6848

?

\[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
\[\mathsf{fma}\left(6, z \cdot \left(y - x\right), x\right) \]
(FPCore (x y z) :precision binary64 (+ x (* (* (- y x) 6.0) z)))
(FPCore (x y z) :precision binary64 (fma 6.0 (* z (- y x)) x))
double code(double x, double y, double z) {
	return x + (((y - x) * 6.0) * z);
}
double code(double x, double y, double z) {
	return fma(6.0, (z * (y - x)), x);
}
function code(x, y, z)
	return Float64(x + Float64(Float64(Float64(y - x) * 6.0) * z))
end
function code(x, y, z)
	return fma(6.0, Float64(z * Float64(y - x)), x)
end
code[x_, y_, z_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(6.0 * N[(z * N[(y - x), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
x + \left(\left(y - x\right) \cdot 6\right) \cdot z
\mathsf{fma}\left(6, z \cdot \left(y - x\right), x\right)

Error?

Target

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

Derivation?

  1. Initial program 99.6%

    \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
  2. Simplified99.7%

    \[\leadsto \color{blue}{x + \left(y - x\right) \cdot \left(6 \cdot z\right)} \]
    Proof

    [Start]99.6

    \[ x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]

    associate-*l* [=>]99.7

    \[ x + \color{blue}{\left(y - x\right) \cdot \left(6 \cdot z\right)} \]
  3. Taylor expanded in x around -inf 99.7%

    \[\leadsto \color{blue}{6 \cdot \left(y \cdot z\right) + -1 \cdot \left(\left(6 \cdot z - 1\right) \cdot x\right)} \]
  4. Simplified99.7%

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

    [Start]99.7

    \[ 6 \cdot \left(y \cdot z\right) + -1 \cdot \left(\left(6 \cdot z - 1\right) \cdot x\right) \]

    *-commutative [=>]99.7

    \[ \color{blue}{\left(y \cdot z\right) \cdot 6} + -1 \cdot \left(\left(6 \cdot z - 1\right) \cdot x\right) \]

    associate-*r* [<=]99.7

    \[ \color{blue}{y \cdot \left(z \cdot 6\right)} + -1 \cdot \left(\left(6 \cdot z - 1\right) \cdot x\right) \]

    *-commutative [<=]99.7

    \[ y \cdot \color{blue}{\left(6 \cdot z\right)} + -1 \cdot \left(\left(6 \cdot z - 1\right) \cdot x\right) \]

    *-lft-identity [<=]99.7

    \[ \color{blue}{1 \cdot \left(y \cdot \left(6 \cdot z\right)\right)} + -1 \cdot \left(\left(6 \cdot z - 1\right) \cdot x\right) \]

    *-commutative [<=]99.7

    \[ \color{blue}{\left(y \cdot \left(6 \cdot z\right)\right) \cdot 1} + -1 \cdot \left(\left(6 \cdot z - 1\right) \cdot x\right) \]

    mul-1-neg [=>]99.7

    \[ \left(y \cdot \left(6 \cdot z\right)\right) \cdot 1 + \color{blue}{\left(-\left(6 \cdot z - 1\right) \cdot x\right)} \]

    unsub-neg [=>]99.7

    \[ \color{blue}{\left(y \cdot \left(6 \cdot z\right)\right) \cdot 1 - \left(6 \cdot z - 1\right) \cdot x} \]

    *-commutative [=>]99.7

    \[ \left(y \cdot \left(6 \cdot z\right)\right) \cdot 1 - \color{blue}{x \cdot \left(6 \cdot z - 1\right)} \]

    sub-neg [=>]99.7

    \[ \left(y \cdot \left(6 \cdot z\right)\right) \cdot 1 - x \cdot \color{blue}{\left(6 \cdot z + \left(-1\right)\right)} \]

    metadata-eval [=>]99.7

    \[ \left(y \cdot \left(6 \cdot z\right)\right) \cdot 1 - x \cdot \left(6 \cdot z + \color{blue}{-1}\right) \]

    distribute-rgt-in [=>]99.7

    \[ \left(y \cdot \left(6 \cdot z\right)\right) \cdot 1 - \color{blue}{\left(\left(6 \cdot z\right) \cdot x + -1 \cdot x\right)} \]

    neg-mul-1 [<=]99.7

    \[ \left(y \cdot \left(6 \cdot z\right)\right) \cdot 1 - \left(\left(6 \cdot z\right) \cdot x + \color{blue}{\left(-x\right)}\right) \]

    associate--r+ [=>]99.7

    \[ \color{blue}{\left(\left(y \cdot \left(6 \cdot z\right)\right) \cdot 1 - \left(6 \cdot z\right) \cdot x\right) - \left(-x\right)} \]
  5. Final simplification99.7%

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

Alternatives

Alternative 1
Accuracy80.0%
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -3.3 \cdot 10^{-59} \lor \neg \left(z \leq 1.85 \cdot 10^{-6}\right):\\ \;\;\;\;6 \cdot \left(z \cdot \left(y - x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Accuracy80.0%
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -2.7 \cdot 10^{-62} \lor \neg \left(z \leq 0.0145\right):\\ \;\;\;\;6 \cdot \left(z \cdot \left(y - x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(x \cdot -6\right)\\ \end{array} \]
Alternative 3
Accuracy98.3%
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -0.00055 \lor \neg \left(z \leq 0.17\right):\\ \;\;\;\;6 \cdot \left(z \cdot \left(y - x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(6 \cdot y\right)\\ \end{array} \]
Alternative 4
Accuracy98.4%
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -0.00055 \lor \neg \left(z \leq 0.17\right):\\ \;\;\;\;6 \cdot \left(z \cdot \left(y - x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{z}{\frac{0.16666666666666666}{y}}\\ \end{array} \]
Alternative 5
Accuracy61.7%
Cost585
\[\begin{array}{l} \mathbf{if}\;z \leq -0.00055 \lor \neg \left(z \leq 6200\right):\\ \;\;\;\;-6 \cdot \left(z \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Accuracy62.6%
Cost585
\[\begin{array}{l} \mathbf{if}\;z \leq -2.5 \cdot 10^{-62} \lor \neg \left(z \leq 1.6 \cdot 10^{-6}\right):\\ \;\;\;\;6 \cdot \left(z \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Accuracy62.6%
Cost584
\[\begin{array}{l} \mathbf{if}\;z \leq -2.45 \cdot 10^{-61}:\\ \;\;\;\;z \cdot \left(6 \cdot y\right)\\ \mathbf{elif}\;z \leq 1.6 \cdot 10^{-6}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \left(z \cdot y\right)\\ \end{array} \]
Alternative 8
Accuracy99.6%
Cost576
\[x + z \cdot \left(6 \cdot \left(y - x\right)\right) \]
Alternative 9
Accuracy99.7%
Cost576
\[x + \left(y - x\right) \cdot \left(6 \cdot z\right) \]
Alternative 10
Accuracy45.4%
Cost64
\[x \]

Error

Reproduce?

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