Average Error: 2.0 → 0.8
Time: 14.2s
Precision: 64
\[x + \left(y - x\right) \cdot \frac{z}{t}\]
\[\begin{array}{l} \mathbf{if}\;\frac{z}{t} = -\infty \lor \neg \left(\frac{z}{t} \le -2.409265180973639206758559822292383386784 \cdot 10^{-271}\right) \land \frac{z}{t} \le -0.0:\\ \;\;\;\;\mathsf{fma}\left(1, x, \frac{y - x}{t} \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y - x, x\right)\\ \end{array}\]
x + \left(y - x\right) \cdot \frac{z}{t}
\begin{array}{l}
\mathbf{if}\;\frac{z}{t} = -\infty \lor \neg \left(\frac{z}{t} \le -2.409265180973639206758559822292383386784 \cdot 10^{-271}\right) \land \frac{z}{t} \le -0.0:\\
\;\;\;\;\mathsf{fma}\left(1, x, \frac{y - x}{t} \cdot z\right)\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r559276 = x;
        double r559277 = y;
        double r559278 = r559277 - r559276;
        double r559279 = z;
        double r559280 = t;
        double r559281 = r559279 / r559280;
        double r559282 = r559278 * r559281;
        double r559283 = r559276 + r559282;
        return r559283;
}

double f(double x, double y, double z, double t) {
        double r559284 = z;
        double r559285 = t;
        double r559286 = r559284 / r559285;
        double r559287 = -inf.0;
        bool r559288 = r559286 <= r559287;
        double r559289 = -2.409265180973639e-271;
        bool r559290 = r559286 <= r559289;
        double r559291 = !r559290;
        double r559292 = -0.0;
        bool r559293 = r559286 <= r559292;
        bool r559294 = r559291 && r559293;
        bool r559295 = r559288 || r559294;
        double r559296 = 1.0;
        double r559297 = x;
        double r559298 = y;
        double r559299 = r559298 - r559297;
        double r559300 = r559299 / r559285;
        double r559301 = r559300 * r559284;
        double r559302 = fma(r559296, r559297, r559301);
        double r559303 = fma(r559286, r559299, r559297);
        double r559304 = r559295 ? r559302 : r559303;
        return r559304;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original2.0
Target2.2
Herbie0.8
\[\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) < -inf.0 or -2.409265180973639e-271 < (/ z t) < -0.0

    1. Initial program 8.0

      \[x + \left(y - x\right) \cdot \frac{z}{t}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity8.0

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(1, x, \left(y - x\right) \cdot \frac{z}{t}\right)}\]
    5. Using strategy rm
    6. Applied pow18.0

      \[\leadsto \mathsf{fma}\left(1, x, \left(y - x\right) \cdot \color{blue}{{\left(\frac{z}{t}\right)}^{1}}\right)\]
    7. Applied pow18.0

      \[\leadsto \mathsf{fma}\left(1, x, \color{blue}{{\left(y - x\right)}^{1}} \cdot {\left(\frac{z}{t}\right)}^{1}\right)\]
    8. Applied pow-prod-down8.0

      \[\leadsto \mathsf{fma}\left(1, x, \color{blue}{{\left(\left(y - x\right) \cdot \frac{z}{t}\right)}^{1}}\right)\]
    9. Simplified7.6

      \[\leadsto \mathsf{fma}\left(1, x, {\color{blue}{\left(\frac{y - x}{\frac{t}{z}}\right)}}^{1}\right)\]
    10. Using strategy rm
    11. Applied *-un-lft-identity7.6

      \[\leadsto \mathsf{fma}\left(1, x, {\left(\frac{y - x}{\frac{t}{\color{blue}{1 \cdot z}}}\right)}^{1}\right)\]
    12. Applied *-un-lft-identity7.6

      \[\leadsto \mathsf{fma}\left(1, x, {\left(\frac{y - x}{\frac{\color{blue}{1 \cdot t}}{1 \cdot z}}\right)}^{1}\right)\]
    13. Applied times-frac7.6

      \[\leadsto \mathsf{fma}\left(1, x, {\left(\frac{y - x}{\color{blue}{\frac{1}{1} \cdot \frac{t}{z}}}\right)}^{1}\right)\]
    14. Applied *-un-lft-identity7.6

      \[\leadsto \mathsf{fma}\left(1, x, {\left(\frac{\color{blue}{1 \cdot \left(y - x\right)}}{\frac{1}{1} \cdot \frac{t}{z}}\right)}^{1}\right)\]
    15. Applied times-frac7.6

      \[\leadsto \mathsf{fma}\left(1, x, {\color{blue}{\left(\frac{1}{\frac{1}{1}} \cdot \frac{y - x}{\frac{t}{z}}\right)}}^{1}\right)\]
    16. Simplified7.6

      \[\leadsto \mathsf{fma}\left(1, x, {\left(\color{blue}{1} \cdot \frac{y - x}{\frac{t}{z}}\right)}^{1}\right)\]
    17. Simplified0.0

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

    if -inf.0 < (/ z t) < -2.409265180973639e-271 or -0.0 < (/ z t)

    1. Initial program 1.2

      \[x + \left(y - x\right) \cdot \frac{z}{t}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity1.2

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(1, x, \left(y - x\right) \cdot \frac{z}{t}\right)}\]
    5. Taylor expanded around 0 7.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{z}{t} = -\infty \lor \neg \left(\frac{z}{t} \le -2.409265180973639206758559822292383386784 \cdot 10^{-271}\right) \land \frac{z}{t} \le -0.0:\\ \;\;\;\;\mathsf{fma}\left(1, x, \frac{y - x}{t} \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y - x, x\right)\\ \end{array}\]

Reproduce

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