Average Error: 6.5 → 1.9
Time: 15.5s
Precision: 64
\[x + \frac{\left(y - x\right) \cdot z}{t}\]
\[\begin{array}{l} \mathbf{if}\;x \le -8.197251181992450336177184911706312715011 \cdot 10^{-110} \lor \neg \left(x \le 1.163685728587467934538355368329212838924 \cdot 10^{-252}\right):\\ \;\;\;\;x + \frac{z}{t} \cdot \left(y - x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(y - x\right) \cdot z}{t} + x\\ \end{array}\]
x + \frac{\left(y - x\right) \cdot z}{t}
\begin{array}{l}
\mathbf{if}\;x \le -8.197251181992450336177184911706312715011 \cdot 10^{-110} \lor \neg \left(x \le 1.163685728587467934538355368329212838924 \cdot 10^{-252}\right):\\
\;\;\;\;x + \frac{z}{t} \cdot \left(y - x\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{\left(y - x\right) \cdot z}{t} + x\\

\end{array}
double f(double x, double y, double z, double t) {
        double r343357 = x;
        double r343358 = y;
        double r343359 = r343358 - r343357;
        double r343360 = z;
        double r343361 = r343359 * r343360;
        double r343362 = t;
        double r343363 = r343361 / r343362;
        double r343364 = r343357 + r343363;
        return r343364;
}

double f(double x, double y, double z, double t) {
        double r343365 = x;
        double r343366 = -8.19725118199245e-110;
        bool r343367 = r343365 <= r343366;
        double r343368 = 1.163685728587468e-252;
        bool r343369 = r343365 <= r343368;
        double r343370 = !r343369;
        bool r343371 = r343367 || r343370;
        double r343372 = z;
        double r343373 = t;
        double r343374 = r343372 / r343373;
        double r343375 = y;
        double r343376 = r343375 - r343365;
        double r343377 = r343374 * r343376;
        double r343378 = r343365 + r343377;
        double r343379 = r343376 * r343372;
        double r343380 = r343379 / r343373;
        double r343381 = r343380 + r343365;
        double r343382 = r343371 ? r343378 : r343381;
        return r343382;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.5
Target2.0
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 2 regimes
  2. if x < -8.19725118199245e-110 or 1.163685728587468e-252 < x

    1. Initial program 7.0

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\left(y - x\right) \cdot \left(\sqrt[3]{\frac{1}{t}} \cdot \sqrt[3]{\frac{1}{t}}\right)\right) \cdot \sqrt[3]{\frac{1}{t}}}, z, x\right)\]
    8. Simplified7.2

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

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

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

    if -8.19725118199245e-110 < x < 1.163685728587468e-252

    1. Initial program 4.5

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

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(y - x\right) \cdot \frac{1}{t}}, z, x\right)\]
    5. Using strategy rm
    6. Applied fma-udef5.7

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -8.197251181992450336177184911706312715011 \cdot 10^{-110} \lor \neg \left(x \le 1.163685728587467934538355368329212838924 \cdot 10^{-252}\right):\\ \;\;\;\;x + \frac{z}{t} \cdot \left(y - x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(y - x\right) \cdot z}{t} + x\\ \end{array}\]

Reproduce

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

  :herbie-target
  (if (< x -9.0255111955330046e-135) (- x (* (/ z t) (- x y))) (if (< x 4.2750321637007147e-250) (+ x (* (/ (- y x) t) z)) (+ x (/ (- y x) (/ t z)))))

  (+ x (/ (* (- y x) z) t)))