Average Error: 6.6 → 2.2
Time: 3.4s
Precision: 64
\[x + \frac{\left(y - x\right) \cdot z}{t}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.55799832481955134 \cdot 10^{-261} \lor \neg \left(x \le 1.73611979100849925 \cdot 10^{-107}\right):\\ \;\;\;\;x + \left(y - x\right) \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \mathsf{fma}\left(\frac{y - x}{t}, z, x\right)\\ \end{array}\]
x + \frac{\left(y - x\right) \cdot z}{t}
\begin{array}{l}
\mathbf{if}\;x \le -1.55799832481955134 \cdot 10^{-261} \lor \neg \left(x \le 1.73611979100849925 \cdot 10^{-107}\right):\\
\;\;\;\;x + \left(y - x\right) \cdot \frac{z}{t}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r573907 = x;
        double r573908 = y;
        double r573909 = r573908 - r573907;
        double r573910 = z;
        double r573911 = r573909 * r573910;
        double r573912 = t;
        double r573913 = r573911 / r573912;
        double r573914 = r573907 + r573913;
        return r573914;
}

double f(double x, double y, double z, double t) {
        double r573915 = x;
        double r573916 = -1.5579983248195513e-261;
        bool r573917 = r573915 <= r573916;
        double r573918 = 1.7361197910084992e-107;
        bool r573919 = r573915 <= r573918;
        double r573920 = !r573919;
        bool r573921 = r573917 || r573920;
        double r573922 = y;
        double r573923 = r573922 - r573915;
        double r573924 = z;
        double r573925 = t;
        double r573926 = r573924 / r573925;
        double r573927 = r573923 * r573926;
        double r573928 = r573915 + r573927;
        double r573929 = 1.0;
        double r573930 = r573923 / r573925;
        double r573931 = fma(r573930, r573924, r573915);
        double r573932 = r573929 * r573931;
        double r573933 = r573921 ? r573928 : r573932;
        return r573933;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.6
Target2.1
Herbie2.2
\[\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 < -1.5579983248195513e-261 or 1.7361197910084992e-107 < x

    1. Initial program 7.2

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

      \[\leadsto x + \frac{\left(y - x\right) \cdot z}{\color{blue}{1 \cdot t}}\]
    4. Applied times-frac1.2

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

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

    if -1.5579983248195513e-261 < x < 1.7361197910084992e-107

    1. Initial program 4.6

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.55799832481955134 \cdot 10^{-261} \lor \neg \left(x \le 1.73611979100849925 \cdot 10^{-107}\right):\\ \;\;\;\;x + \left(y - x\right) \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \mathsf{fma}\left(\frac{y - x}{t}, z, x\right)\\ \end{array}\]

Reproduce

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