Average Error: 0.0 → 0.0
Time: 5.0s
Precision: 64
\[x \cdot y + z \cdot \left(1 - y\right)\]
\[\mathsf{fma}\left(x, y, 1 \cdot z + \left(-y\right) \cdot z\right)\]
x \cdot y + z \cdot \left(1 - y\right)
\mathsf{fma}\left(x, y, 1 \cdot z + \left(-y\right) \cdot z\right)
double f(double x, double y, double z) {
        double r860603 = x;
        double r860604 = y;
        double r860605 = r860603 * r860604;
        double r860606 = z;
        double r860607 = 1.0;
        double r860608 = r860607 - r860604;
        double r860609 = r860606 * r860608;
        double r860610 = r860605 + r860609;
        return r860610;
}

double f(double x, double y, double z) {
        double r860611 = x;
        double r860612 = y;
        double r860613 = 1.0;
        double r860614 = z;
        double r860615 = r860613 * r860614;
        double r860616 = -r860612;
        double r860617 = r860616 * r860614;
        double r860618 = r860615 + r860617;
        double r860619 = fma(r860611, r860612, r860618);
        return r860619;
}

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-lft-in0.0

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

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

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

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

Reproduce

herbie shell --seed 2020042 +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))))