Average Error: 25.1 → 7.8
Time: 6.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.35259782446174889 \cdot 10^{-15}:\\ \;\;\;\;x - \frac{\log \left(\left(1 - y\right) + \left(\sqrt[3]{y \cdot e^{z}} \cdot \sqrt[3]{y \cdot e^{z}}\right) \cdot \sqrt[3]{y \cdot e^{z}}\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \left(1 \cdot \left(\frac{z}{t} \cdot y\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}\;z \le -1.35259782446174889 \cdot 10^{-15}:\\
\;\;\;\;x - \frac{\log \left(\left(1 - y\right) + \left(\sqrt[3]{y \cdot e^{z}} \cdot \sqrt[3]{y \cdot e^{z}}\right) \cdot \sqrt[3]{y \cdot e^{z}}\right)}{t}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r312030 = x;
        double r312031 = 1.0;
        double r312032 = y;
        double r312033 = r312031 - r312032;
        double r312034 = z;
        double r312035 = exp(r312034);
        double r312036 = r312032 * r312035;
        double r312037 = r312033 + r312036;
        double r312038 = log(r312037);
        double r312039 = t;
        double r312040 = r312038 / r312039;
        double r312041 = r312030 - r312040;
        return r312041;
}

double f(double x, double y, double z, double t) {
        double r312042 = z;
        double r312043 = -1.3525978244617489e-15;
        bool r312044 = r312042 <= r312043;
        double r312045 = x;
        double r312046 = 1.0;
        double r312047 = y;
        double r312048 = r312046 - r312047;
        double r312049 = exp(r312042);
        double r312050 = r312047 * r312049;
        double r312051 = cbrt(r312050);
        double r312052 = r312051 * r312051;
        double r312053 = r312052 * r312051;
        double r312054 = r312048 + r312053;
        double r312055 = log(r312054);
        double r312056 = t;
        double r312057 = r312055 / r312056;
        double r312058 = r312045 - r312057;
        double r312059 = r312042 / r312056;
        double r312060 = r312059 * r312047;
        double r312061 = r312046 * r312060;
        double r312062 = log(r312046);
        double r312063 = r312062 / r312056;
        double r312064 = r312061 + r312063;
        double r312065 = r312045 - r312064;
        double r312066 = r312044 ? r312058 : r312065;
        return r312066;
}

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.1
Target16.3
Herbie7.8
\[\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 z < -1.3525978244617489e-15

    1. Initial program 11.5

      \[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(\left(1 - y\right) + \color{blue}{\left(\sqrt[3]{y \cdot e^{z}} \cdot \sqrt[3]{y \cdot e^{z}}\right) \cdot \sqrt[3]{y \cdot e^{z}}}\right)}{t}\]

    if -1.3525978244617489e-15 < z

    1. Initial program 31.3

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

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

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

      \[\leadsto \color{blue}{x - \left(1 \cdot \frac{z \cdot y}{t} + \frac{\log 1}{t}\right)}\]
    5. Using strategy rm
    6. Applied associate-/l*8.7

      \[\leadsto x - \left(1 \cdot \color{blue}{\frac{z}{\frac{t}{y}}} + \frac{\log 1}{t}\right)\]
    7. Using strategy rm
    8. Applied associate-/r/6.2

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

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

Reproduce

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