Average Error: 6.7 → 1.0
Time: 15.9s
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} = -\infty \lor \neg \left(x + \frac{\left(y - x\right) \cdot z}{t} \le 7.47453856091499786 \cdot 10^{296}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{y - x}{t}, z, x\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\left(y - x\right) \cdot z}{t}\\ \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} = -\infty \lor \neg \left(x + \frac{\left(y - x\right) \cdot z}{t} \le 7.47453856091499786 \cdot 10^{296}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{y - x}{t}, z, x\right)\\

\mathbf{else}:\\
\;\;\;\;x + \frac{\left(y - x\right) \cdot z}{t}\\

\end{array}
double f(double x, double y, double z, double t) {
        double r560980 = x;
        double r560981 = y;
        double r560982 = r560981 - r560980;
        double r560983 = z;
        double r560984 = r560982 * r560983;
        double r560985 = t;
        double r560986 = r560984 / r560985;
        double r560987 = r560980 + r560986;
        return r560987;
}

double f(double x, double y, double z, double t) {
        double r560988 = x;
        double r560989 = y;
        double r560990 = r560989 - r560988;
        double r560991 = z;
        double r560992 = r560990 * r560991;
        double r560993 = t;
        double r560994 = r560992 / r560993;
        double r560995 = r560988 + r560994;
        double r560996 = -inf.0;
        bool r560997 = r560995 <= r560996;
        double r560998 = 7.474538560914998e+296;
        bool r560999 = r560995 <= r560998;
        double r561000 = !r560999;
        bool r561001 = r560997 || r561000;
        double r561002 = r560990 / r560993;
        double r561003 = fma(r561002, r560991, r560988);
        double r561004 = r561001 ? r561003 : r560995;
        return r561004;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.7
Target2.3
Herbie1.0
\[\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 (/ (* (- y x) z) t)) < -inf.0 or 7.474538560914998e+296 < (+ x (/ (* (- y x) z) t))

    1. Initial program 58.1

      \[x + \frac{\left(y - x\right) \cdot z}{t}\]
    2. Using strategy rm
    3. Applied associate-/l*0.4

      \[\leadsto x + \color{blue}{\frac{y - x}{\frac{t}{z}}}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity0.4

      \[\leadsto x + \color{blue}{1 \cdot \frac{y - x}{\frac{t}{z}}}\]
    6. Applied *-un-lft-identity0.4

      \[\leadsto \color{blue}{1 \cdot x} + 1 \cdot \frac{y - x}{\frac{t}{z}}\]
    7. Applied distribute-lft-out0.4

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

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

    if -inf.0 < (+ x (/ (* (- y x) z) t)) < 7.474538560914998e+296

    1. Initial program 0.8

      \[x + \frac{\left(y - x\right) \cdot z}{t}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.0

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

Reproduce

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