Average Error: 0.0 → 0.0
Time: 7.2s
Precision: 64
\[x \cdot y + z \cdot \left(1 - y\right)\]
\[\mathsf{fma}\left(y, x - z, 1 \cdot z\right)\]
x \cdot y + z \cdot \left(1 - y\right)
\mathsf{fma}\left(y, x - z, 1 \cdot z\right)
double f(double x, double y, double z) {
        double r754025 = x;
        double r754026 = y;
        double r754027 = r754025 * r754026;
        double r754028 = z;
        double r754029 = 1.0;
        double r754030 = r754029 - r754026;
        double r754031 = r754028 * r754030;
        double r754032 = r754027 + r754031;
        return r754032;
}

double f(double x, double y, double z) {
        double r754033 = y;
        double r754034 = x;
        double r754035 = z;
        double r754036 = r754034 - r754035;
        double r754037 = 1.0;
        double r754038 = r754037 * r754035;
        double r754039 = fma(r754033, r754036, r754038);
        return r754039;
}

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(y, x - z, 1 \cdot z\right)}\]
  5. Final simplification0.0

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

Reproduce

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