Average Error: 0.0 → 0.0
Time: 1.7s
Precision: 64
\[\left(1 - x\right) \cdot y + x \cdot z\]
\[\mathsf{fma}\left(z, x, y \cdot 1 + y \cdot \left(-x\right)\right)\]
\left(1 - x\right) \cdot y + x \cdot z
\mathsf{fma}\left(z, x, y \cdot 1 + y \cdot \left(-x\right)\right)
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(z, x, ((y * 1.0) + (y * -x)));
}

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

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. Using strategy rm
  3. Applied add-sqr-sqrt31.9

    \[\leadsto \left(1 - x\right) \cdot \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right)} + x \cdot z\]
  4. Applied associate-*r*31.9

    \[\leadsto \color{blue}{\left(\left(1 - x\right) \cdot \sqrt{y}\right) \cdot \sqrt{y}} + x \cdot z\]
  5. Taylor expanded around 0 0.0

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(z, x, y \cdot \left(1 - x\right)\right)}\]
  7. Using strategy rm
  8. Applied sub-neg0.0

    \[\leadsto \mathsf{fma}\left(z, x, y \cdot \color{blue}{\left(1 + \left(-x\right)\right)}\right)\]
  9. Applied distribute-lft-in0.0

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

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

Reproduce

herbie shell --seed 2020105 +o rules:numerics
(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 x) y) (* x z)))