Average Error: 25.2 → 9.0
Time: 7.0s
Precision: 64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \le -13648522833977.074:\\ \;\;\;\;x - \log \left(1 + \left(e^{z} - 1\right) \cdot y\right) \cdot \frac{1}{t}\\ \mathbf{elif}\;z \le -3.60856869199622405 \cdot 10^{-154}:\\ \;\;\;\;x - \frac{\log \left(1 + \left({z}^{2} \cdot \left(\frac{1}{2} + z \cdot \frac{1}{6}\right) + z\right) \cdot y\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \left(1 \cdot \frac{z \cdot y}{t} + \left(\frac{\log 1}{t} + 0.5 \cdot \frac{{z}^{2} \cdot y}{t}\right)\right)\\ \end{array}\]
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
\begin{array}{l}
\mathbf{if}\;z \le -13648522833977.074:\\
\;\;\;\;x - \log \left(1 + \left(e^{z} - 1\right) \cdot y\right) \cdot \frac{1}{t}\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r318955 = x;
        double r318956 = 1.0;
        double r318957 = y;
        double r318958 = r318956 - r318957;
        double r318959 = z;
        double r318960 = exp(r318959);
        double r318961 = r318957 * r318960;
        double r318962 = r318958 + r318961;
        double r318963 = log(r318962);
        double r318964 = t;
        double r318965 = r318963 / r318964;
        double r318966 = r318955 - r318965;
        return r318966;
}

double f(double x, double y, double z, double t) {
        double r318967 = z;
        double r318968 = -13648522833977.074;
        bool r318969 = r318967 <= r318968;
        double r318970 = x;
        double r318971 = 1.0;
        double r318972 = exp(r318967);
        double r318973 = 1.0;
        double r318974 = r318972 - r318973;
        double r318975 = y;
        double r318976 = r318974 * r318975;
        double r318977 = r318971 + r318976;
        double r318978 = log(r318977);
        double r318979 = t;
        double r318980 = r318973 / r318979;
        double r318981 = r318978 * r318980;
        double r318982 = r318970 - r318981;
        double r318983 = -3.608568691996224e-154;
        bool r318984 = r318967 <= r318983;
        double r318985 = 2.0;
        double r318986 = pow(r318967, r318985);
        double r318987 = 0.5;
        double r318988 = 0.16666666666666666;
        double r318989 = r318967 * r318988;
        double r318990 = r318987 + r318989;
        double r318991 = r318986 * r318990;
        double r318992 = r318991 + r318967;
        double r318993 = r318992 * r318975;
        double r318994 = r318971 + r318993;
        double r318995 = log(r318994);
        double r318996 = r318995 / r318979;
        double r318997 = r318970 - r318996;
        double r318998 = r318967 * r318975;
        double r318999 = r318998 / r318979;
        double r319000 = r318971 * r318999;
        double r319001 = log(r318971);
        double r319002 = r319001 / r318979;
        double r319003 = 0.5;
        double r319004 = r318986 * r318975;
        double r319005 = r319004 / r318979;
        double r319006 = r319003 * r319005;
        double r319007 = r319002 + r319006;
        double r319008 = r319000 + r319007;
        double r319009 = r318970 - r319008;
        double r319010 = r318984 ? r318997 : r319009;
        double r319011 = r318969 ? r318982 : r319010;
        return r319011;
}

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.2
Target15.6
Herbie9.0
\[\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 3 regimes
  2. if z < -13648522833977.074

    1. Initial program 12.0

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

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

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

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

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

    if -13648522833977.074 < z < -3.608568691996224e-154

    1. Initial program 29.1

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

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

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

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

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

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

    if -3.608568691996224e-154 < z

    1. Initial program 30.8

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

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

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

Reproduce

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