Average Error: 0.0 → 0
Time: 2.1s
Precision: 64
\[x - y \cdot z\]
\[\mathsf{fma}\left(z, -y, x\right)\]
x - y \cdot z
\mathsf{fma}\left(z, -y, x\right)
double f(double x, double y, double z) {
        double r749122 = x;
        double r749123 = y;
        double r749124 = z;
        double r749125 = r749123 * r749124;
        double r749126 = r749122 - r749125;
        return r749126;
}

double f(double x, double y, double z) {
        double r749127 = z;
        double r749128 = y;
        double r749129 = -r749128;
        double r749130 = x;
        double r749131 = fma(r749127, r749129, r749130);
        return r749131;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original0.0
Target0.0
Herbie0
\[\frac{x + y \cdot z}{\frac{x + y \cdot z}{x - y \cdot z}}\]

Derivation

  1. Initial program 0.0

    \[x - y \cdot z\]
  2. Taylor expanded around inf 0.0

    \[\leadsto \color{blue}{x - z \cdot y}\]
  3. Simplified0

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

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

Reproduce

herbie shell --seed 2020046 +o rules:numerics
(FPCore (x y z)
  :name "Diagrams.Solve.Tridiagonal:solveTriDiagonal from diagrams-solve-0.1, C"
  :precision binary64

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

  (- x (* y z)))