Average Error: 6.6 → 1.6
Time: 2.8s
Precision: 64
\[x + \frac{\left(y - x\right) \cdot z}{t}\]
\[\begin{array}{l} \mathbf{if}\;t \le -4.325591509926424005596455457595530997711 \cdot 10^{-60} \lor \neg \left(t \le 5.800727818947734055610785619121475428497 \cdot 10^{-101}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{t}, z, x\right) - \frac{x}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\left(y - x\right) \cdot \left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right)}{\frac{t}{\sqrt[3]{z}}}\\ \end{array}\]
x + \frac{\left(y - x\right) \cdot z}{t}
\begin{array}{l}
\mathbf{if}\;t \le -4.325591509926424005596455457595530997711 \cdot 10^{-60} \lor \neg \left(t \le 5.800727818947734055610785619121475428497 \cdot 10^{-101}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{t}, z, x\right) - \frac{x}{\frac{t}{z}}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r406223 = x;
        double r406224 = y;
        double r406225 = r406224 - r406223;
        double r406226 = z;
        double r406227 = r406225 * r406226;
        double r406228 = t;
        double r406229 = r406227 / r406228;
        double r406230 = r406223 + r406229;
        return r406230;
}

double f(double x, double y, double z, double t) {
        double r406231 = t;
        double r406232 = -4.325591509926424e-60;
        bool r406233 = r406231 <= r406232;
        double r406234 = 5.800727818947734e-101;
        bool r406235 = r406231 <= r406234;
        double r406236 = !r406235;
        bool r406237 = r406233 || r406236;
        double r406238 = y;
        double r406239 = r406238 / r406231;
        double r406240 = z;
        double r406241 = x;
        double r406242 = fma(r406239, r406240, r406241);
        double r406243 = r406231 / r406240;
        double r406244 = r406241 / r406243;
        double r406245 = r406242 - r406244;
        double r406246 = r406238 - r406241;
        double r406247 = cbrt(r406240);
        double r406248 = r406247 * r406247;
        double r406249 = r406246 * r406248;
        double r406250 = r406231 / r406247;
        double r406251 = r406249 / r406250;
        double r406252 = r406241 + r406251;
        double r406253 = r406237 ? r406245 : r406252;
        return r406253;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.6
Target2.1
Herbie1.6
\[\begin{array}{l} \mathbf{if}\;x \lt -9.025511195533004570453352523209034680317 \cdot 10^{-135}:\\ \;\;\;\;x - \frac{z}{t} \cdot \left(x - y\right)\\ \mathbf{elif}\;x \lt 4.275032163700714748507147332551979944314 \cdot 10^{-250}:\\ \;\;\;\;x + \frac{y - x}{t} \cdot z\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if t < -4.325591509926424e-60 or 5.800727818947734e-101 < t

    1. Initial program 8.1

      \[x + \frac{\left(y - x\right) \cdot z}{t}\]
    2. Using strategy rm
    3. Applied associate-/l*1.1

      \[\leadsto x + \color{blue}{\frac{y - x}{\frac{t}{z}}}\]
    4. Using strategy rm
    5. Applied div-sub1.1

      \[\leadsto x + \color{blue}{\left(\frac{y}{\frac{t}{z}} - \frac{x}{\frac{t}{z}}\right)}\]
    6. Applied associate-+r-1.1

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

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

    if -4.325591509926424e-60 < t < 5.800727818947734e-101

    1. Initial program 2.4

      \[x + \frac{\left(y - x\right) \cdot z}{t}\]
    2. Using strategy rm
    3. Applied associate-/l*4.0

      \[\leadsto x + \color{blue}{\frac{y - x}{\frac{t}{z}}}\]
    4. Using strategy rm
    5. Applied add-cube-cbrt4.8

      \[\leadsto x + \frac{y - x}{\frac{t}{\color{blue}{\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \sqrt[3]{z}}}}\]
    6. Applied *-un-lft-identity4.8

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

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

      \[\leadsto x + \color{blue}{\frac{\frac{y - x}{\frac{1}{\sqrt[3]{z} \cdot \sqrt[3]{z}}}}{\frac{t}{\sqrt[3]{z}}}}\]
    9. Simplified2.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -4.325591509926424005596455457595530997711 \cdot 10^{-60} \lor \neg \left(t \le 5.800727818947734055610785619121475428497 \cdot 10^{-101}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{t}, z, x\right) - \frac{x}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\left(y - x\right) \cdot \left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right)}{\frac{t}{\sqrt[3]{z}}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020002 +o rules:numerics
(FPCore (x y z t)
  :name "Numeric.Histogram:binBounds from Chart-1.5.3"
  :precision binary64

  :herbie-target
  (if (< x -9.025511195533005e-135) (- x (* (/ z t) (- x y))) (if (< x 4.275032163700715e-250) (+ x (* (/ (- y x) t) z)) (+ x (/ (- y x) (/ t z)))))

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