Average Error: 6.6 → 2.1
Time: 2.7s
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 + \frac{1}{t} \cdot \left(\left(y - x\right) \cdot z\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}\;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 + \frac{1}{t} \cdot \left(\left(y - x\right) \cdot z\right)\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r705483 = x;
        double r705484 = y;
        double r705485 = r705484 - r705483;
        double r705486 = z;
        double r705487 = r705485 * r705486;
        double r705488 = t;
        double r705489 = r705487 / r705488;
        double r705490 = r705483 + r705489;
        return r705490;
}

double f(double x, double y, double z, double t) {
        double r705491 = x;
        double r705492 = -1.9940252243615597e-76;
        bool r705493 = r705491 <= r705492;
        double r705494 = y;
        double r705495 = r705494 - r705491;
        double r705496 = z;
        double r705497 = t;
        double r705498 = r705496 / r705497;
        double r705499 = r705495 * r705498;
        double r705500 = r705491 + r705499;
        double r705501 = 1.7816371570631576e-248;
        bool r705502 = r705491 <= r705501;
        double r705503 = 1.0;
        double r705504 = r705503 / r705497;
        double r705505 = r705495 * r705496;
        double r705506 = r705504 * r705505;
        double r705507 = r705491 + r705506;
        double r705508 = r705497 / r705496;
        double r705509 = r705495 / r705508;
        double r705510 = r705491 + r705509;
        double r705511 = r705502 ? r705507 : r705510;
        double r705512 = r705493 ? r705500 : r705511;
        return r705512;
}

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 associate-/l*4.4

      \[\leadsto x + \color{blue}{\frac{y - x}{\frac{t}{z}}}\]
    4. Using strategy rm
    5. Applied div-inv4.4

      \[\leadsto x + \frac{y - x}{\color{blue}{t \cdot \frac{1}{z}}}\]
    6. Applied *-un-lft-identity4.4

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

      \[\leadsto x + \color{blue}{\frac{1}{t} \cdot \frac{y - x}{\frac{1}{z}}}\]
    8. Simplified4.9

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

    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 + \frac{1}{t} \cdot \left(\left(y - x\right) \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \end{array}\]

Reproduce

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