Average Error: 6.6 → 2.1
Time: 2.6s
Precision: 64
\[x + \frac{\left(y - x\right) \cdot z}{t}\]
\[\begin{array}{l} \mathbf{if}\;x + \frac{\left(y - x\right) \cdot z}{t} \le -4.8678966988149982 \cdot 10^{264}:\\ \;\;\;\;\mathsf{fma}\left(\left(y - x\right) \cdot \frac{1}{t}, z, x\right)\\ \mathbf{elif}\;x + \frac{\left(y - x\right) \cdot z}{t} \le -6.8477009412007924 \cdot 10^{-118}:\\ \;\;\;\;x + \frac{\left(y - x\right) \cdot z}{t}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x - \frac{x}{\frac{t}{z}}\right)\\ \end{array}\]
x + \frac{\left(y - x\right) \cdot z}{t}
\begin{array}{l}
\mathbf{if}\;x + \frac{\left(y - x\right) \cdot z}{t} \le -4.8678966988149982 \cdot 10^{264}:\\
\;\;\;\;\mathsf{fma}\left(\left(y - x\right) \cdot \frac{1}{t}, z, x\right)\\

\mathbf{elif}\;x + \frac{\left(y - x\right) \cdot z}{t} \le -6.8477009412007924 \cdot 10^{-118}:\\
\;\;\;\;x + \frac{\left(y - x\right) \cdot z}{t}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x - \frac{x}{\frac{t}{z}}\right)\\

\end{array}
double f(double x, double y, double z, double t) {
        double r444308 = x;
        double r444309 = y;
        double r444310 = r444309 - r444308;
        double r444311 = z;
        double r444312 = r444310 * r444311;
        double r444313 = t;
        double r444314 = r444312 / r444313;
        double r444315 = r444308 + r444314;
        return r444315;
}

double f(double x, double y, double z, double t) {
        double r444316 = x;
        double r444317 = y;
        double r444318 = r444317 - r444316;
        double r444319 = z;
        double r444320 = r444318 * r444319;
        double r444321 = t;
        double r444322 = r444320 / r444321;
        double r444323 = r444316 + r444322;
        double r444324 = -4.867896698814998e+264;
        bool r444325 = r444323 <= r444324;
        double r444326 = 1.0;
        double r444327 = r444326 / r444321;
        double r444328 = r444318 * r444327;
        double r444329 = fma(r444328, r444319, r444316);
        double r444330 = -6.847700941200792e-118;
        bool r444331 = r444323 <= r444330;
        double r444332 = r444319 / r444321;
        double r444333 = r444321 / r444319;
        double r444334 = r444316 / r444333;
        double r444335 = r444316 - r444334;
        double r444336 = fma(r444332, r444317, r444335);
        double r444337 = r444331 ? r444323 : r444336;
        double r444338 = r444325 ? r444329 : r444337;
        return r444338;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.6
Target1.9
Herbie2.1
\[\begin{array}{l} \mathbf{if}\;x \lt -9.0255111955330046 \cdot 10^{-135}:\\ \;\;\;\;x - \frac{z}{t} \cdot \left(x - y\right)\\ \mathbf{elif}\;x \lt 4.2750321637007147 \cdot 10^{-250}:\\ \;\;\;\;x + \frac{y - x}{t} \cdot z\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if (+ x (/ (* (- y x) z) t)) < -4.867896698814998e+264

    1. Initial program 34.5

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

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

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

    if -4.867896698814998e+264 < (+ x (/ (* (- y x) z) t)) < -6.847700941200792e-118

    1. Initial program 0.3

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

    if -6.847700941200792e-118 < (+ x (/ (* (- y x) z) t))

    1. Initial program 6.3

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{z}{t}, y, x - \frac{x \cdot z}{t}\right)}\]
    7. Using strategy rm
    8. Applied associate-/l*2.0

      \[\leadsto \mathsf{fma}\left(\frac{z}{t}, y, x - \color{blue}{\frac{x}{\frac{t}{z}}}\right)\]
  3. Recombined 3 regimes into one program.
  4. Final simplification2.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + \frac{\left(y - x\right) \cdot z}{t} \le -4.8678966988149982 \cdot 10^{264}:\\ \;\;\;\;\mathsf{fma}\left(\left(y - x\right) \cdot \frac{1}{t}, z, x\right)\\ \mathbf{elif}\;x + \frac{\left(y - x\right) \cdot z}{t} \le -6.8477009412007924 \cdot 10^{-118}:\\ \;\;\;\;x + \frac{\left(y - x\right) \cdot z}{t}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x - \frac{x}{\frac{t}{z}}\right)\\ \end{array}\]

Reproduce

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