Average Error: 6.6 → 2.5
Time: 2.7s
Precision: 64
\[x + \frac{\left(y - x\right) \cdot z}{t}\]
\[\begin{array}{l} \mathbf{if}\;t \le -1.229651158615936528983347561392124591292 \cdot 10^{-21}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y - x}{t}, z, x\right)\\ \mathbf{elif}\;t \le 1.625406329571911990929648461559105916592 \cdot 10^{-217}:\\ \;\;\;\;x + \left(\left(y - x\right) \cdot z\right) \cdot \frac{1}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - x}{\sqrt[3]{t} \cdot \sqrt[3]{t}} \cdot \frac{z}{\sqrt[3]{t}}\\ \end{array}\]
x + \frac{\left(y - x\right) \cdot z}{t}
\begin{array}{l}
\mathbf{if}\;t \le -1.229651158615936528983347561392124591292 \cdot 10^{-21}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y - x}{t}, z, x\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r383074 = x;
        double r383075 = y;
        double r383076 = r383075 - r383074;
        double r383077 = z;
        double r383078 = r383076 * r383077;
        double r383079 = t;
        double r383080 = r383078 / r383079;
        double r383081 = r383074 + r383080;
        return r383081;
}

double f(double x, double y, double z, double t) {
        double r383082 = t;
        double r383083 = -1.2296511586159365e-21;
        bool r383084 = r383082 <= r383083;
        double r383085 = y;
        double r383086 = x;
        double r383087 = r383085 - r383086;
        double r383088 = r383087 / r383082;
        double r383089 = z;
        double r383090 = fma(r383088, r383089, r383086);
        double r383091 = 1.625406329571912e-217;
        bool r383092 = r383082 <= r383091;
        double r383093 = r383087 * r383089;
        double r383094 = 1.0;
        double r383095 = r383094 / r383082;
        double r383096 = r383093 * r383095;
        double r383097 = r383086 + r383096;
        double r383098 = cbrt(r383082);
        double r383099 = r383098 * r383098;
        double r383100 = r383087 / r383099;
        double r383101 = r383089 / r383098;
        double r383102 = r383100 * r383101;
        double r383103 = r383086 + r383102;
        double r383104 = r383092 ? r383097 : r383103;
        double r383105 = r383084 ? r383090 : r383104;
        return r383105;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.6
Target2.0
Herbie2.5
\[\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 3 regimes
  2. if t < -1.2296511586159365e-21

    1. Initial program 9.1

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

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

    if -1.2296511586159365e-21 < t < 1.625406329571912e-217

    1. Initial program 2.0

      \[x + \frac{\left(y - x\right) \cdot z}{t}\]
    2. Using strategy rm
    3. Applied div-inv2.1

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

    if 1.625406329571912e-217 < t

    1. Initial program 6.8

      \[x + \frac{\left(y - x\right) \cdot z}{t}\]
    2. Using strategy rm
    3. Applied add-cube-cbrt7.2

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

      \[\leadsto x + \color{blue}{\frac{y - x}{\sqrt[3]{t} \cdot \sqrt[3]{t}} \cdot \frac{z}{\sqrt[3]{t}}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification2.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -1.229651158615936528983347561392124591292 \cdot 10^{-21}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y - x}{t}, z, x\right)\\ \mathbf{elif}\;t \le 1.625406329571911990929648461559105916592 \cdot 10^{-217}:\\ \;\;\;\;x + \left(\left(y - x\right) \cdot z\right) \cdot \frac{1}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - x}{\sqrt[3]{t} \cdot \sqrt[3]{t}} \cdot \frac{z}{\sqrt[3]{t}}\\ \end{array}\]

Reproduce

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