Average Error: 24.9 → 8.6
Time: 11.8s
Precision: 64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.335321811329624610683838289670382751461 \cdot 10^{-46}:\\ \;\;\;\;x - \frac{\sqrt[3]{{\left(\sqrt[3]{\log \left(1 - \left(1 - e^{z}\right) \cdot y\right) \cdot \log \left(1 - \left(1 - e^{z}\right) \cdot y\right)} \cdot \sqrt[3]{\log \left(1 - \left(1 - e^{z}\right) \cdot y\right)}\right)}^{3}}}{t}\\ \mathbf{elif}\;z \le 3.376112840318544795339777656673878871719 \cdot 10^{-108}:\\ \;\;\;\;x - \frac{\log 1 + y \cdot \left(0.5 \cdot {z}^{2} + 1 \cdot z\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(1 + y \cdot \left(\frac{1}{2} \cdot {z}^{2} + z\right)\right)}{t}\\ \end{array}\]
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
\begin{array}{l}
\mathbf{if}\;z \le -1.335321811329624610683838289670382751461 \cdot 10^{-46}:\\
\;\;\;\;x - \frac{\sqrt[3]{{\left(\sqrt[3]{\log \left(1 - \left(1 - e^{z}\right) \cdot y\right) \cdot \log \left(1 - \left(1 - e^{z}\right) \cdot y\right)} \cdot \sqrt[3]{\log \left(1 - \left(1 - e^{z}\right) \cdot y\right)}\right)}^{3}}}{t}\\

\mathbf{elif}\;z \le 3.376112840318544795339777656673878871719 \cdot 10^{-108}:\\
\;\;\;\;x - \frac{\log 1 + y \cdot \left(0.5 \cdot {z}^{2} + 1 \cdot z\right)}{t}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r225173 = x;
        double r225174 = 1.0;
        double r225175 = y;
        double r225176 = r225174 - r225175;
        double r225177 = z;
        double r225178 = exp(r225177);
        double r225179 = r225175 * r225178;
        double r225180 = r225176 + r225179;
        double r225181 = log(r225180);
        double r225182 = t;
        double r225183 = r225181 / r225182;
        double r225184 = r225173 - r225183;
        return r225184;
}

double f(double x, double y, double z, double t) {
        double r225185 = z;
        double r225186 = -1.3353218113296246e-46;
        bool r225187 = r225185 <= r225186;
        double r225188 = x;
        double r225189 = 1.0;
        double r225190 = 1.0;
        double r225191 = exp(r225185);
        double r225192 = r225190 - r225191;
        double r225193 = y;
        double r225194 = r225192 * r225193;
        double r225195 = r225189 - r225194;
        double r225196 = log(r225195);
        double r225197 = r225196 * r225196;
        double r225198 = cbrt(r225197);
        double r225199 = cbrt(r225196);
        double r225200 = r225198 * r225199;
        double r225201 = 3.0;
        double r225202 = pow(r225200, r225201);
        double r225203 = cbrt(r225202);
        double r225204 = t;
        double r225205 = r225203 / r225204;
        double r225206 = r225188 - r225205;
        double r225207 = 3.3761128403185448e-108;
        bool r225208 = r225185 <= r225207;
        double r225209 = log(r225189);
        double r225210 = 0.5;
        double r225211 = 2.0;
        double r225212 = pow(r225185, r225211);
        double r225213 = r225210 * r225212;
        double r225214 = r225189 * r225185;
        double r225215 = r225213 + r225214;
        double r225216 = r225193 * r225215;
        double r225217 = r225209 + r225216;
        double r225218 = r225217 / r225204;
        double r225219 = r225188 - r225218;
        double r225220 = 0.5;
        double r225221 = r225220 * r225212;
        double r225222 = r225221 + r225185;
        double r225223 = r225193 * r225222;
        double r225224 = r225189 + r225223;
        double r225225 = log(r225224);
        double r225226 = r225225 / r225204;
        double r225227 = r225188 - r225226;
        double r225228 = r225208 ? r225219 : r225227;
        double r225229 = r225187 ? r225206 : r225228;
        return r225229;
}

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

Original24.9
Target16.0
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 3 regimes
  2. if z < -1.3353218113296246e-46

    1. Initial program 13.2

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

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

      \[\leadsto x - \frac{\log \left(1 - \color{blue}{\left(1 - e^{z}\right) \cdot y}\right)}{t}\]
    5. Using strategy rm
    6. Applied add-cbrt-cube12.4

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

      \[\leadsto x - \frac{\sqrt[3]{\color{blue}{{\left(\log \left(1 - \left(1 - e^{z}\right) \cdot y\right)\right)}^{3}}}}{t}\]
    8. Using strategy rm
    9. Applied add-cube-cbrt12.5

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

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

    if -1.3353218113296246e-46 < z < 3.3761128403185448e-108

    1. Initial program 30.6

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

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

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

    if 3.3761128403185448e-108 < z

    1. Initial program 32.7

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.335321811329624610683838289670382751461 \cdot 10^{-46}:\\ \;\;\;\;x - \frac{\sqrt[3]{{\left(\sqrt[3]{\log \left(1 - \left(1 - e^{z}\right) \cdot y\right) \cdot \log \left(1 - \left(1 - e^{z}\right) \cdot y\right)} \cdot \sqrt[3]{\log \left(1 - \left(1 - e^{z}\right) \cdot y\right)}\right)}^{3}}}{t}\\ \mathbf{elif}\;z \le 3.376112840318544795339777656673878871719 \cdot 10^{-108}:\\ \;\;\;\;x - \frac{\log 1 + y \cdot \left(0.5 \cdot {z}^{2} + 1 \cdot z\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(1 + y \cdot \left(\frac{1}{2} \cdot {z}^{2} + z\right)\right)}{t}\\ \end{array}\]

Reproduce

herbie shell --seed 2019308 
(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)))