Average Error: 0.0 → 0.0
Time: 8.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 r385157 = x;
        double r385158 = y;
        double r385159 = r385157 * r385158;
        double r385160 = z;
        double r385161 = 1.0;
        double r385162 = r385161 - r385158;
        double r385163 = r385160 * r385162;
        double r385164 = r385159 + r385163;
        return r385164;
}

double f(double x, double y, double z) {
        double r385165 = x;
        double r385166 = y;
        double r385167 = 1.0;
        double r385168 = z;
        double r385169 = r385167 * r385168;
        double r385170 = -r385166;
        double r385171 = r385168 * r385170;
        double r385172 = r385169 + r385171;
        double r385173 = fma(r385165, r385166, r385172);
        return r385173;
}

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