Average Error: 6.6 → 1.4
Time: 3.0s
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 -1.24776180719115646 \cdot 10^{274}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y - x, x\right)\\ \mathbf{elif}\;x + \frac{\left(y - x\right) \cdot z}{t} \le -1.58966566023791801 \cdot 10^{-168}:\\ \;\;\;\;x + \frac{\left(y - x\right) \cdot z}{t}\\ \mathbf{elif}\;x + \frac{\left(y - x\right) \cdot z}{t} \le 1.17692352051271372 \cdot 10^{-136}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{\frac{t}{y - x}}, z, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y - x, 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} \le -1.24776180719115646 \cdot 10^{274}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y - x, x\right)\\

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

\mathbf{elif}\;x + \frac{\left(y - x\right) \cdot z}{t} \le 1.17692352051271372 \cdot 10^{-136}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{\frac{t}{y - x}}, z, x\right)\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r452760 = x;
        double r452761 = y;
        double r452762 = r452761 - r452760;
        double r452763 = z;
        double r452764 = r452762 * r452763;
        double r452765 = t;
        double r452766 = r452764 / r452765;
        double r452767 = r452760 + r452766;
        return r452767;
}

double f(double x, double y, double z, double t) {
        double r452768 = x;
        double r452769 = y;
        double r452770 = r452769 - r452768;
        double r452771 = z;
        double r452772 = r452770 * r452771;
        double r452773 = t;
        double r452774 = r452772 / r452773;
        double r452775 = r452768 + r452774;
        double r452776 = -1.2477618071911565e+274;
        bool r452777 = r452775 <= r452776;
        double r452778 = r452771 / r452773;
        double r452779 = fma(r452778, r452770, r452768);
        double r452780 = -1.589665660237918e-168;
        bool r452781 = r452775 <= r452780;
        double r452782 = 1.1769235205127137e-136;
        bool r452783 = r452775 <= r452782;
        double r452784 = 1.0;
        double r452785 = r452773 / r452770;
        double r452786 = r452784 / r452785;
        double r452787 = fma(r452786, r452771, r452768);
        double r452788 = r452783 ? r452787 : r452779;
        double r452789 = r452781 ? r452775 : r452788;
        double r452790 = r452777 ? r452779 : r452789;
        return r452790;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.6
Target1.9
Herbie1.4
\[\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)) < -1.2477618071911565e+274 or 1.1769235205127137e-136 < (+ x (/ (* (- y x) z) t))

    1. Initial program 11.6

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

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

      \[\leadsto \mathsf{fma}\left(\frac{y - x}{\color{blue}{\left(\sqrt[3]{t} \cdot \sqrt[3]{t}\right) \cdot \sqrt[3]{t}}}, z, x\right)\]
    5. Applied associate-/r*7.5

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{\frac{y - x}{\sqrt[3]{t} \cdot \sqrt[3]{t}}}{\sqrt[3]{t}}}, z, x\right)\]
    6. Taylor expanded around 0 11.6

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

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

    if -1.2477618071911565e+274 < (+ x (/ (* (- y x) z) t)) < -1.589665660237918e-168

    1. Initial program 0.4

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

    if -1.589665660237918e-168 < (+ x (/ (* (- y x) z) t)) < 1.1769235205127137e-136

    1. Initial program 3.9

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + \frac{\left(y - x\right) \cdot z}{t} \le -1.24776180719115646 \cdot 10^{274}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y - x, x\right)\\ \mathbf{elif}\;x + \frac{\left(y - x\right) \cdot z}{t} \le -1.58966566023791801 \cdot 10^{-168}:\\ \;\;\;\;x + \frac{\left(y - x\right) \cdot z}{t}\\ \mathbf{elif}\;x + \frac{\left(y - x\right) \cdot z}{t} \le 1.17692352051271372 \cdot 10^{-136}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{\frac{t}{y - x}}, z, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y - x, x\right)\\ \end{array}\]

Reproduce

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