Average Error: 6.3 → 1.8
Time: 24.0s
Precision: 64
\[x + \frac{\left(y - x\right) \cdot z}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \le 5.652856478954745293198236811998099696538 \cdot 10^{-33}:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;\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}\;z \le 5.652856478954745293198236811998099696538 \cdot 10^{-33}:\\
\;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r338600 = x;
        double r338601 = y;
        double r338602 = r338601 - r338600;
        double r338603 = z;
        double r338604 = r338602 * r338603;
        double r338605 = t;
        double r338606 = r338604 / r338605;
        double r338607 = r338600 + r338606;
        return r338607;
}

double f(double x, double y, double z, double t) {
        double r338608 = z;
        double r338609 = 5.652856478954745e-33;
        bool r338610 = r338608 <= r338609;
        double r338611 = x;
        double r338612 = y;
        double r338613 = r338612 - r338611;
        double r338614 = t;
        double r338615 = r338614 / r338608;
        double r338616 = r338613 / r338615;
        double r338617 = r338611 + r338616;
        double r338618 = r338613 / r338614;
        double r338619 = fma(r338618, r338608, r338611);
        double r338620 = r338610 ? r338617 : r338619;
        return r338620;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.3
Target2.2
Herbie1.8
\[\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 2 regimes
  2. if z < 5.652856478954745e-33

    1. Initial program 4.4

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

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

    if 5.652856478954745e-33 < z

    1. Initial program 12.9

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le 5.652856478954745293198236811998099696538 \cdot 10^{-33}:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y - x}{t}, z, x\right)\\ \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)))