Average Error: 0.0 → 0.0
Time: 10.3s
Precision: 64
\[x \cdot y + z \cdot \left(1 - y\right)\]
\[\mathsf{fma}\left(z, 1, \left(x - z\right) \cdot y\right)\]
x \cdot y + z \cdot \left(1 - y\right)
\mathsf{fma}\left(z, 1, \left(x - z\right) \cdot y\right)
double f(double x, double y, double z) {
        double r27899732 = x;
        double r27899733 = y;
        double r27899734 = r27899732 * r27899733;
        double r27899735 = z;
        double r27899736 = 1.0;
        double r27899737 = r27899736 - r27899733;
        double r27899738 = r27899735 * r27899737;
        double r27899739 = r27899734 + r27899738;
        return r27899739;
}

double f(double x, double y, double z) {
        double r27899740 = z;
        double r27899741 = 1.0;
        double r27899742 = x;
        double r27899743 = r27899742 - r27899740;
        double r27899744 = y;
        double r27899745 = r27899743 * r27899744;
        double r27899746 = fma(r27899740, r27899741, r27899745);
        return r27899746;
}

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. Taylor expanded around 0 0.0

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

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

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

Reproduce

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