Average Error: 0.0 → 0.0
Time: 9.0s
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. Simplified0.0

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

Alternatives

Alternative 1
Error0.0
Cost6848
\[\mathsf{fma}\left(z, x, \left(1 - x\right) \cdot y\right) \]
Alternative 2
Error22.8
Cost1312
\[\begin{array}{l} t_0 := -y \cdot x\\ \mathbf{if}\;x \leq -4.8 \cdot 10^{+156}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq -3.3 \cdot 10^{+39}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -7 \cdot 10^{-72}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq 1.02 \cdot 10^{-16}:\\ \;\;\;\;y\\ \mathbf{elif}\;x \leq 3.3 \cdot 10^{+28}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq 2.2 \cdot 10^{+70}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 8.2 \cdot 10^{+135}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq 2.5 \cdot 10^{+255}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;z \cdot x\\ \end{array} \]
Alternative 3
Error17.1
Cost848
\[\begin{array}{l} t_0 := \left(1 - x\right) \cdot y\\ \mathbf{if}\;y \leq -1.16 \cdot 10^{-16}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -5.8 \cdot 10^{-127}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;y \leq -1.15 \cdot 10^{-168}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 9.8 \cdot 10^{-113}:\\ \;\;\;\;z \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error12.2
Cost584
\[\begin{array}{l} t_0 := \left(z - y\right) \cdot x\\ \mathbf{if}\;x \leq -5.2 \cdot 10^{-72}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 4.2 \cdot 10^{-9}:\\ \;\;\;\;\left(1 - x\right) \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error0.0
Cost576
\[\left(1 - x\right) \cdot y + x \cdot z \]
Alternative 6
Error23.4
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -7 \cdot 10^{-72}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq 7.2 \cdot 10^{-12}:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;z \cdot x\\ \end{array} \]
Alternative 7
Error34.3
Cost64
\[y \]

Error

Reproduce

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