Average Error: 6.3 → 2.3
Time: 14.4s
Precision: 64
\[x + \frac{\left(y - x\right) \cdot z}{t}\]
\[\mathsf{fma}\left(\frac{z}{t}, y - x, x\right)\]
x + \frac{\left(y - x\right) \cdot z}{t}
\mathsf{fma}\left(\frac{z}{t}, y - x, x\right)
double f(double x, double y, double z, double t) {
        double r563319 = x;
        double r563320 = y;
        double r563321 = r563320 - r563319;
        double r563322 = z;
        double r563323 = r563321 * r563322;
        double r563324 = t;
        double r563325 = r563323 / r563324;
        double r563326 = r563319 + r563325;
        return r563326;
}

double f(double x, double y, double z, double t) {
        double r563327 = z;
        double r563328 = t;
        double r563329 = r563327 / r563328;
        double r563330 = y;
        double r563331 = x;
        double r563332 = r563330 - r563331;
        double r563333 = fma(r563329, r563332, r563331);
        return r563333;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.3
Target2.2
Herbie2.3
\[\begin{array}{l} \mathbf{if}\;x \lt -9.025511195533004570453352523209034680317 \cdot 10^{-135}:\\ \;\;\;\;x - \frac{z}{t} \cdot \left(x - y\right)\\ \mathbf{elif}\;x \lt 4.275032163700714748507147332551979944314 \cdot 10^{-250}:\\ \;\;\;\;x + \frac{y - x}{t} \cdot z\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \end{array}\]

Derivation

  1. Initial program 6.3

    \[x + \frac{\left(y - x\right) \cdot z}{t}\]
  2. Simplified6.3

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y - x}{t}, z, x\right)}\]
  3. Using strategy rm
  4. Applied div-sub6.3

    \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{y}{t} - \frac{x}{t}}, z, x\right)\]
  5. Using strategy rm
  6. Applied div-inv6.3

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

    \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(y, \frac{1}{t}, -\frac{x}{t}\right)}, z, x\right)\]
  8. Taylor expanded around inf 6.3

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

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

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

Reproduce

herbie shell --seed 2019351 +o rules:numerics
(FPCore (x y z t)
  :name "Numeric.Histogram:binBounds from Chart-1.5.3"
  :precision binary64

  :herbie-target
  (if (< x -9.025511195533005e-135) (- x (* (/ z t) (- x y))) (if (< x 4.275032163700715e-250) (+ x (* (/ (- y x) t) z)) (+ x (/ (- y x) (/ t z)))))

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