Average Error: 24.7 → 9.0
Time: 26.0s
Precision: 64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \le -8.353666488902590411260926095415868530836 \cdot 10^{-6}:\\ \;\;\;\;x - \frac{\log \left(\left(1 - y\right) + \left(y \cdot \left(\sqrt[3]{e^{z}} \cdot \sqrt[3]{e^{z}}\right)\right) \cdot \sqrt[3]{e^{z}}\right)}{t}\\ \mathbf{elif}\;z \le -1.628486441959117828114509818342344019672 \cdot 10^{-38}:\\ \;\;\;\;x - \frac{\log \left(1 + y \cdot \left(z + \frac{1}{2} \cdot {z}^{2}\right)\right)}{t}\\ \mathbf{elif}\;z \le 2.384499893983490228652173517457022713963 \cdot 10^{-39}:\\ \;\;\;\;x - \left(1 \cdot \frac{z \cdot y}{t} + \left(\frac{\log 1}{t} + 0.5 \cdot \frac{\log \left(e^{{z}^{2} \cdot y}\right)}{t}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x - \left(1 \cdot \left(z \cdot \frac{y}{t}\right) + \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 -8.353666488902590411260926095415868530836 \cdot 10^{-6}:\\
\;\;\;\;x - \frac{\log \left(\left(1 - y\right) + \left(y \cdot \left(\sqrt[3]{e^{z}} \cdot \sqrt[3]{e^{z}}\right)\right) \cdot \sqrt[3]{e^{z}}\right)}{t}\\

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

\mathbf{elif}\;z \le 2.384499893983490228652173517457022713963 \cdot 10^{-39}:\\
\;\;\;\;x - \left(1 \cdot \frac{z \cdot y}{t} + \left(\frac{\log 1}{t} + 0.5 \cdot \frac{\log \left(e^{{z}^{2} \cdot y}\right)}{t}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;x - \left(1 \cdot \left(z \cdot \frac{y}{t}\right) + \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 r219902 = x;
        double r219903 = 1.0;
        double r219904 = y;
        double r219905 = r219903 - r219904;
        double r219906 = z;
        double r219907 = exp(r219906);
        double r219908 = r219904 * r219907;
        double r219909 = r219905 + r219908;
        double r219910 = log(r219909);
        double r219911 = t;
        double r219912 = r219910 / r219911;
        double r219913 = r219902 - r219912;
        return r219913;
}

double f(double x, double y, double z, double t) {
        double r219914 = z;
        double r219915 = -8.35366648890259e-06;
        bool r219916 = r219914 <= r219915;
        double r219917 = x;
        double r219918 = 1.0;
        double r219919 = y;
        double r219920 = r219918 - r219919;
        double r219921 = exp(r219914);
        double r219922 = cbrt(r219921);
        double r219923 = r219922 * r219922;
        double r219924 = r219919 * r219923;
        double r219925 = r219924 * r219922;
        double r219926 = r219920 + r219925;
        double r219927 = log(r219926);
        double r219928 = t;
        double r219929 = r219927 / r219928;
        double r219930 = r219917 - r219929;
        double r219931 = -1.6284864419591178e-38;
        bool r219932 = r219914 <= r219931;
        double r219933 = 0.5;
        double r219934 = 2.0;
        double r219935 = pow(r219914, r219934);
        double r219936 = r219933 * r219935;
        double r219937 = r219914 + r219936;
        double r219938 = r219919 * r219937;
        double r219939 = r219918 + r219938;
        double r219940 = log(r219939);
        double r219941 = r219940 / r219928;
        double r219942 = r219917 - r219941;
        double r219943 = 2.3844998939834902e-39;
        bool r219944 = r219914 <= r219943;
        double r219945 = r219914 * r219919;
        double r219946 = r219945 / r219928;
        double r219947 = r219918 * r219946;
        double r219948 = log(r219918);
        double r219949 = r219948 / r219928;
        double r219950 = 0.5;
        double r219951 = r219935 * r219919;
        double r219952 = exp(r219951);
        double r219953 = log(r219952);
        double r219954 = r219953 / r219928;
        double r219955 = r219950 * r219954;
        double r219956 = r219949 + r219955;
        double r219957 = r219947 + r219956;
        double r219958 = r219917 - r219957;
        double r219959 = r219919 / r219928;
        double r219960 = r219914 * r219959;
        double r219961 = r219918 * r219960;
        double r219962 = r219951 / r219928;
        double r219963 = r219950 * r219962;
        double r219964 = r219949 + r219963;
        double r219965 = r219961 + r219964;
        double r219966 = r219917 - r219965;
        double r219967 = r219944 ? r219958 : r219966;
        double r219968 = r219932 ? r219942 : r219967;
        double r219969 = r219916 ? r219930 : r219968;
        return r219969;
}

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.7
Target16.3
Herbie9.0
\[\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 4 regimes
  2. if z < -8.35366648890259e-06

    1. Initial program 11.2

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

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

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

    if -8.35366648890259e-06 < z < -1.6284864419591178e-38

    1. Initial program 28.6

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

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

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

    if -1.6284864419591178e-38 < z < 2.3844998939834902e-39

    1. Initial program 30.6

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

      \[\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. Using strategy rm
    4. Applied add-log-exp7.0

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

    if 2.3844998939834902e-39 < z

    1. Initial program 28.9

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

      \[\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. Using strategy rm
    4. Applied *-un-lft-identity18.0

      \[\leadsto x - \left(1 \cdot \frac{z \cdot y}{\color{blue}{1 \cdot t}} + \left(\frac{\log 1}{t} + 0.5 \cdot \frac{{z}^{2} \cdot y}{t}\right)\right)\]
    5. Applied times-frac18.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -8.353666488902590411260926095415868530836 \cdot 10^{-6}:\\ \;\;\;\;x - \frac{\log \left(\left(1 - y\right) + \left(y \cdot \left(\sqrt[3]{e^{z}} \cdot \sqrt[3]{e^{z}}\right)\right) \cdot \sqrt[3]{e^{z}}\right)}{t}\\ \mathbf{elif}\;z \le -1.628486441959117828114509818342344019672 \cdot 10^{-38}:\\ \;\;\;\;x - \frac{\log \left(1 + y \cdot \left(z + \frac{1}{2} \cdot {z}^{2}\right)\right)}{t}\\ \mathbf{elif}\;z \le 2.384499893983490228652173517457022713963 \cdot 10^{-39}:\\ \;\;\;\;x - \left(1 \cdot \frac{z \cdot y}{t} + \left(\frac{\log 1}{t} + 0.5 \cdot \frac{\log \left(e^{{z}^{2} \cdot y}\right)}{t}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x - \left(1 \cdot \left(z \cdot \frac{y}{t}\right) + \left(\frac{\log 1}{t} + 0.5 \cdot \frac{{z}^{2} \cdot y}{t}\right)\right)\\ \end{array}\]

Reproduce

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