Average Error: 25.4 → 8.6
Time: 22.4s
Precision: 64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \le -0.3115017031960372051457852649036794900894:\\ \;\;\;\;x - \frac{1}{\frac{t}{\log \left(1 + \left(e^{z} \cdot y - y\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{1}{\frac{t}{y \cdot \left(0.5 \cdot {z}^{2} + 1 \cdot z\right) + \log 1}}\\ \end{array}\]
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
\begin{array}{l}
\mathbf{if}\;z \le -0.3115017031960372051457852649036794900894:\\
\;\;\;\;x - \frac{1}{\frac{t}{\log \left(1 + \left(e^{z} \cdot y - y\right)\right)}}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r200178 = x;
        double r200179 = 1.0;
        double r200180 = y;
        double r200181 = r200179 - r200180;
        double r200182 = z;
        double r200183 = exp(r200182);
        double r200184 = r200180 * r200183;
        double r200185 = r200181 + r200184;
        double r200186 = log(r200185);
        double r200187 = t;
        double r200188 = r200186 / r200187;
        double r200189 = r200178 - r200188;
        return r200189;
}

double f(double x, double y, double z, double t) {
        double r200190 = z;
        double r200191 = -0.3115017031960372;
        bool r200192 = r200190 <= r200191;
        double r200193 = x;
        double r200194 = 1.0;
        double r200195 = t;
        double r200196 = 1.0;
        double r200197 = exp(r200190);
        double r200198 = y;
        double r200199 = r200197 * r200198;
        double r200200 = r200199 - r200198;
        double r200201 = r200196 + r200200;
        double r200202 = log(r200201);
        double r200203 = r200195 / r200202;
        double r200204 = r200194 / r200203;
        double r200205 = r200193 - r200204;
        double r200206 = 0.5;
        double r200207 = 2.0;
        double r200208 = pow(r200190, r200207);
        double r200209 = r200206 * r200208;
        double r200210 = r200196 * r200190;
        double r200211 = r200209 + r200210;
        double r200212 = r200198 * r200211;
        double r200213 = log(r200196);
        double r200214 = r200212 + r200213;
        double r200215 = r200195 / r200214;
        double r200216 = r200194 / r200215;
        double r200217 = r200193 - r200216;
        double r200218 = r200192 ? r200205 : r200217;
        return r200218;
}

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.5
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 z < -0.3115017031960372

    1. Initial program 10.9

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

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

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

      \[\leadsto x - \frac{\log \left(1 + \color{blue}{\left(e^{z} \cdot y - y\right)}\right)}{t}\]
    6. Using strategy rm
    7. Applied clear-num10.9

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

    if -0.3115017031960372 < z

    1. Initial program 31.3

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

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

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

      \[\leadsto x - \frac{\log \left(1 + \color{blue}{\left(e^{z} \cdot y - y\right)}\right)}{t}\]
    6. Using strategy rm
    7. Applied clear-num16.8

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

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

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

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

Reproduce

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