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 + \frac{1}{t} \cdot \left(\left(y - x\right) \cdot z\right)\\ \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 + \frac{1}{t} \cdot \left(\left(y - x\right) \cdot z\right)\\

\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 r477740 = x;
        double r477741 = y;
        double r477742 = r477741 - r477740;
        double r477743 = z;
        double r477744 = r477742 * r477743;
        double r477745 = t;
        double r477746 = r477744 / r477745;
        double r477747 = r477740 + r477746;
        return r477747;
}

double f(double x, double y, double z, double t) {
        double r477748 = t;
        double r477749 = -1.2296511586159365e-21;
        bool r477750 = r477748 <= r477749;
        double r477751 = y;
        double r477752 = x;
        double r477753 = r477751 - r477752;
        double r477754 = r477753 / r477748;
        double r477755 = z;
        double r477756 = fma(r477754, r477755, r477752);
        double r477757 = 1.625406329571912e-217;
        bool r477758 = r477748 <= r477757;
        double r477759 = 1.0;
        double r477760 = r477759 / r477748;
        double r477761 = r477753 * r477755;
        double r477762 = r477760 * r477761;
        double r477763 = r477752 + r477762;
        double r477764 = cbrt(r477748);
        double r477765 = r477764 * r477764;
        double r477766 = r477753 / r477765;
        double r477767 = r477755 / r477764;
        double r477768 = r477766 * r477767;
        double r477769 = r477752 + r477768;
        double r477770 = r477758 ? r477763 : r477769;
        double r477771 = r477750 ? r477756 : r477770;
        return r477771;
}

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 associate-/l*3.8

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

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

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

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

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

    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 + \frac{1}{t} \cdot \left(\left(y - x\right) \cdot z\right)\\ \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)))