Average Error: 0.0 → 0.0
Time: 10.5s
Precision: 64
\[x \cdot y + z \cdot \left(1 - y\right)\]
\[\mathsf{fma}\left(x, y, 1 \cdot z + z \cdot \left(-y\right)\right)\]
x \cdot y + z \cdot \left(1 - y\right)
\mathsf{fma}\left(x, y, 1 \cdot z + z \cdot \left(-y\right)\right)
double f(double x, double y, double z) {
        double r873621 = x;
        double r873622 = y;
        double r873623 = r873621 * r873622;
        double r873624 = z;
        double r873625 = 1.0;
        double r873626 = r873625 - r873622;
        double r873627 = r873624 * r873626;
        double r873628 = r873623 + r873627;
        return r873628;
}

double f(double x, double y, double z) {
        double r873629 = x;
        double r873630 = y;
        double r873631 = 1.0;
        double r873632 = z;
        double r873633 = r873631 * r873632;
        double r873634 = -r873630;
        double r873635 = r873632 * r873634;
        double r873636 = r873633 + r873635;
        double r873637 = fma(r873629, r873630, r873636);
        return r873637;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

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. Simplified0.0

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

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

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

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

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

Reproduce

herbie shell --seed 2019305 +o rules:numerics
(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 y))))