Average Error: 2.0 → 2.1
Time: 19.7s
Precision: 64
\[x + \left(y - x\right) \cdot \frac{z}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \le -9.321316198184014864250290572846970188364 \cdot 10^{-37} \lor \neg \left(z \le 2.048461183832285343472596302907101930479 \cdot 10^{-167}\right):\\ \;\;\;\;\frac{y - x}{t} \cdot z + x\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\left(y - x\right) \cdot z}{t}\\ \end{array}\]
x + \left(y - x\right) \cdot \frac{z}{t}
\begin{array}{l}
\mathbf{if}\;z \le -9.321316198184014864250290572846970188364 \cdot 10^{-37} \lor \neg \left(z \le 2.048461183832285343472596302907101930479 \cdot 10^{-167}\right):\\
\;\;\;\;\frac{y - x}{t} \cdot z + x\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r333354 = x;
        double r333355 = y;
        double r333356 = r333355 - r333354;
        double r333357 = z;
        double r333358 = t;
        double r333359 = r333357 / r333358;
        double r333360 = r333356 * r333359;
        double r333361 = r333354 + r333360;
        return r333361;
}

double f(double x, double y, double z, double t) {
        double r333362 = z;
        double r333363 = -9.321316198184015e-37;
        bool r333364 = r333362 <= r333363;
        double r333365 = 2.0484611838322853e-167;
        bool r333366 = r333362 <= r333365;
        double r333367 = !r333366;
        bool r333368 = r333364 || r333367;
        double r333369 = y;
        double r333370 = x;
        double r333371 = r333369 - r333370;
        double r333372 = t;
        double r333373 = r333371 / r333372;
        double r333374 = r333373 * r333362;
        double r333375 = r333374 + r333370;
        double r333376 = r333371 * r333362;
        double r333377 = r333376 / r333372;
        double r333378 = r333370 + r333377;
        double r333379 = r333368 ? r333375 : r333378;
        return r333379;
}

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

Original2.0
Target2.2
Herbie2.1
\[\begin{array}{l} \mathbf{if}\;\left(y - x\right) \cdot \frac{z}{t} \lt -1013646692435.88671875:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \mathbf{elif}\;\left(y - x\right) \cdot \frac{z}{t} \lt -0.0:\\ \;\;\;\;x + \frac{\left(y - x\right) \cdot z}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if z < -9.321316198184015e-37 or 2.0484611838322853e-167 < z

    1. Initial program 2.5

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

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

      \[\leadsto \color{blue}{\frac{z}{t} \cdot \left(y - x\right) + x}\]
    5. Using strategy rm
    6. Applied div-inv2.5

      \[\leadsto \color{blue}{\left(z \cdot \frac{1}{t}\right)} \cdot \left(y - x\right) + x\]
    7. Applied associate-*l*2.8

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

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

    if -9.321316198184015e-37 < z < 2.0484611838322853e-167

    1. Initial program 1.4

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

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

      \[\leadsto \color{blue}{\frac{z}{t} \cdot \left(y - x\right) + x}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity1.4

      \[\leadsto \frac{z}{\color{blue}{1 \cdot t}} \cdot \left(y - x\right) + x\]
    7. Applied *-un-lft-identity1.4

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

      \[\leadsto \color{blue}{\left(\frac{1}{1} \cdot \frac{z}{t}\right)} \cdot \left(y - x\right) + x\]
    9. Applied associate-*l*1.4

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

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

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

Reproduce

herbie shell --seed 2019174 +o rules:numerics
(FPCore (x y z t)
  :name "Graphics.Rendering.Plot.Render.Plot.Axis:tickPosition from plot-0.2.3.4"

  :herbie-target
  (if (< (* (- y x) (/ z t)) -1013646692435.8867) (+ x (/ (- y x) (/ t z))) (if (< (* (- y x) (/ z t)) -0.0) (+ x (/ (* (- y x) z) t)) (+ x (/ (- y x) (/ t z)))))

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