?

Average Error: 0.0 → 0.0
Time: 30.5s
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
Error23.8
Cost1312
\[\begin{array}{l} t_0 := -y \cdot x\\ \mathbf{if}\;x \leq -8.6 \cdot 10^{+70}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq -2.3 \cdot 10^{+35}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -3.7 \cdot 10^{-12}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-90}:\\ \;\;\;\;y\\ \mathbf{elif}\;x \leq 4.8 \cdot 10^{-71}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq 3 \cdot 10^{-35}:\\ \;\;\;\;y\\ \mathbf{elif}\;x \leq 1.76 \cdot 10^{+102}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq 1.85 \cdot 10^{+179}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;z \cdot x\\ \end{array} \]
Alternative 2
Error13.4
Cost848
\[\begin{array}{l} t_0 := \left(z - y\right) \cdot x\\ \mathbf{if}\;x \leq -2.05 \cdot 10^{+20}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 3.2 \cdot 10^{-90}:\\ \;\;\;\;y \cdot \left(1 - x\right)\\ \mathbf{elif}\;x \leq 4.8 \cdot 10^{-71}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{-35}:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error23.9
Cost720
\[\begin{array}{l} \mathbf{if}\;x \leq -7.8 \cdot 10^{-13}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{-90}:\\ \;\;\;\;y\\ \mathbf{elif}\;x \leq 5.9 \cdot 10^{-71}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq 2.2 \cdot 10^{-35}:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;z \cdot x\\ \end{array} \]
Alternative 4
Error18.4
Cost584
\[\begin{array}{l} \mathbf{if}\;z \leq -2.25 \cdot 10^{-21}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;z \leq 2.75 \cdot 10^{+69}:\\ \;\;\;\;y \cdot \left(1 - x\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot x\\ \end{array} \]
Alternative 5
Error0.0
Cost576
\[\left(1 - x\right) \cdot y + x \cdot z \]
Alternative 6
Error35.0
Cost64
\[y \]

Error

Reproduce?

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