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

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r23462386 = x;
        double r23462387 = y;
        double r23462388 = r23462387 - r23462386;
        double r23462389 = z;
        double r23462390 = t;
        double r23462391 = r23462389 / r23462390;
        double r23462392 = r23462388 * r23462391;
        double r23462393 = r23462386 + r23462392;
        return r23462393;
}

double f(double x, double y, double z, double t) {
        double r23462394 = z;
        double r23462395 = -9.321316198184015e-37;
        bool r23462396 = r23462394 <= r23462395;
        double r23462397 = y;
        double r23462398 = x;
        double r23462399 = r23462397 - r23462398;
        double r23462400 = t;
        double r23462401 = r23462399 / r23462400;
        double r23462402 = r23462401 * r23462394;
        double r23462403 = r23462402 + r23462398;
        double r23462404 = 2.0484611838322853e-167;
        bool r23462405 = r23462394 <= r23462404;
        double r23462406 = r23462399 * r23462394;
        double r23462407 = r23462406 / r23462400;
        double r23462408 = r23462398 + r23462407;
        double r23462409 = r23462405 ? r23462408 : r23462403;
        double r23462410 = r23462396 ? r23462403 : r23462409;
        return r23462410;
}

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

      \[\leadsto \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}:\\ \;\;\;\;\frac{y - x}{t} \cdot z + x\\ \mathbf{elif}\;z \le 2.048461183832285343472596302907101930479 \cdot 10^{-167}:\\ \;\;\;\;x + \frac{\left(y - x\right) \cdot z}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{y - x}{t} \cdot z + x\\ \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))))