Average Error: 6.6 → 2.1
Time: 3.0s
Precision: 64
\[x + \frac{\left(y - x\right) \cdot z}{t}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.994025224361559732601768522780092621951 \cdot 10^{-76}:\\ \;\;\;\;x + \left(y - x\right) \cdot \frac{z}{t}\\ \mathbf{elif}\;x \le 1.781637157063157607516751735823972328059 \cdot 10^{-248}:\\ \;\;\;\;x + \left(\left(y - x\right) \cdot z\right) \cdot \frac{1}{t}\\ \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}\;x \le -1.994025224361559732601768522780092621951 \cdot 10^{-76}:\\
\;\;\;\;x + \left(y - x\right) \cdot \frac{z}{t}\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r585957 = x;
        double r585958 = y;
        double r585959 = r585958 - r585957;
        double r585960 = z;
        double r585961 = r585959 * r585960;
        double r585962 = t;
        double r585963 = r585961 / r585962;
        double r585964 = r585957 + r585963;
        return r585964;
}

double f(double x, double y, double z, double t) {
        double r585965 = x;
        double r585966 = -1.9940252243615597e-76;
        bool r585967 = r585965 <= r585966;
        double r585968 = y;
        double r585969 = r585968 - r585965;
        double r585970 = z;
        double r585971 = t;
        double r585972 = r585970 / r585971;
        double r585973 = r585969 * r585972;
        double r585974 = r585965 + r585973;
        double r585975 = 1.7816371570631576e-248;
        bool r585976 = r585965 <= r585975;
        double r585977 = r585969 * r585970;
        double r585978 = 1.0;
        double r585979 = r585978 / r585971;
        double r585980 = r585977 * r585979;
        double r585981 = r585965 + r585980;
        double r585982 = r585971 / r585970;
        double r585983 = r585969 / r585982;
        double r585984 = r585965 + r585983;
        double r585985 = r585976 ? r585981 : r585984;
        double r585986 = r585967 ? r585974 : r585985;
        return r585986;
}

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.6
Target2.2
Herbie2.1
\[\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 x < -1.9940252243615597e-76

    1. Initial program 7.9

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

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

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

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

    if -1.9940252243615597e-76 < x < 1.7816371570631576e-248

    1. Initial program 4.8

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

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

    if 1.7816371570631576e-248 < x

    1. Initial program 6.9

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

      \[\leadsto x + \color{blue}{\frac{y - x}{\frac{t}{z}}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification2.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.994025224361559732601768522780092621951 \cdot 10^{-76}:\\ \;\;\;\;x + \left(y - x\right) \cdot \frac{z}{t}\\ \mathbf{elif}\;x \le 1.781637157063157607516751735823972328059 \cdot 10^{-248}:\\ \;\;\;\;x + \left(\left(y - x\right) \cdot z\right) \cdot \frac{1}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019362 +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)))