Average Error: 24.2 → 8.1
Time: 23.8s
Precision: 64
\[x - \frac{\log \left(\left(1.0 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \le -804280505547.8507:\\ \;\;\;\;x - \log \left(e^{z} \cdot y + \left(1.0 - y\right)\right) \cdot \frac{1}{t}\\ \mathbf{elif}\;z \le 2.5098281878527637 \cdot 10^{-138}:\\ \;\;\;\;x - \left(y \cdot \left(z \cdot \frac{1.0}{t}\right) + \left(\frac{0.5}{\frac{t}{z \cdot \left(y \cdot z\right)}} + \frac{\log 1.0}{t}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(1.0 + \left(z + \left(\frac{1}{2} \cdot z\right) \cdot z\right) \cdot y\right)}{t}\\ \end{array}\]
x - \frac{\log \left(\left(1.0 - y\right) + y \cdot e^{z}\right)}{t}
\begin{array}{l}
\mathbf{if}\;z \le -804280505547.8507:\\
\;\;\;\;x - \log \left(e^{z} \cdot y + \left(1.0 - y\right)\right) \cdot \frac{1}{t}\\

\mathbf{elif}\;z \le 2.5098281878527637 \cdot 10^{-138}:\\
\;\;\;\;x - \left(y \cdot \left(z \cdot \frac{1.0}{t}\right) + \left(\frac{0.5}{\frac{t}{z \cdot \left(y \cdot z\right)}} + \frac{\log 1.0}{t}\right)\right)\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r14781151 = x;
        double r14781152 = 1.0;
        double r14781153 = y;
        double r14781154 = r14781152 - r14781153;
        double r14781155 = z;
        double r14781156 = exp(r14781155);
        double r14781157 = r14781153 * r14781156;
        double r14781158 = r14781154 + r14781157;
        double r14781159 = log(r14781158);
        double r14781160 = t;
        double r14781161 = r14781159 / r14781160;
        double r14781162 = r14781151 - r14781161;
        return r14781162;
}

double f(double x, double y, double z, double t) {
        double r14781163 = z;
        double r14781164 = -804280505547.8507;
        bool r14781165 = r14781163 <= r14781164;
        double r14781166 = x;
        double r14781167 = exp(r14781163);
        double r14781168 = y;
        double r14781169 = r14781167 * r14781168;
        double r14781170 = 1.0;
        double r14781171 = r14781170 - r14781168;
        double r14781172 = r14781169 + r14781171;
        double r14781173 = log(r14781172);
        double r14781174 = 1.0;
        double r14781175 = t;
        double r14781176 = r14781174 / r14781175;
        double r14781177 = r14781173 * r14781176;
        double r14781178 = r14781166 - r14781177;
        double r14781179 = 2.5098281878527637e-138;
        bool r14781180 = r14781163 <= r14781179;
        double r14781181 = r14781170 / r14781175;
        double r14781182 = r14781163 * r14781181;
        double r14781183 = r14781168 * r14781182;
        double r14781184 = 0.5;
        double r14781185 = r14781168 * r14781163;
        double r14781186 = r14781163 * r14781185;
        double r14781187 = r14781175 / r14781186;
        double r14781188 = r14781184 / r14781187;
        double r14781189 = log(r14781170);
        double r14781190 = r14781189 / r14781175;
        double r14781191 = r14781188 + r14781190;
        double r14781192 = r14781183 + r14781191;
        double r14781193 = r14781166 - r14781192;
        double r14781194 = 0.5;
        double r14781195 = r14781194 * r14781163;
        double r14781196 = r14781195 * r14781163;
        double r14781197 = r14781163 + r14781196;
        double r14781198 = r14781197 * r14781168;
        double r14781199 = r14781170 + r14781198;
        double r14781200 = log(r14781199);
        double r14781201 = r14781200 / r14781175;
        double r14781202 = r14781166 - r14781201;
        double r14781203 = r14781180 ? r14781193 : r14781202;
        double r14781204 = r14781165 ? r14781178 : r14781203;
        return r14781204;
}

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.2
Target15.9
Herbie8.1
\[\begin{array}{l} \mathbf{if}\;z \lt -2.8874623088207947 \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.0}{z}}{z \cdot z}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(1.0 + z \cdot y\right)}{t}\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if z < -804280505547.8507

    1. Initial program 10.8

      \[x - \frac{\log \left(\left(1.0 - y\right) + y \cdot e^{z}\right)}{t}\]
    2. Using strategy rm
    3. Applied div-inv10.8

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

    if -804280505547.8507 < z < 2.5098281878527637e-138

    1. Initial program 29.2

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

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

      \[\leadsto x - \color{blue}{\left(\frac{\left(y \cdot z\right) \cdot 1.0}{t} + \left(\frac{0.5}{\frac{t}{z \cdot \left(z \cdot y\right)}} + \frac{\log 1.0}{t}\right)\right)}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity6.5

      \[\leadsto x - \left(\frac{\left(y \cdot z\right) \cdot 1.0}{\color{blue}{1 \cdot t}} + \left(\frac{0.5}{\frac{t}{z \cdot \left(z \cdot y\right)}} + \frac{\log 1.0}{t}\right)\right)\]
    6. Applied times-frac6.5

      \[\leadsto x - \left(\color{blue}{\frac{y \cdot z}{1} \cdot \frac{1.0}{t}} + \left(\frac{0.5}{\frac{t}{z \cdot \left(z \cdot y\right)}} + \frac{\log 1.0}{t}\right)\right)\]
    7. Simplified6.5

      \[\leadsto x - \left(\color{blue}{\left(y \cdot z\right)} \cdot \frac{1.0}{t} + \left(\frac{0.5}{\frac{t}{z \cdot \left(z \cdot y\right)}} + \frac{\log 1.0}{t}\right)\right)\]
    8. Using strategy rm
    9. Applied associate-*l*5.8

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

    if 2.5098281878527637e-138 < z

    1. Initial program 29.4

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -804280505547.8507:\\ \;\;\;\;x - \log \left(e^{z} \cdot y + \left(1.0 - y\right)\right) \cdot \frac{1}{t}\\ \mathbf{elif}\;z \le 2.5098281878527637 \cdot 10^{-138}:\\ \;\;\;\;x - \left(y \cdot \left(z \cdot \frac{1.0}{t}\right) + \left(\frac{0.5}{\frac{t}{z \cdot \left(y \cdot z\right)}} + \frac{\log 1.0}{t}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(1.0 + \left(z + \left(\frac{1}{2} \cdot z\right) \cdot z\right) \cdot y\right)}{t}\\ \end{array}\]

Reproduce

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