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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r324359 = x;
        double r324360 = y;
        double r324361 = r324360 - r324359;
        double r324362 = z;
        double r324363 = t;
        double r324364 = r324362 / r324363;
        double r324365 = r324361 * r324364;
        double r324366 = r324359 + r324365;
        return r324366;
}

double f(double x, double y, double z, double t) {
        double r324367 = t;
        double r324368 = -3.2981924105391174e-118;
        bool r324369 = r324367 <= r324368;
        double r324370 = 5.6214786941139976e+32;
        bool r324371 = r324367 <= r324370;
        double r324372 = !r324371;
        bool r324373 = r324369 || r324372;
        double r324374 = y;
        double r324375 = x;
        double r324376 = r324374 - r324375;
        double r324377 = r324376 / r324367;
        double r324378 = 1.0;
        double r324379 = z;
        double r324380 = r324378 / r324379;
        double r324381 = r324377 / r324380;
        double r324382 = r324381 + r324375;
        double r324383 = r324376 * r324379;
        double r324384 = r324383 / r324367;
        double r324385 = r324384 + r324375;
        double r324386 = r324373 ? r324382 : r324385;
        return r324386;
}

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.1
Target2.2
Herbie2.0
\[\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 t < -3.2981924105391174e-118 or 5.6214786941139976e+32 < t

    1. Initial program 1.2

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

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

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

      \[\leadsto \color{blue}{\frac{y - x}{\frac{t}{z}}} + x\]
    6. Using strategy rm
    7. Applied div-inv1.3

      \[\leadsto \frac{y - x}{\color{blue}{t \cdot \frac{1}{z}}} + x\]
    8. Applied associate-/r*2.1

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

    if -3.2981924105391174e-118 < t < 5.6214786941139976e+32

    1. Initial program 3.9

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

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

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

      \[\leadsto \color{blue}{\frac{y - x}{\frac{t}{z}}} + x\]
    6. Using strategy rm
    7. Applied *-un-lft-identity3.5

      \[\leadsto \frac{y - x}{\frac{t}{\color{blue}{1 \cdot z}}} + x\]
    8. Applied *-un-lft-identity3.5

      \[\leadsto \frac{y - x}{\frac{\color{blue}{1 \cdot t}}{1 \cdot z}} + x\]
    9. Applied times-frac3.5

      \[\leadsto \frac{y - x}{\color{blue}{\frac{1}{1} \cdot \frac{t}{z}}} + x\]
    10. Applied *-un-lft-identity3.5

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

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

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

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

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

Reproduce

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

  :herbie-target
  (if (< (* (- y x) (/ z t)) -1013646692435.887) (+ 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))))