Average Error: 24.4 → 8.7
Time: 28.1s
Precision: 64
\[x - \frac{\log \left(\left(1.0 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;e^{z} \le 0.0:\\ \;\;\;\;x - \frac{\sqrt{\log \left(\left(1.0 - y\right) + y \cdot e^{z}\right)}}{\frac{t}{\sqrt{\log \left(\left(1.0 - y\right) + y \cdot e^{z}\right)}}}\\ \mathbf{else}:\\ \;\;\;\;x - \left(1.0 \cdot \frac{1}{\frac{\frac{t}{z}}{y}} + \frac{\log 1.0}{t}\right)\\ \end{array}\]
x - \frac{\log \left(\left(1.0 - y\right) + y \cdot e^{z}\right)}{t}
\begin{array}{l}
\mathbf{if}\;e^{z} \le 0.0:\\
\;\;\;\;x - \frac{\sqrt{\log \left(\left(1.0 - y\right) + y \cdot e^{z}\right)}}{\frac{t}{\sqrt{\log \left(\left(1.0 - y\right) + y \cdot e^{z}\right)}}}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r17535159 = x;
        double r17535160 = 1.0;
        double r17535161 = y;
        double r17535162 = r17535160 - r17535161;
        double r17535163 = z;
        double r17535164 = exp(r17535163);
        double r17535165 = r17535161 * r17535164;
        double r17535166 = r17535162 + r17535165;
        double r17535167 = log(r17535166);
        double r17535168 = t;
        double r17535169 = r17535167 / r17535168;
        double r17535170 = r17535159 - r17535169;
        return r17535170;
}

double f(double x, double y, double z, double t) {
        double r17535171 = z;
        double r17535172 = exp(r17535171);
        double r17535173 = 0.0;
        bool r17535174 = r17535172 <= r17535173;
        double r17535175 = x;
        double r17535176 = 1.0;
        double r17535177 = y;
        double r17535178 = r17535176 - r17535177;
        double r17535179 = r17535177 * r17535172;
        double r17535180 = r17535178 + r17535179;
        double r17535181 = log(r17535180);
        double r17535182 = sqrt(r17535181);
        double r17535183 = t;
        double r17535184 = r17535183 / r17535182;
        double r17535185 = r17535182 / r17535184;
        double r17535186 = r17535175 - r17535185;
        double r17535187 = 1.0;
        double r17535188 = r17535183 / r17535171;
        double r17535189 = r17535188 / r17535177;
        double r17535190 = r17535187 / r17535189;
        double r17535191 = r17535176 * r17535190;
        double r17535192 = log(r17535176);
        double r17535193 = r17535192 / r17535183;
        double r17535194 = r17535191 + r17535193;
        double r17535195 = r17535175 - r17535194;
        double r17535196 = r17535174 ? r17535186 : r17535195;
        return r17535196;
}

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.4
Target16.6
Herbie8.7
\[\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 2 regimes
  2. if (exp z) < 0.0

    1. Initial program 12.2

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

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

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

    if 0.0 < (exp z)

    1. Initial program 29.7

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

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

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

      \[\leadsto \color{blue}{x - \left(1.0 \cdot \frac{z \cdot y}{t} + \frac{\log 1.0}{t}\right)}\]
    5. Using strategy rm
    6. Applied clear-num7.8

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

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

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

Reproduce

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