Average Error: 2.2 → 2.0
Time: 22.4s
Precision: 64
\[x + \left(y - x\right) \cdot \frac{z}{t}\]
\[\begin{array}{l} \mathbf{if}\;\frac{z}{t} \le -5.920177049123856979402727352381656804933 \cdot 10^{-176} \lor \neg \left(\frac{z}{t} \le 1.102754521517662286602101545681870103119 \cdot 10^{-319}\right) \land \frac{z}{t} \le 1288766001837314844471066624:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y - x}{t}, z, x\right)\\ \end{array}\]
x + \left(y - x\right) \cdot \frac{z}{t}
\begin{array}{l}
\mathbf{if}\;\frac{z}{t} \le -5.920177049123856979402727352381656804933 \cdot 10^{-176} \lor \neg \left(\frac{z}{t} \le 1.102754521517662286602101545681870103119 \cdot 10^{-319}\right) \land \frac{z}{t} \le 1288766001837314844471066624:\\
\;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y - x}{t}, z, x\right)\\

\end{array}
double f(double x, double y, double z, double t) {
        double r343124 = x;
        double r343125 = y;
        double r343126 = r343125 - r343124;
        double r343127 = z;
        double r343128 = t;
        double r343129 = r343127 / r343128;
        double r343130 = r343126 * r343129;
        double r343131 = r343124 + r343130;
        return r343131;
}

double f(double x, double y, double z, double t) {
        double r343132 = z;
        double r343133 = t;
        double r343134 = r343132 / r343133;
        double r343135 = -5.920177049123857e-176;
        bool r343136 = r343134 <= r343135;
        double r343137 = 1.1027545215177e-319;
        bool r343138 = r343134 <= r343137;
        double r343139 = !r343138;
        double r343140 = 1.2887660018373148e+27;
        bool r343141 = r343134 <= r343140;
        bool r343142 = r343139 && r343141;
        bool r343143 = r343136 || r343142;
        double r343144 = x;
        double r343145 = y;
        double r343146 = r343145 - r343144;
        double r343147 = r343133 / r343132;
        double r343148 = r343146 / r343147;
        double r343149 = r343144 + r343148;
        double r343150 = r343146 / r343133;
        double r343151 = fma(r343150, r343132, r343144);
        double r343152 = r343143 ? r343149 : r343151;
        return r343152;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original2.2
Target2.4
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 (/ z t) < -5.920177049123857e-176 or 1.1027545215177e-319 < (/ z t) < 1.2887660018373148e+27

    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.1

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

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

    if -5.920177049123857e-176 < (/ z t) < 1.1027545215177e-319 or 1.2887660018373148e+27 < (/ z t)

    1. Initial program 3.8

      \[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.8

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{z}{t} \le -5.920177049123856979402727352381656804933 \cdot 10^{-176} \lor \neg \left(\frac{z}{t} \le 1.102754521517662286602101545681870103119 \cdot 10^{-319}\right) \land \frac{z}{t} \le 1288766001837314844471066624:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y - x}{t}, z, x\right)\\ \end{array}\]

Reproduce

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