Average Error: 25.1 → 8.6
Time: 7.3s
Precision: 64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;e^{z} \le 0.99999999999999334:\\ \;\;\;\;x - \frac{2 \cdot \log \left(\sqrt[3]{\left(1 - y\right) + y \cdot e^{z}}\right) + \log \left(\sqrt[3]{\left(1 - y\right) + y \cdot e^{z}}\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \mathsf{fma}\left(\frac{z}{\sqrt[3]{t} \cdot \sqrt[3]{t}} \cdot \frac{y}{\sqrt[3]{t}}, 1, \mathsf{fma}\left(0.5, \frac{{z}^{2} \cdot y}{t}, \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}\;e^{z} \le 0.99999999999999334:\\
\;\;\;\;x - \frac{2 \cdot \log \left(\sqrt[3]{\left(1 - y\right) + y \cdot e^{z}}\right) + \log \left(\sqrt[3]{\left(1 - y\right) + y \cdot e^{z}}\right)}{t}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r272478 = x;
        double r272479 = 1.0;
        double r272480 = y;
        double r272481 = r272479 - r272480;
        double r272482 = z;
        double r272483 = exp(r272482);
        double r272484 = r272480 * r272483;
        double r272485 = r272481 + r272484;
        double r272486 = log(r272485);
        double r272487 = t;
        double r272488 = r272486 / r272487;
        double r272489 = r272478 - r272488;
        return r272489;
}

double f(double x, double y, double z, double t) {
        double r272490 = z;
        double r272491 = exp(r272490);
        double r272492 = 0.9999999999999933;
        bool r272493 = r272491 <= r272492;
        double r272494 = x;
        double r272495 = 2.0;
        double r272496 = 1.0;
        double r272497 = y;
        double r272498 = r272496 - r272497;
        double r272499 = r272497 * r272491;
        double r272500 = r272498 + r272499;
        double r272501 = cbrt(r272500);
        double r272502 = log(r272501);
        double r272503 = r272495 * r272502;
        double r272504 = r272503 + r272502;
        double r272505 = t;
        double r272506 = r272504 / r272505;
        double r272507 = r272494 - r272506;
        double r272508 = cbrt(r272505);
        double r272509 = r272508 * r272508;
        double r272510 = r272490 / r272509;
        double r272511 = r272497 / r272508;
        double r272512 = r272510 * r272511;
        double r272513 = 0.5;
        double r272514 = pow(r272490, r272495);
        double r272515 = r272514 * r272497;
        double r272516 = r272515 / r272505;
        double r272517 = log(r272496);
        double r272518 = r272517 / r272505;
        double r272519 = fma(r272513, r272516, r272518);
        double r272520 = fma(r272512, r272496, r272519);
        double r272521 = r272494 - r272520;
        double r272522 = r272493 ? r272507 : r272521;
        return r272522;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original25.1
Target16.9
Herbie8.6
\[\begin{array}{l} \mathbf{if}\;z \lt -2.88746230882079466 \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 (exp z) < 0.9999999999999933

    1. Initial program 12.6

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

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

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

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

    if 0.9999999999999933 < (exp z)

    1. Initial program 30.9

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

      \[\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.1

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

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

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

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

Reproduce

herbie shell --seed 2020020 +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.8874623088207947e+119) (- (- 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)))