Average Error: 6.3 → 1.5
Time: 22.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} = -\infty:\\ \;\;\;\;\mathsf{fma}\left(\frac{y - x}{t}, z, x\right)\\ \mathbf{elif}\;x + \frac{\left(y - x\right) \cdot z}{t} \le -2.398417684101355072336787554272342478967 \cdot 10^{-89}:\\ \;\;\;\;x + \frac{\left(y - x\right) \cdot z}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \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{y - x}{t}, z, x\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r294375 = x;
        double r294376 = y;
        double r294377 = r294376 - r294375;
        double r294378 = z;
        double r294379 = r294377 * r294378;
        double r294380 = t;
        double r294381 = r294379 / r294380;
        double r294382 = r294375 + r294381;
        return r294382;
}

double f(double x, double y, double z, double t) {
        double r294383 = x;
        double r294384 = y;
        double r294385 = r294384 - r294383;
        double r294386 = z;
        double r294387 = r294385 * r294386;
        double r294388 = t;
        double r294389 = r294387 / r294388;
        double r294390 = r294383 + r294389;
        double r294391 = -inf.0;
        bool r294392 = r294390 <= r294391;
        double r294393 = r294385 / r294388;
        double r294394 = fma(r294393, r294386, r294383);
        double r294395 = -2.398417684101355e-89;
        bool r294396 = r294390 <= r294395;
        double r294397 = r294388 / r294386;
        double r294398 = r294385 / r294397;
        double r294399 = r294383 + r294398;
        double r294400 = r294396 ? r294390 : r294399;
        double r294401 = r294392 ? r294394 : r294400;
        return r294401;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.3
Target2.2
Herbie1.5
\[\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. 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. Using strategy rm
    3. Applied *-un-lft-identity64.0

      \[\leadsto \color{blue}{1 \cdot \left(x + \frac{\left(y - x\right) \cdot z}{t}\right)}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity64.0

      \[\leadsto 1 \cdot \left(x + \color{blue}{1 \cdot \frac{\left(y - x\right) \cdot z}{t}}\right)\]
    6. Applied *-un-lft-identity64.0

      \[\leadsto 1 \cdot \left(\color{blue}{1 \cdot x} + 1 \cdot \frac{\left(y - x\right) \cdot z}{t}\right)\]
    7. Applied distribute-lft-out64.0

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

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

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

    1. Initial program 0.2

      \[x + \frac{\left(y - x\right) \cdot z}{t}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity0.2

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

    if -2.398417684101355e-89 < (+ x (/ (* (- y x) z) t))

    1. Initial program 5.7

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

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

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

Reproduce

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