Average Error: 0.0 → 0.0
Time: 17.8s
Precision: 64
\[\left(1 - x\right) \cdot y + x \cdot z\]
\[\mathsf{fma}\left(x, z, \left(1 - x\right) \cdot y\right)\]
\left(1 - x\right) \cdot y + x \cdot z
\mathsf{fma}\left(x, z, \left(1 - x\right) \cdot y\right)
double f(double x, double y, double z) {
        double r47647354 = 1.0;
        double r47647355 = x;
        double r47647356 = r47647354 - r47647355;
        double r47647357 = y;
        double r47647358 = r47647356 * r47647357;
        double r47647359 = z;
        double r47647360 = r47647355 * r47647359;
        double r47647361 = r47647358 + r47647360;
        return r47647361;
}

double f(double x, double y, double z) {
        double r47647362 = x;
        double r47647363 = z;
        double r47647364 = 1.0;
        double r47647365 = r47647364 - r47647362;
        double r47647366 = y;
        double r47647367 = r47647365 * r47647366;
        double r47647368 = fma(r47647362, r47647363, r47647367);
        return r47647368;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original0.0
Target0.0
Herbie0.0
\[y - x \cdot \left(y - z\right)\]

Derivation

  1. Initial program 0.0

    \[\left(1 - x\right) \cdot y + x \cdot z\]
  2. Simplified0.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(1 - x, y, x \cdot z\right)}\]
  3. Using strategy rm
  4. Applied add-sqr-sqrt32.2

    \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(1 - x, y, x \cdot z\right)} \cdot \sqrt{\mathsf{fma}\left(1 - x, y, x \cdot z\right)}}\]
  5. Using strategy rm
  6. Applied *-un-lft-identity32.2

    \[\leadsto \sqrt{\mathsf{fma}\left(1 - x, y, x \cdot z\right)} \cdot \sqrt{\color{blue}{1 \cdot \mathsf{fma}\left(1 - x, y, x \cdot z\right)}}\]
  7. Applied sqrt-prod32.2

    \[\leadsto \sqrt{\mathsf{fma}\left(1 - x, y, x \cdot z\right)} \cdot \color{blue}{\left(\sqrt{1} \cdot \sqrt{\mathsf{fma}\left(1 - x, y, x \cdot z\right)}\right)}\]
  8. Applied *-un-lft-identity32.2

    \[\leadsto \sqrt{\color{blue}{1 \cdot \mathsf{fma}\left(1 - x, y, x \cdot z\right)}} \cdot \left(\sqrt{1} \cdot \sqrt{\mathsf{fma}\left(1 - x, y, x \cdot z\right)}\right)\]
  9. Applied sqrt-prod32.2

    \[\leadsto \color{blue}{\left(\sqrt{1} \cdot \sqrt{\mathsf{fma}\left(1 - x, y, x \cdot z\right)}\right)} \cdot \left(\sqrt{1} \cdot \sqrt{\mathsf{fma}\left(1 - x, y, x \cdot z\right)}\right)\]
  10. Applied swap-sqr32.2

    \[\leadsto \color{blue}{\left(\sqrt{1} \cdot \sqrt{1}\right) \cdot \left(\sqrt{\mathsf{fma}\left(1 - x, y, x \cdot z\right)} \cdot \sqrt{\mathsf{fma}\left(1 - x, y, x \cdot z\right)}\right)}\]
  11. Simplified32.2

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

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

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

Reproduce

herbie shell --seed 2019174 +o rules:numerics
(FPCore (x y z)
  :name "Diagrams.Color.HSV:lerp  from diagrams-contrib-1.3.0.5"

  :herbie-target
  (- y (* x (- y z)))

  (+ (* (- 1.0 x) y) (* x z)))