Average Error: 0.0 → 0.0
Time: 9.6s
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 r463010 = x;
        double r463011 = y;
        double r463012 = r463010 * r463011;
        double r463013 = z;
        double r463014 = 1.0;
        double r463015 = r463014 - r463011;
        double r463016 = r463013 * r463015;
        double r463017 = r463012 + r463016;
        return r463017;
}

double f(double x, double y, double z) {
        double r463018 = x;
        double r463019 = y;
        double r463020 = 1.0;
        double r463021 = z;
        double r463022 = r463020 * r463021;
        double r463023 = -r463019;
        double r463024 = r463021 * r463023;
        double r463025 = r463022 + r463024;
        double r463026 = fma(r463018, r463019, r463025);
        return r463026;
}

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 2019198 +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))))