Average Error: 0.0 → 0.0
Time: 6.3s
Precision: binary64
Cost: 6848
\[\left(1 - x\right) \cdot y + x \cdot z \]
\[\mathsf{fma}\left(1 - x, y, x \cdot z\right) \]
(FPCore (x y z) :precision binary64 (+ (* (- 1.0 x) y) (* x z)))
(FPCore (x y z) :precision binary64 (fma (- 1.0 x) y (* x z)))
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((1.0 - x), y, (x * z));
}
function code(x, y, z)
	return Float64(Float64(Float64(1.0 - x) * y) + Float64(x * z))
end
function code(x, y, z)
	return fma(Float64(1.0 - x), y, Float64(x * z))
end
code[x_, y_, z_] := N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] + N[(x * z), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(N[(1.0 - x), $MachinePrecision] * y + N[(x * z), $MachinePrecision]), $MachinePrecision]
\left(1 - x\right) \cdot y + x \cdot z
\mathsf{fma}\left(1 - x, y, x \cdot z\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(1 - x, y, x \cdot z\right)} \]
  3. Final simplification0.0

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

Alternatives

Alternative 1
Error25.5
Cost916
\[\begin{array}{l} t_0 := x \cdot \left(-y\right)\\ \mathbf{if}\;x \leq -2.5 \cdot 10^{+102}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;x \leq -76.55260091418698:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -4.0873565926724834 \cdot 10^{-125}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;x \leq 1.7961782705043693 \cdot 10^{-89}:\\ \;\;\;\;y\\ \mathbf{elif}\;x \leq 7.169444529973968 \cdot 10^{+19}:\\ \;\;\;\;x \cdot z\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error12.0
Cost716
\[\begin{array}{l} t_0 := y + x \cdot z\\ t_1 := x \cdot \left(-y\right)\\ \mathbf{if}\;x \leq -9.5 \cdot 10^{+96}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -76.55260091418698:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 7.169444529973968 \cdot 10^{+19}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error9.0
Cost584
\[\begin{array}{l} t_0 := y - x \cdot y\\ \mathbf{if}\;y \leq -594893.0191040874:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 5.0943697288809915 \cdot 10^{+101}:\\ \;\;\;\;y + x \cdot z\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error1.5
Cost584
\[\begin{array}{l} t_0 := x \cdot \left(z - y\right)\\ \mathbf{if}\;x \leq -76.55260091418698:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 4.801897650124731 \cdot 10^{-28}:\\ \;\;\;\;y + x \cdot z\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error1.5
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -76.55260091418698:\\ \;\;\;\;x \cdot z - x \cdot y\\ \mathbf{elif}\;x \leq 4.801897650124731 \cdot 10^{-28}:\\ \;\;\;\;y + x \cdot z\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(z - y\right)\\ \end{array} \]
Alternative 6
Error25.6
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -4.0873565926724834 \cdot 10^{-125}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;x \leq 1.7961782705043693 \cdot 10^{-89}:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;x \cdot z\\ \end{array} \]
Alternative 7
Error0.0
Cost448
\[y + x \cdot \left(z - y\right) \]
Alternative 8
Error34.7
Cost64
\[y \]

Error

Reproduce

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