Average Error: 24.2 → 8.1
Time: 24.5s
Precision: 64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.985391526702694770119793366003335677306 \cdot 10^{-5}:\\ \;\;\;\;x - \frac{\log \left(\mathsf{fma}\left(\sqrt[3]{1 - y} \cdot \sqrt[3]{1 - y}, \sqrt[3]{1 - y}, y \cdot e^{z}\right)\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \mathsf{fma}\left(1, \left(\frac{z}{\sqrt[3]{t} \cdot \sqrt[3]{t}} \cdot \frac{\sqrt[3]{y} \cdot \sqrt[3]{y}}{\sqrt[3]{\sqrt[3]{t}} \cdot \sqrt[3]{\sqrt[3]{t}}}\right) \cdot \frac{\sqrt[3]{y}}{\sqrt[3]{\sqrt[3]{t}}}, \mathsf{fma}\left(\frac{{z}^{2} \cdot y}{t}, 0.5, \frac{\log 1}{t}\right)\right)\\ \end{array}\]
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
\begin{array}{l}
\mathbf{if}\;z \le -1.985391526702694770119793366003335677306 \cdot 10^{-5}:\\
\;\;\;\;x - \frac{\log \left(\mathsf{fma}\left(\sqrt[3]{1 - y} \cdot \sqrt[3]{1 - y}, \sqrt[3]{1 - y}, y \cdot e^{z}\right)\right)}{t}\\

\mathbf{else}:\\
\;\;\;\;x - \mathsf{fma}\left(1, \left(\frac{z}{\sqrt[3]{t} \cdot \sqrt[3]{t}} \cdot \frac{\sqrt[3]{y} \cdot \sqrt[3]{y}}{\sqrt[3]{\sqrt[3]{t}} \cdot \sqrt[3]{\sqrt[3]{t}}}\right) \cdot \frac{\sqrt[3]{y}}{\sqrt[3]{\sqrt[3]{t}}}, \mathsf{fma}\left(\frac{{z}^{2} \cdot y}{t}, 0.5, \frac{\log 1}{t}\right)\right)\\

\end{array}
double f(double x, double y, double z, double t) {
        double r168417 = x;
        double r168418 = 1.0;
        double r168419 = y;
        double r168420 = r168418 - r168419;
        double r168421 = z;
        double r168422 = exp(r168421);
        double r168423 = r168419 * r168422;
        double r168424 = r168420 + r168423;
        double r168425 = log(r168424);
        double r168426 = t;
        double r168427 = r168425 / r168426;
        double r168428 = r168417 - r168427;
        return r168428;
}

double f(double x, double y, double z, double t) {
        double r168429 = z;
        double r168430 = -1.9853915267026948e-05;
        bool r168431 = r168429 <= r168430;
        double r168432 = x;
        double r168433 = 1.0;
        double r168434 = y;
        double r168435 = r168433 - r168434;
        double r168436 = cbrt(r168435);
        double r168437 = r168436 * r168436;
        double r168438 = exp(r168429);
        double r168439 = r168434 * r168438;
        double r168440 = fma(r168437, r168436, r168439);
        double r168441 = log(r168440);
        double r168442 = t;
        double r168443 = r168441 / r168442;
        double r168444 = r168432 - r168443;
        double r168445 = cbrt(r168442);
        double r168446 = r168445 * r168445;
        double r168447 = r168429 / r168446;
        double r168448 = cbrt(r168434);
        double r168449 = r168448 * r168448;
        double r168450 = cbrt(r168445);
        double r168451 = r168450 * r168450;
        double r168452 = r168449 / r168451;
        double r168453 = r168447 * r168452;
        double r168454 = r168448 / r168450;
        double r168455 = r168453 * r168454;
        double r168456 = 2.0;
        double r168457 = pow(r168429, r168456);
        double r168458 = r168457 * r168434;
        double r168459 = r168458 / r168442;
        double r168460 = 0.5;
        double r168461 = log(r168433);
        double r168462 = r168461 / r168442;
        double r168463 = fma(r168459, r168460, r168462);
        double r168464 = fma(r168433, r168455, r168463);
        double r168465 = r168432 - r168464;
        double r168466 = r168431 ? r168444 : r168465;
        return r168466;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original24.2
Target15.7
Herbie8.1
\[\begin{array}{l} \mathbf{if}\;z \lt -2.887462308820794658905265984545350618896 \cdot 10^{119}:\\ \;\;\;\;\left(x - \frac{\frac{-0.5}{y \cdot t}}{z \cdot z}\right) - \frac{-0.5}{y \cdot t} \cdot \frac{\frac{2}{z}}{z \cdot z}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(1 + z \cdot y\right)}{t}\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if z < -1.9853915267026948e-05

    1. Initial program 11.4

      \[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
    2. Using strategy rm
    3. Applied add-cube-cbrt11.5

      \[\leadsto x - \frac{\log \left(\color{blue}{\left(\sqrt[3]{1 - y} \cdot \sqrt[3]{1 - y}\right) \cdot \sqrt[3]{1 - y}} + y \cdot e^{z}\right)}{t}\]
    4. Applied fma-def11.5

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

    if -1.9853915267026948e-05 < z

    1. Initial program 29.7

      \[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
    2. Taylor expanded around 0 7.0

      \[\leadsto x - \color{blue}{\left(1 \cdot \frac{z \cdot y}{t} + \left(\frac{\log 1}{t} + 0.5 \cdot \frac{{z}^{2} \cdot y}{t}\right)\right)}\]
    3. Simplified7.0

      \[\leadsto x - \color{blue}{\mathsf{fma}\left(1, \frac{z \cdot y}{t}, \mathsf{fma}\left(\frac{{z}^{2} \cdot y}{t}, 0.5, \frac{\log 1}{t}\right)\right)}\]
    4. Using strategy rm
    5. Applied add-cube-cbrt7.2

      \[\leadsto x - \mathsf{fma}\left(1, \frac{z \cdot y}{\color{blue}{\left(\sqrt[3]{t} \cdot \sqrt[3]{t}\right) \cdot \sqrt[3]{t}}}, \mathsf{fma}\left(\frac{{z}^{2} \cdot y}{t}, 0.5, \frac{\log 1}{t}\right)\right)\]
    6. Applied times-frac6.7

      \[\leadsto x - \mathsf{fma}\left(1, \color{blue}{\frac{z}{\sqrt[3]{t} \cdot \sqrt[3]{t}} \cdot \frac{y}{\sqrt[3]{t}}}, \mathsf{fma}\left(\frac{{z}^{2} \cdot y}{t}, 0.5, \frac{\log 1}{t}\right)\right)\]
    7. Using strategy rm
    8. Applied add-cube-cbrt6.8

      \[\leadsto x - \mathsf{fma}\left(1, \frac{z}{\sqrt[3]{t} \cdot \sqrt[3]{t}} \cdot \frac{y}{\color{blue}{\left(\sqrt[3]{\sqrt[3]{t}} \cdot \sqrt[3]{\sqrt[3]{t}}\right) \cdot \sqrt[3]{\sqrt[3]{t}}}}, \mathsf{fma}\left(\frac{{z}^{2} \cdot y}{t}, 0.5, \frac{\log 1}{t}\right)\right)\]
    9. Applied add-cube-cbrt6.8

      \[\leadsto x - \mathsf{fma}\left(1, \frac{z}{\sqrt[3]{t} \cdot \sqrt[3]{t}} \cdot \frac{\color{blue}{\left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right) \cdot \sqrt[3]{y}}}{\left(\sqrt[3]{\sqrt[3]{t}} \cdot \sqrt[3]{\sqrt[3]{t}}\right) \cdot \sqrt[3]{\sqrt[3]{t}}}, \mathsf{fma}\left(\frac{{z}^{2} \cdot y}{t}, 0.5, \frac{\log 1}{t}\right)\right)\]
    10. Applied times-frac6.8

      \[\leadsto x - \mathsf{fma}\left(1, \frac{z}{\sqrt[3]{t} \cdot \sqrt[3]{t}} \cdot \color{blue}{\left(\frac{\sqrt[3]{y} \cdot \sqrt[3]{y}}{\sqrt[3]{\sqrt[3]{t}} \cdot \sqrt[3]{\sqrt[3]{t}}} \cdot \frac{\sqrt[3]{y}}{\sqrt[3]{\sqrt[3]{t}}}\right)}, \mathsf{fma}\left(\frac{{z}^{2} \cdot y}{t}, 0.5, \frac{\log 1}{t}\right)\right)\]
    11. Applied associate-*r*6.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.985391526702694770119793366003335677306 \cdot 10^{-5}:\\ \;\;\;\;x - \frac{\log \left(\mathsf{fma}\left(\sqrt[3]{1 - y} \cdot \sqrt[3]{1 - y}, \sqrt[3]{1 - y}, y \cdot e^{z}\right)\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \mathsf{fma}\left(1, \left(\frac{z}{\sqrt[3]{t} \cdot \sqrt[3]{t}} \cdot \frac{\sqrt[3]{y} \cdot \sqrt[3]{y}}{\sqrt[3]{\sqrt[3]{t}} \cdot \sqrt[3]{\sqrt[3]{t}}}\right) \cdot \frac{\sqrt[3]{y}}{\sqrt[3]{\sqrt[3]{t}}}, \mathsf{fma}\left(\frac{{z}^{2} \cdot y}{t}, 0.5, \frac{\log 1}{t}\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019212 +o rules:numerics
(FPCore (x y z t)
  :name "System.Random.MWC.Distributions:truncatedExp from mwc-random-0.13.3.2"
  :precision binary64

  :herbie-target
  (if (< z -2.88746230882079466e119) (- (- x (/ (/ (- 0.5) (* y t)) (* z z))) (* (/ (- 0.5) (* y t)) (/ (/ 2 z) (* z z)))) (- x (/ (log (+ 1 (* z y))) t)))

  (- x (/ (log (+ (- 1 y) (* y (exp z)))) t)))