?

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

?

\[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
\[\mathsf{fma}\left(y - x, 6 \cdot z, x\right) \]
(FPCore (x y z) :precision binary64 (+ x (* (* (- y x) 6.0) z)))
(FPCore (x y z) :precision binary64 (fma (- y x) (* 6.0 z) 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((y - x), (6.0 * z), 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(Float64(y - x), Float64(6.0 * z), 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[(N[(y - x), $MachinePrecision] * N[(6.0 * z), $MachinePrecision] + x), $MachinePrecision]
x + \left(\left(y - x\right) \cdot 6\right) \cdot z
\mathsf{fma}\left(y - x, 6 \cdot z, 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}{\mathsf{fma}\left(y - x, 6 \cdot z, x\right)} \]
    Proof

    [Start]99.6

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

    +-commutative [=>]99.6

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

    associate-*l* [=>]99.7

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

    fma-def [=>]99.7

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

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

Alternatives

Alternative 1
Accuracy63.5%
Cost716
\[\begin{array}{l} t_0 := 6 \cdot \left(y \cdot z\right)\\ \mathbf{if}\;z \leq -2.6 \cdot 10^{-39}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 6.9 \cdot 10^{-16}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 16200000000000:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;-6 \cdot \left(x \cdot z\right)\\ \end{array} \]
Alternative 2
Accuracy63.3%
Cost716
\[\begin{array}{l} t_0 := y \cdot \left(6 \cdot z\right)\\ \mathbf{if}\;z \leq -2.5 \cdot 10^{-52}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.52 \cdot 10^{-15}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1120000000000:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;-6 \cdot \left(x \cdot z\right)\\ \end{array} \]
Alternative 3
Accuracy63.4%
Cost716
\[\begin{array}{l} \mathbf{if}\;z \leq -5.4 \cdot 10^{-48}:\\ \;\;\;\;z \cdot \left(y \cdot 6\right)\\ \mathbf{elif}\;z \leq 8 \cdot 10^{-16}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 40000000000000:\\ \;\;\;\;y \cdot \left(6 \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;-6 \cdot \left(x \cdot z\right)\\ \end{array} \]
Alternative 4
Accuracy81.4%
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -1.5 \cdot 10^{-43} \lor \neg \left(z \leq 6.8 \cdot 10^{-16}\right):\\ \;\;\;\;6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Accuracy79.8%
Cost713
\[\begin{array}{l} \mathbf{if}\;x \leq -3.2 \cdot 10^{-68} \lor \neg \left(x \leq 0.0025\right):\\ \;\;\;\;x \cdot \left(1 + z \cdot -6\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y - x\right) \cdot \left(6 \cdot z\right)\\ \end{array} \]
Alternative 6
Accuracy81.3%
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -1.3 \cdot 10^{-46}:\\ \;\;\;\;6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \mathbf{elif}\;z \leq 7.5 \cdot 10^{-16}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\left(y - x\right) \cdot \left(6 \cdot z\right)\\ \end{array} \]
Alternative 7
Accuracy79.8%
Cost712
\[\begin{array}{l} \mathbf{if}\;x \leq -6.6 \cdot 10^{-68}:\\ \;\;\;\;x + z \cdot \left(x \cdot -6\right)\\ \mathbf{elif}\;x \leq 0.007:\\ \;\;\;\;\left(y - x\right) \cdot \left(6 \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 + z \cdot -6\right)\\ \end{array} \]
Alternative 8
Accuracy98.5%
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -0.205:\\ \;\;\;\;6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \mathbf{elif}\;z \leq 0.165:\\ \;\;\;\;x + z \cdot \left(y \cdot 6\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y - x\right) \cdot \left(6 \cdot z\right)\\ \end{array} \]
Alternative 9
Accuracy62.4%
Cost585
\[\begin{array}{l} \mathbf{if}\;z \leq -0.0016 \lor \neg \left(z \leq 0.165\right):\\ \;\;\;\;-6 \cdot \left(x \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 10
Accuracy99.6%
Cost576
\[x + z \cdot \left(\left(y - x\right) \cdot 6\right) \]
Alternative 11
Accuracy99.7%
Cost576
\[x + \left(y - x\right) \cdot \left(6 \cdot z\right) \]
Alternative 12
Accuracy45.6%
Cost64
\[x \]

Error

Reproduce?

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