Average Error: 0.0 → 0.0
Time: 2.0min
Precision: binary64
Cost: 576
\[x \cdot y + \left(1 - x\right) \cdot z\]
\[\left(x \cdot y + z\right) - x \cdot z\]
x \cdot y + \left(1 - x\right) \cdot z
\left(x \cdot y + z\right) - x \cdot z
(FPCore (x y z) :precision binary64 (+ (* x y) (* (- 1.0 x) z)))
(FPCore (x y z) :precision binary64 (- (+ (* x y) z) (* x z)))
double code(double x, double y, double z) {
	return (x * y) + ((1.0 - x) * z);
}
double code(double x, double y, double z) {
	return ((x * y) + z) - (x * z);
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Alternatives

Alternative 1
Error0.0
Cost448
\[z - x \cdot \left(z - y\right)\]
Alternative 2
Error0.9
Cost1090
\[\begin{array}{l} \mathbf{if}\;x \leq -1.0203092446224575:\\ \;\;\;\;x \cdot \left(y - z\right)\\ \mathbf{elif}\;x \leq 0.001244767960264407:\\ \;\;\;\;x \cdot y + z\\ \mathbf{else}:\\ \;\;\;\;x \cdot y - x \cdot z\\ \end{array}\]
Alternative 3
Error0.9
Cost648
\[\begin{array}{l} \mathbf{if}\;x \leq -1.0203092446224575 \lor \neg \left(x \leq 0.001244767960264407\right):\\ \;\;\;\;x \cdot \left(y - z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot y + z\\ \end{array}\]
Alternative 4
Error7.1
Cost648
\[\begin{array}{l} \mathbf{if}\;y \leq -3.9688333823953555 \cdot 10^{-173} \lor \neg \left(y \leq 9.203858378917389 \cdot 10^{-118}\right):\\ \;\;\;\;x \cdot y + z\\ \mathbf{else}:\\ \;\;\;\;z - x \cdot z\\ \end{array}\]
Alternative 5
Error15.8
Cost648
\[\begin{array}{l} \mathbf{if}\;z \leq -1.2378780902325995 \cdot 10^{-154} \lor \neg \left(z \leq 1.673818157913548 \cdot 10^{-152}\right):\\ \;\;\;\;z - x \cdot z\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array}\]
Alternative 6
Error24.7
Cost973
\[\begin{array}{l} \mathbf{if}\;z \leq -2.8611145528597853 \cdot 10^{-39}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq -1.0453144994583717 \cdot 10^{-125} \lor \neg \left(z \leq -1.0252448052030216 \cdot 10^{-156}\right) \land z \leq 1.6715378555165724 \cdot 10^{-46}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array}\]
Alternative 7
Error34.6
Cost64
\[z\]

Error

Time

Derivation

  1. Initial program 0.0

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

    \[\leadsto \color{blue}{z + x \cdot \left(y - z\right)}\]
  3. Using strategy rm
  4. Applied sub-neg_binary64_65500.0

    \[\leadsto z + x \cdot \color{blue}{\left(y + \left(-z\right)\right)}\]
  5. Applied distribute-lft-in_binary64_65060.0

    \[\leadsto z + \color{blue}{\left(x \cdot y + x \cdot \left(-z\right)\right)}\]
  6. Applied associate-+r+_binary64_64890.0

    \[\leadsto \color{blue}{\left(z + x \cdot y\right) + x \cdot \left(-z\right)}\]
  7. Using strategy rm
  8. Applied distribute-rgt-neg-out_binary64_65170.0

    \[\leadsto \left(z + x \cdot y\right) + \color{blue}{\left(-x \cdot z\right)}\]
  9. Applied unsub-neg_binary64_65510.0

    \[\leadsto \color{blue}{\left(z + x \cdot y\right) - x \cdot z}\]
  10. Using strategy rm
  11. Applied *-un-lft-identity_binary64_65570.0

    \[\leadsto \color{blue}{1 \cdot \left(\left(z + x \cdot y\right) - x \cdot z\right)}\]
  12. Using strategy rm
  13. Applied +-commutative_binary64_64870.0

    \[\leadsto 1 \cdot \left(\color{blue}{\left(x \cdot y + z\right)} - x \cdot z\right)\]
  14. Simplified0.0

    \[\leadsto \color{blue}{\left(x \cdot y + z\right) - z \cdot x}\]
  15. Final simplification0.0

    \[\leadsto \left(x \cdot y + z\right) - x \cdot z\]

Reproduce

herbie shell --seed 2021040 
(FPCore (x y z)
  :name "Diagrams.Backend.Rasterific:$crender from diagrams-rasterific-1.3.1.3"
  :precision binary64
  (+ (* x y) (* (- 1.0 x) z)))