Average Error: 25.4 → 8.6
Time: 22.6s
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.9999999353825346215529634719132445752621:\\ \;\;\;\;x - \frac{\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{\sqrt[3]{t} \cdot \sqrt[3]{t}}}{\sqrt[3]{t}}\\ \mathbf{else}:\\ \;\;\;\;x - \left(1 \cdot \left(\left(z \cdot y\right) \cdot \frac{1}{t}\right) + \frac{\log 1}{t}\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.9999999353825346215529634719132445752621:\\
\;\;\;\;x - \frac{\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{\sqrt[3]{t} \cdot \sqrt[3]{t}}}{\sqrt[3]{t}}\\

\mathbf{else}:\\
\;\;\;\;x - \left(1 \cdot \left(\left(z \cdot y\right) \cdot \frac{1}{t}\right) + \frac{\log 1}{t}\right)\\

\end{array}
double f(double x, double y, double z, double t) {
        double r15850942 = x;
        double r15850943 = 1.0;
        double r15850944 = y;
        double r15850945 = r15850943 - r15850944;
        double r15850946 = z;
        double r15850947 = exp(r15850946);
        double r15850948 = r15850944 * r15850947;
        double r15850949 = r15850945 + r15850948;
        double r15850950 = log(r15850949);
        double r15850951 = t;
        double r15850952 = r15850950 / r15850951;
        double r15850953 = r15850942 - r15850952;
        return r15850953;
}

double f(double x, double y, double z, double t) {
        double r15850954 = z;
        double r15850955 = exp(r15850954);
        double r15850956 = 0.9999999353825346;
        bool r15850957 = r15850955 <= r15850956;
        double r15850958 = x;
        double r15850959 = 1.0;
        double r15850960 = y;
        double r15850961 = r15850959 - r15850960;
        double r15850962 = r15850960 * r15850955;
        double r15850963 = r15850961 + r15850962;
        double r15850964 = log(r15850963);
        double r15850965 = t;
        double r15850966 = cbrt(r15850965);
        double r15850967 = r15850966 * r15850966;
        double r15850968 = r15850964 / r15850967;
        double r15850969 = r15850968 / r15850966;
        double r15850970 = r15850958 - r15850969;
        double r15850971 = r15850954 * r15850960;
        double r15850972 = 1.0;
        double r15850973 = r15850972 / r15850965;
        double r15850974 = r15850971 * r15850973;
        double r15850975 = r15850959 * r15850974;
        double r15850976 = log(r15850959);
        double r15850977 = r15850976 / r15850965;
        double r15850978 = r15850975 + r15850977;
        double r15850979 = r15850958 - r15850978;
        double r15850980 = r15850957 ? r15850970 : r15850979;
        return r15850980;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original25.4
Target16.4
Herbie8.6
\[\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 (exp z) < 0.9999999353825346

    1. Initial program 11.2

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

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

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

    if 0.9999999353825346 < (exp z)

    1. Initial program 31.8

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

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

      \[\leadsto x - \frac{\color{blue}{\log 1 + y \cdot \left(0.5 \cdot \left(z \cdot z\right) + 1 \cdot z\right)}}{t}\]
    4. Taylor expanded around 0 7.3

      \[\leadsto \color{blue}{x - \left(1 \cdot \frac{z \cdot y}{t} + \frac{\log 1}{t}\right)}\]
    5. Using strategy rm
    6. Applied div-inv7.3

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

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

Reproduce

herbie shell --seed 2019174 
(FPCore (x y z t)
  :name "System.Random.MWC.Distributions:truncatedExp from mwc-random-0.13.3.2"

  :herbie-target
  (if (< z -2.8874623088207947e+119) (- (- x (/ (/ (- 0.5) (* y t)) (* z z))) (* (/ (- 0.5) (* y t)) (/ (/ 2.0 z) (* z z)))) (- x (/ (log (+ 1.0 (* z y))) t)))

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