Average Error: 24.7 → 8.9
Time: 37.0s
Precision: 64
\[x - \frac{\log \left(\left(1.0 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \le -6.220564919949488 \cdot 10^{-06}:\\ \;\;\;\;x - \frac{\log \left(\sqrt[3]{e^{z} \cdot y + \left(1.0 - y\right)} \cdot \sqrt[3]{e^{z} \cdot y + \left(1.0 - y\right)}\right) + \log \left(\sqrt[3]{e^{z} \cdot y + \left(1.0 - y\right)}\right)}{t}\\ \mathbf{elif}\;z \le -7.588076395555027 \cdot 10^{-93}:\\ \;\;\;\;x - \frac{\log \left(\left(\left(z \cdot \frac{1}{2}\right) \cdot z + z\right) \cdot y + 1.0\right)}{t}\\ \mathbf{elif}\;z \le 1.6081434733570535 \cdot 10^{-109}:\\ \;\;\;\;x - \frac{\log 1.0 + \left(z \cdot \left(1.0 + 0.5 \cdot z\right)\right) \cdot y}{t}\\ \mathbf{elif}\;z \le 9.047911306874446 \cdot 10^{-17}:\\ \;\;\;\;x - \frac{\log \left(\left(\left(z \cdot \frac{1}{2}\right) \cdot z + z\right) \cdot y + 1.0\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log 1.0 + \left(z \cdot \left(1.0 + 0.5 \cdot z\right)\right) \cdot y}{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 -6.220564919949488 \cdot 10^{-06}:\\
\;\;\;\;x - \frac{\log \left(\sqrt[3]{e^{z} \cdot y + \left(1.0 - y\right)} \cdot \sqrt[3]{e^{z} \cdot y + \left(1.0 - y\right)}\right) + \log \left(\sqrt[3]{e^{z} \cdot y + \left(1.0 - y\right)}\right)}{t}\\

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

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

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r18097869 = x;
        double r18097870 = 1.0;
        double r18097871 = y;
        double r18097872 = r18097870 - r18097871;
        double r18097873 = z;
        double r18097874 = exp(r18097873);
        double r18097875 = r18097871 * r18097874;
        double r18097876 = r18097872 + r18097875;
        double r18097877 = log(r18097876);
        double r18097878 = t;
        double r18097879 = r18097877 / r18097878;
        double r18097880 = r18097869 - r18097879;
        return r18097880;
}

double f(double x, double y, double z, double t) {
        double r18097881 = z;
        double r18097882 = -6.220564919949488e-06;
        bool r18097883 = r18097881 <= r18097882;
        double r18097884 = x;
        double r18097885 = exp(r18097881);
        double r18097886 = y;
        double r18097887 = r18097885 * r18097886;
        double r18097888 = 1.0;
        double r18097889 = r18097888 - r18097886;
        double r18097890 = r18097887 + r18097889;
        double r18097891 = cbrt(r18097890);
        double r18097892 = r18097891 * r18097891;
        double r18097893 = log(r18097892);
        double r18097894 = log(r18097891);
        double r18097895 = r18097893 + r18097894;
        double r18097896 = t;
        double r18097897 = r18097895 / r18097896;
        double r18097898 = r18097884 - r18097897;
        double r18097899 = -7.588076395555027e-93;
        bool r18097900 = r18097881 <= r18097899;
        double r18097901 = 0.5;
        double r18097902 = r18097881 * r18097901;
        double r18097903 = r18097902 * r18097881;
        double r18097904 = r18097903 + r18097881;
        double r18097905 = r18097904 * r18097886;
        double r18097906 = r18097905 + r18097888;
        double r18097907 = log(r18097906);
        double r18097908 = r18097907 / r18097896;
        double r18097909 = r18097884 - r18097908;
        double r18097910 = 1.6081434733570535e-109;
        bool r18097911 = r18097881 <= r18097910;
        double r18097912 = log(r18097888);
        double r18097913 = 0.5;
        double r18097914 = r18097913 * r18097881;
        double r18097915 = r18097888 + r18097914;
        double r18097916 = r18097881 * r18097915;
        double r18097917 = r18097916 * r18097886;
        double r18097918 = r18097912 + r18097917;
        double r18097919 = r18097918 / r18097896;
        double r18097920 = r18097884 - r18097919;
        double r18097921 = 9.047911306874446e-17;
        bool r18097922 = r18097881 <= r18097921;
        double r18097923 = r18097922 ? r18097909 : r18097920;
        double r18097924 = r18097911 ? r18097920 : r18097923;
        double r18097925 = r18097900 ? r18097909 : r18097924;
        double r18097926 = r18097883 ? r18097898 : r18097925;
        return r18097926;
}

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.5
Herbie8.9
\[\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 < -6.220564919949488e-06

    1. Initial program 12.9

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

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

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

    if -6.220564919949488e-06 < z < -7.588076395555027e-93 or 1.6081434733570535e-109 < z < 9.047911306874446e-17

    1. Initial program 30.2

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

      \[\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. Simplified11.3

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

    if -7.588076395555027e-93 < z < 1.6081434733570535e-109 or 9.047911306874446e-17 < z

    1. Initial program 29.8

      \[x - \frac{\log \left(\left(1.0 - y\right) + y \cdot e^{z}\right)}{t}\]
    2. Taylor expanded around 0 5.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. Simplified5.6

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -6.220564919949488 \cdot 10^{-06}:\\ \;\;\;\;x - \frac{\log \left(\sqrt[3]{e^{z} \cdot y + \left(1.0 - y\right)} \cdot \sqrt[3]{e^{z} \cdot y + \left(1.0 - y\right)}\right) + \log \left(\sqrt[3]{e^{z} \cdot y + \left(1.0 - y\right)}\right)}{t}\\ \mathbf{elif}\;z \le -7.588076395555027 \cdot 10^{-93}:\\ \;\;\;\;x - \frac{\log \left(\left(\left(z \cdot \frac{1}{2}\right) \cdot z + z\right) \cdot y + 1.0\right)}{t}\\ \mathbf{elif}\;z \le 1.6081434733570535 \cdot 10^{-109}:\\ \;\;\;\;x - \frac{\log 1.0 + \left(z \cdot \left(1.0 + 0.5 \cdot z\right)\right) \cdot y}{t}\\ \mathbf{elif}\;z \le 9.047911306874446 \cdot 10^{-17}:\\ \;\;\;\;x - \frac{\log \left(\left(\left(z \cdot \frac{1}{2}\right) \cdot z + z\right) \cdot y + 1.0\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log 1.0 + \left(z \cdot \left(1.0 + 0.5 \cdot z\right)\right) \cdot y}{t}\\ \end{array}\]

Reproduce

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