Average Error: 6.4 → 2.1
Time: 3.2s
Precision: 64
\[x + \frac{\left(y - x\right) \cdot z}{t}\]
\[\begin{array}{l} \mathbf{if}\;x \le -2.7932208206939209 \cdot 10^{-119} \lor \neg \left(x \le 1.849643447572145 \cdot 10^{-145}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y - x, x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{\frac{t}{y - x}} + x\\ \end{array}\]
x + \frac{\left(y - x\right) \cdot z}{t}
\begin{array}{l}
\mathbf{if}\;x \le -2.7932208206939209 \cdot 10^{-119} \lor \neg \left(x \le 1.849643447572145 \cdot 10^{-145}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y - x, x\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{z}{\frac{t}{y - x}} + x\\

\end{array}
double f(double x, double y, double z, double t) {
        double r444294 = x;
        double r444295 = y;
        double r444296 = r444295 - r444294;
        double r444297 = z;
        double r444298 = r444296 * r444297;
        double r444299 = t;
        double r444300 = r444298 / r444299;
        double r444301 = r444294 + r444300;
        return r444301;
}

double f(double x, double y, double z, double t) {
        double r444302 = x;
        double r444303 = -2.793220820693921e-119;
        bool r444304 = r444302 <= r444303;
        double r444305 = 1.849643447572145e-145;
        bool r444306 = r444302 <= r444305;
        double r444307 = !r444306;
        bool r444308 = r444304 || r444307;
        double r444309 = z;
        double r444310 = t;
        double r444311 = r444309 / r444310;
        double r444312 = y;
        double r444313 = r444312 - r444302;
        double r444314 = fma(r444311, r444313, r444302);
        double r444315 = r444310 / r444313;
        double r444316 = r444309 / r444315;
        double r444317 = r444316 + r444302;
        double r444318 = r444308 ? r444314 : r444317;
        return r444318;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.4
Target2.1
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 2 regimes
  2. if x < -2.793220820693921e-119 or 1.849643447572145e-145 < x

    1. Initial program 6.8

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{t}{y - x}} \cdot z + x}\]
    7. Simplified6.8

      \[\leadsto \color{blue}{\frac{z}{\frac{t}{y - x}}} + x\]
    8. Using strategy rm
    9. Applied associate-/r/0.7

      \[\leadsto \color{blue}{\frac{z}{t} \cdot \left(y - x\right)} + x\]
    10. Applied fma-def0.7

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

    if -2.793220820693921e-119 < x < 1.849643447572145e-145

    1. Initial program 5.5

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{t}{y - x}} \cdot z + x}\]
    7. Simplified5.1

      \[\leadsto \color{blue}{\frac{z}{\frac{t}{y - x}}} + x\]
  3. Recombined 2 regimes into one program.
  4. Final simplification2.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -2.7932208206939209 \cdot 10^{-119} \lor \neg \left(x \le 1.849643447572145 \cdot 10^{-145}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y - x, x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{\frac{t}{y - x}} + x\\ \end{array}\]

Reproduce

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