Average Error: 0.0 → 0.0
Time: 12.8s
Precision: 64
\[x \cdot y + z \cdot \left(1 - y\right)\]
\[\mathsf{fma}\left(1, z, x \cdot y\right) + \left(-y\right) \cdot z\]
x \cdot y + z \cdot \left(1 - y\right)
\mathsf{fma}\left(1, z, x \cdot y\right) + \left(-y\right) \cdot z
double f(double x, double y, double z) {
        double r26354725 = x;
        double r26354726 = y;
        double r26354727 = r26354725 * r26354726;
        double r26354728 = z;
        double r26354729 = 1.0;
        double r26354730 = r26354729 - r26354726;
        double r26354731 = r26354728 * r26354730;
        double r26354732 = r26354727 + r26354731;
        return r26354732;
}

double f(double x, double y, double z) {
        double r26354733 = 1.0;
        double r26354734 = z;
        double r26354735 = x;
        double r26354736 = y;
        double r26354737 = r26354735 * r26354736;
        double r26354738 = fma(r26354733, r26354734, r26354737);
        double r26354739 = -r26354736;
        double r26354740 = r26354739 * r26354734;
        double r26354741 = r26354738 + r26354740;
        return r26354741;
}

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. Using strategy rm
  3. Applied sub-neg0.0

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

    \[\leadsto x \cdot y + \color{blue}{\left(z \cdot 1 + z \cdot \left(-y\right)\right)}\]
  5. Applied associate-+r+0.0

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

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

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

Reproduce

herbie shell --seed 2019172 +o rules:numerics
(FPCore (x y z)
  :name "Diagrams.TwoD.Segment:bezierClip from diagrams-lib-1.3.0.3"

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

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