Average Error: 7.4 → 2.3
Time: 18.0s
Precision: 64
\[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}\]
\[\frac{\mathsf{fma}\left(\frac{z}{z \cdot t - x}, y, x\right) - \frac{x}{z \cdot t - x}}{x + 1}\]
\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}
\frac{\mathsf{fma}\left(\frac{z}{z \cdot t - x}, y, x\right) - \frac{x}{z \cdot t - x}}{x + 1}
double f(double x, double y, double z, double t) {
        double r419689 = x;
        double r419690 = y;
        double r419691 = z;
        double r419692 = r419690 * r419691;
        double r419693 = r419692 - r419689;
        double r419694 = t;
        double r419695 = r419694 * r419691;
        double r419696 = r419695 - r419689;
        double r419697 = r419693 / r419696;
        double r419698 = r419689 + r419697;
        double r419699 = 1.0;
        double r419700 = r419689 + r419699;
        double r419701 = r419698 / r419700;
        return r419701;
}

double f(double x, double y, double z, double t) {
        double r419702 = z;
        double r419703 = t;
        double r419704 = r419702 * r419703;
        double r419705 = x;
        double r419706 = r419704 - r419705;
        double r419707 = r419702 / r419706;
        double r419708 = y;
        double r419709 = fma(r419707, r419708, r419705);
        double r419710 = r419705 / r419706;
        double r419711 = r419709 - r419710;
        double r419712 = 1.0;
        double r419713 = r419705 + r419712;
        double r419714 = r419711 / r419713;
        return r419714;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original7.4
Target0.3
Herbie2.3
\[\frac{x + \left(\frac{y}{t - \frac{x}{z}} - \frac{x}{t \cdot z - x}\right)}{x + 1}\]

Derivation

  1. Initial program 7.4

    \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}\]
  2. Simplified7.4

    \[\leadsto \color{blue}{\frac{x + \frac{z \cdot y - x}{z \cdot t - x}}{1 + x}}\]
  3. Using strategy rm
  4. Applied div-sub7.4

    \[\leadsto \frac{x + \color{blue}{\left(\frac{z \cdot y}{z \cdot t - x} - \frac{x}{z \cdot t - x}\right)}}{1 + x}\]
  5. Applied associate-+r-7.4

    \[\leadsto \frac{\color{blue}{\left(x + \frac{z \cdot y}{z \cdot t - x}\right) - \frac{x}{z \cdot t - x}}}{1 + x}\]
  6. Simplified2.3

    \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{z}{t \cdot z - x}, y, x\right)} - \frac{x}{z \cdot t - x}}{1 + x}\]
  7. Final simplification2.3

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

Reproduce

herbie shell --seed 2019196 +o rules:numerics
(FPCore (x y z t)
  :name "Diagrams.Trail:splitAtParam  from diagrams-lib-1.3.0.3, A"

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

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