Average Error: 0.0 → 0.0
Time: 4.3s
Precision: binary64
Cost: 6848
\[x \cdot y + z \cdot \left(1 - y\right) \]
\[\mathsf{fma}\left(y, x, z \cdot \left(1 - y\right)\right) \]
(FPCore (x y z) :precision binary64 (+ (* x y) (* z (- 1.0 y))))
(FPCore (x y z) :precision binary64 (fma y x (* z (- 1.0 y))))
double code(double x, double y, double z) {
	return (x * y) + (z * (1.0 - y));
}
double code(double x, double y, double z) {
	return fma(y, x, (z * (1.0 - y)));
}
function code(x, y, z)
	return Float64(Float64(x * y) + Float64(z * Float64(1.0 - y)))
end
function code(x, y, z)
	return fma(y, x, Float64(z * Float64(1.0 - y)))
end
code[x_, y_, z_] := N[(N[(x * y), $MachinePrecision] + N[(z * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(y * x + N[(z * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x \cdot y + z \cdot \left(1 - y\right)
\mathsf{fma}\left(y, x, z \cdot \left(1 - y\right)\right)

Error

Target

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

Derivation

  1. Initial program 0.0

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

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

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

Alternatives

Alternative 1
Error0.0
Cost6720
\[\mathsf{fma}\left(y, x - z, z\right) \]
Alternative 2
Error12.9
Cost848
\[\begin{array}{l} t_0 := z + y \cdot x\\ t_1 := y \cdot \left(-z\right)\\ \mathbf{if}\;x \leq -3.485907065575079 \cdot 10^{-305}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 8.846628928109563 \cdot 10^{-248}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 5.331077846216749 \cdot 10^{-139}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 5.913783495717284 \cdot 10^{-126}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error25.2
Cost784
\[\begin{array}{l} \mathbf{if}\;z \leq -2.7324815573128564 \cdot 10^{-29}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq 5.883759852816575 \cdot 10^{-81}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;z \leq 8233723313584718000:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq 5.5 \cdot 10^{+85}:\\ \;\;\;\;y \cdot \left(-z\right)\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
Alternative 4
Error1.5
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -2.4322714825880966 \cdot 10^{+23}:\\ \;\;\;\;y \cdot \left(x - z\right)\\ \mathbf{elif}\;y \leq 1.2286726023738117 \cdot 10^{-10}:\\ \;\;\;\;z + y \cdot x\\ \mathbf{else}:\\ \;\;\;\;y \cdot x - y \cdot z\\ \end{array} \]
Alternative 5
Error1.5
Cost584
\[\begin{array}{l} t_0 := y \cdot \left(x - z\right)\\ \mathbf{if}\;y \leq -2.4322714825880966 \cdot 10^{+23}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.2286726023738117 \cdot 10^{-10}:\\ \;\;\;\;z + y \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error0.0
Cost576
\[z \cdot \left(1 - y\right) + y \cdot x \]
Alternative 7
Error24.3
Cost456
\[\begin{array}{l} \mathbf{if}\;z \leq -2.7324815573128564 \cdot 10^{-29}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq 5.883759852816575 \cdot 10^{-81}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
Alternative 8
Error0.0
Cost448
\[z + y \cdot \left(x - z\right) \]
Alternative 9
Error34.8
Cost64
\[z \]

Error

Reproduce

herbie shell --seed 2022294 
(FPCore (x y z)
  :name "Diagrams.TwoD.Segment:bezierClip from diagrams-lib-1.3.0.3"
  :precision binary64

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

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