Average Error: 6.7 → 2.2
Time: 14.8s
Precision: 64
\[x + \frac{\left(y - x\right) \cdot z}{t}\]
\[\begin{array}{l} \mathbf{if}\;t \le -3.063495949423465697600577098817550141136 \cdot 10^{-95}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y - x}{t}, z, x\right)\\ \mathbf{elif}\;t \le -9.604647615299938484210642138811948553933 \cdot 10^{-236}:\\ \;\;\;\;\frac{1}{t \cdot \frac{\frac{1}{z}}{y - x}} + x\\ \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}\;t \le -3.063495949423465697600577098817550141136 \cdot 10^{-95}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y - x}{t}, z, x\right)\\

\mathbf{elif}\;t \le -9.604647615299938484210642138811948553933 \cdot 10^{-236}:\\
\;\;\;\;\frac{1}{t \cdot \frac{\frac{1}{z}}{y - x}} + x\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r18181238 = x;
        double r18181239 = y;
        double r18181240 = r18181239 - r18181238;
        double r18181241 = z;
        double r18181242 = r18181240 * r18181241;
        double r18181243 = t;
        double r18181244 = r18181242 / r18181243;
        double r18181245 = r18181238 + r18181244;
        return r18181245;
}

double f(double x, double y, double z, double t) {
        double r18181246 = t;
        double r18181247 = -3.063495949423466e-95;
        bool r18181248 = r18181246 <= r18181247;
        double r18181249 = y;
        double r18181250 = x;
        double r18181251 = r18181249 - r18181250;
        double r18181252 = r18181251 / r18181246;
        double r18181253 = z;
        double r18181254 = fma(r18181252, r18181253, r18181250);
        double r18181255 = -9.604647615299938e-236;
        bool r18181256 = r18181246 <= r18181255;
        double r18181257 = 1.0;
        double r18181258 = r18181257 / r18181253;
        double r18181259 = r18181258 / r18181251;
        double r18181260 = r18181246 * r18181259;
        double r18181261 = r18181257 / r18181260;
        double r18181262 = r18181261 + r18181250;
        double r18181263 = r18181246 / r18181253;
        double r18181264 = r18181251 / r18181263;
        double r18181265 = r18181250 + r18181264;
        double r18181266 = r18181256 ? r18181262 : r18181265;
        double r18181267 = r18181248 ? r18181254 : r18181266;
        return r18181267;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.7
Target2.1
Herbie2.2
\[\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 t < -3.063495949423466e-95

    1. Initial program 7.6

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

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

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

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

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

    if -3.063495949423466e-95 < t < -9.604647615299938e-236

    1. Initial program 2.7

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

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

      \[\leadsto x + \color{blue}{\frac{1}{\frac{\frac{t}{z}}{y - x}}}\]
    6. Using strategy rm
    7. Applied *-un-lft-identity2.7

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

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

      \[\leadsto x + \frac{1}{\color{blue}{\frac{t}{1} \cdot \frac{\frac{1}{z}}{y - x}}}\]
    10. Simplified3.0

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

    if -9.604647615299938e-236 < t

    1. Initial program 6.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 simplification2.2

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

Reproduce

herbie shell --seed 2019172 +o rules:numerics
(FPCore (x y z t)
  :name "Numeric.Histogram:binBounds from Chart-1.5.3"

  :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)))