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

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r18497966 = x;
        double r18497967 = y;
        double r18497968 = r18497967 - r18497966;
        double r18497969 = z;
        double r18497970 = r18497968 * r18497969;
        double r18497971 = t;
        double r18497972 = r18497970 / r18497971;
        double r18497973 = r18497966 + r18497972;
        return r18497973;
}

double f(double x, double y, double z, double t) {
        double r18497974 = t;
        double r18497975 = -7160.27886158334;
        bool r18497976 = r18497974 <= r18497975;
        double r18497977 = y;
        double r18497978 = x;
        double r18497979 = r18497977 - r18497978;
        double r18497980 = r18497979 / r18497974;
        double r18497981 = z;
        double r18497982 = fma(r18497980, r18497981, r18497978);
        double r18497983 = -5.485219336659275e-236;
        bool r18497984 = r18497974 <= r18497983;
        double r18497985 = r18497977 * r18497981;
        double r18497986 = r18497985 / r18497974;
        double r18497987 = r18497981 * r18497978;
        double r18497988 = r18497987 / r18497974;
        double r18497989 = r18497986 - r18497988;
        double r18497990 = r18497978 + r18497989;
        double r18497991 = r18497974 / r18497981;
        double r18497992 = r18497979 / r18497991;
        double r18497993 = r18497978 + r18497992;
        double r18497994 = r18497984 ? r18497990 : r18497993;
        double r18497995 = r18497976 ? r18497982 : r18497994;
        return r18497995;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.7
Target2.1
Herbie1.9
\[\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 < -7160.27886158334

    1. Initial program 9.4

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

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

    if -7160.27886158334 < t < -5.485219336659275e-236

    1. Initial program 1.5

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

      \[\leadsto x + \color{blue}{\frac{y - x}{\frac{t}{z}}}\]
    4. Taylor expanded around 0 1.5

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

    if -5.485219336659275e-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 simplification1.9

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