Average Error: 6.7 → 1.9
Time: 17.3s
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 r18697661 = x;
        double r18697662 = y;
        double r18697663 = r18697662 - r18697661;
        double r18697664 = z;
        double r18697665 = r18697663 * r18697664;
        double r18697666 = t;
        double r18697667 = r18697665 / r18697666;
        double r18697668 = r18697661 + r18697667;
        return r18697668;
}

double f(double x, double y, double z, double t) {
        double r18697669 = t;
        double r18697670 = -7160.27886158334;
        bool r18697671 = r18697669 <= r18697670;
        double r18697672 = y;
        double r18697673 = x;
        double r18697674 = r18697672 - r18697673;
        double r18697675 = r18697674 / r18697669;
        double r18697676 = z;
        double r18697677 = fma(r18697675, r18697676, r18697673);
        double r18697678 = -5.485219336659275e-236;
        bool r18697679 = r18697669 <= r18697678;
        double r18697680 = r18697672 * r18697676;
        double r18697681 = r18697680 / r18697669;
        double r18697682 = r18697676 * r18697673;
        double r18697683 = r18697682 / r18697669;
        double r18697684 = r18697681 - r18697683;
        double r18697685 = r18697673 + r18697684;
        double r18697686 = r18697669 / r18697676;
        double r18697687 = r18697674 / r18697686;
        double r18697688 = r18697673 + r18697687;
        double r18697689 = r18697679 ? r18697685 : r18697688;
        double r18697690 = r18697671 ? r18697677 : r18697689;
        return r18697690;
}

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