Average Error: 6.5 → 1.1
Time: 19.4s
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 6.92785629516221491 \cdot 10^{-263} \lor \neg \left(x + \frac{\left(y - x\right) \cdot z}{t} \le 1.75952401416843627 \cdot 10^{307}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y - x, 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} \le 6.92785629516221491 \cdot 10^{-263} \lor \neg \left(x + \frac{\left(y - x\right) \cdot z}{t} \le 1.75952401416843627 \cdot 10^{307}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y - x, 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 r585550 = x;
        double r585551 = y;
        double r585552 = r585551 - r585550;
        double r585553 = z;
        double r585554 = r585552 * r585553;
        double r585555 = t;
        double r585556 = r585554 / r585555;
        double r585557 = r585550 + r585556;
        return r585557;
}

double f(double x, double y, double z, double t) {
        double r585558 = x;
        double r585559 = y;
        double r585560 = r585559 - r585558;
        double r585561 = z;
        double r585562 = r585560 * r585561;
        double r585563 = t;
        double r585564 = r585562 / r585563;
        double r585565 = r585558 + r585564;
        double r585566 = 6.927856295162215e-263;
        bool r585567 = r585565 <= r585566;
        double r585568 = 1.7595240141684363e+307;
        bool r585569 = r585565 <= r585568;
        double r585570 = !r585569;
        bool r585571 = r585567 || r585570;
        double r585572 = r585561 / r585563;
        double r585573 = fma(r585572, r585560, r585558);
        double r585574 = r585571 ? r585573 : r585565;
        return r585574;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.5
Target1.8
Herbie1.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 (/ (* (- y x) z) t)) < 6.927856295162215e-263 or 1.7595240141684363e+307 < (+ x (/ (* (- y x) z) t))

    1. Initial program 11.3

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

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

      \[\leadsto \color{blue}{\frac{y - x}{t} \cdot z + x}\]
    5. Simplified1.5

      \[\leadsto \color{blue}{\frac{y - x}{\frac{t}{z}}} + x\]
    6. Using strategy rm
    7. Applied clear-num1.5

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

      \[\leadsto \frac{1}{\frac{\frac{t}{z}}{y - x}} + \color{blue}{1 \cdot x}\]
    10. Applied *-un-lft-identity1.5

      \[\leadsto \color{blue}{1 \cdot \frac{1}{\frac{\frac{t}{z}}{y - x}}} + 1 \cdot x\]
    11. Applied distribute-lft-out1.5

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

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

    if 6.927856295162215e-263 < (+ x (/ (* (- y x) z) t)) < 1.7595240141684363e+307

    1. Initial program 0.5

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

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

Reproduce

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