Average Error: 0.0 → 0.0
Time: 9.7s
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 r387853 = x;
        double r387854 = y;
        double r387855 = r387853 * r387854;
        double r387856 = z;
        double r387857 = 1.0;
        double r387858 = r387857 - r387854;
        double r387859 = r387856 * r387858;
        double r387860 = r387855 + r387859;
        return r387860;
}

double f(double x, double y, double z) {
        double r387861 = z;
        double r387862 = 1.0;
        double r387863 = x;
        double r387864 = r387863 - r387861;
        double r387865 = y;
        double r387866 = r387864 * r387865;
        double r387867 = fma(r387861, r387862, r387866);
        return r387867;
}

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