?

Average Error: 0.0 → 0.0
Time: 6.6s
Precision: binary64
Cost: 6848

?

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

Error?

Target

Original0.0
Target0.0
Herbie0.0
\[y - x \cdot \left(y - z\right) \]

Derivation?

  1. Initial program 0.0

    \[\left(1 - x\right) \cdot y + x \cdot z \]
  2. Applied egg-rr0.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(z, x, \left(1 - x\right) \cdot y\right)} \]
  3. Final simplification0.0

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

Alternatives

Alternative 1
Error0.0
Cost6720
\[\mathsf{fma}\left(x, z - y, y\right) \]
Alternative 2
Error24.1
Cost916
\[\begin{array}{l} t_0 := y \cdot \left(-x\right)\\ \mathbf{if}\;x \leq -2 \cdot 10^{+88}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -2.5 \cdot 10^{-68}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq 2.1 \cdot 10^{-21}:\\ \;\;\;\;y\\ \mathbf{elif}\;x \leq 9.6 \cdot 10^{+66}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq 9 \cdot 10^{+105}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;z \cdot x\\ \end{array} \]
Alternative 3
Error12.7
Cost585
\[\begin{array}{l} \mathbf{if}\;x \leq -3.2 \cdot 10^{-67} \lor \neg \left(x \leq 6 \cdot 10^{-21}\right):\\ \;\;\;\;x \cdot \left(z - y\right)\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
Alternative 4
Error1.0
Cost585
\[\begin{array}{l} \mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 0.26\right):\\ \;\;\;\;x \cdot \left(z - y\right)\\ \mathbf{else}:\\ \;\;\;\;y + z \cdot x\\ \end{array} \]
Alternative 5
Error23.9
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -1.25 \cdot 10^{-70}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq 1.26 \cdot 10^{-20}:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;z \cdot x\\ \end{array} \]
Alternative 6
Error0.0
Cost448
\[y + x \cdot \left(z - y\right) \]
Alternative 7
Error34.3
Cost64
\[y \]

Error

Reproduce?

herbie shell --seed 2023028 
(FPCore (x y z)
  :name "Diagrams.Color.HSV:lerp  from diagrams-contrib-1.3.0.5"
  :precision binary64

  :herbie-target
  (- y (* x (- y z)))

  (+ (* (- 1.0 x) y) (* x z)))