Average Error: 6.4 → 1.0
Time: 2.7s
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:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{\frac{t}{y - x}}, z, x\right)\\ \mathbf{elif}\;x + \frac{\left(y - x\right) \cdot z}{t} \le 2.595832591399591 \cdot 10^{223}:\\ \;\;\;\;x + \frac{\left(y - x\right) \cdot z}{t}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x - \frac{1}{\frac{\frac{t}{z}}{x}}\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} = -\infty:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{\frac{t}{y - x}}, z, x\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r468538 = x;
        double r468539 = y;
        double r468540 = r468539 - r468538;
        double r468541 = z;
        double r468542 = r468540 * r468541;
        double r468543 = t;
        double r468544 = r468542 / r468543;
        double r468545 = r468538 + r468544;
        return r468545;
}

double f(double x, double y, double z, double t) {
        double r468546 = x;
        double r468547 = y;
        double r468548 = r468547 - r468546;
        double r468549 = z;
        double r468550 = r468548 * r468549;
        double r468551 = t;
        double r468552 = r468550 / r468551;
        double r468553 = r468546 + r468552;
        double r468554 = -inf.0;
        bool r468555 = r468553 <= r468554;
        double r468556 = 1.0;
        double r468557 = r468551 / r468548;
        double r468558 = r468556 / r468557;
        double r468559 = fma(r468558, r468549, r468546);
        double r468560 = 2.595832591399591e+223;
        bool r468561 = r468553 <= r468560;
        double r468562 = r468549 / r468551;
        double r468563 = r468551 / r468549;
        double r468564 = r468563 / r468546;
        double r468565 = r468556 / r468564;
        double r468566 = r468546 - r468565;
        double r468567 = fma(r468562, r468547, r468566);
        double r468568 = r468561 ? r468553 : r468567;
        double r468569 = r468555 ? r468559 : r468568;
        return r468569;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.4
Target2.1
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 3 regimes
  2. if (+ x (/ (* (- y x) z) t)) < -inf.0

    1. Initial program 64.0

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

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

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

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

    1. Initial program 0.8

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

    if 2.595832591399591e+223 < (+ x (/ (* (- y x) z) t))

    1. Initial program 23.0

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

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

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

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

      \[\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.4

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

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

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

Reproduce

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