Average Error: 24.9 → 8.7
Time: 7.1s
Precision: 64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \le -14.7380534391468725:\\ \;\;\;\;x - \frac{\log \left(\sqrt{\left(1 - y\right) + y \cdot e^{z}}\right) + \log \left(\sqrt{\left(1 - y\right) + y \cdot e^{z}}\right)}{t}\\ \mathbf{elif}\;z \le 2.229337771929231 \cdot 10^{-115}:\\ \;\;\;\;x - \frac{1}{\frac{t}{\log 1 + y \cdot \left(0.5 \cdot {z}^{2} + 1 \cdot z\right)}}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(1 + y \cdot \left(\frac{1}{2} \cdot {z}^{2} + z\right)\right)}{t}\\ \end{array}\]
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
\begin{array}{l}
\mathbf{if}\;z \le -14.7380534391468725:\\
\;\;\;\;x - \frac{\log \left(\sqrt{\left(1 - y\right) + y \cdot e^{z}}\right) + \log \left(\sqrt{\left(1 - y\right) + y \cdot e^{z}}\right)}{t}\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r282852 = x;
        double r282853 = 1.0;
        double r282854 = y;
        double r282855 = r282853 - r282854;
        double r282856 = z;
        double r282857 = exp(r282856);
        double r282858 = r282854 * r282857;
        double r282859 = r282855 + r282858;
        double r282860 = log(r282859);
        double r282861 = t;
        double r282862 = r282860 / r282861;
        double r282863 = r282852 - r282862;
        return r282863;
}

double f(double x, double y, double z, double t) {
        double r282864 = z;
        double r282865 = -14.738053439146872;
        bool r282866 = r282864 <= r282865;
        double r282867 = x;
        double r282868 = 1.0;
        double r282869 = y;
        double r282870 = r282868 - r282869;
        double r282871 = exp(r282864);
        double r282872 = r282869 * r282871;
        double r282873 = r282870 + r282872;
        double r282874 = sqrt(r282873);
        double r282875 = log(r282874);
        double r282876 = r282875 + r282875;
        double r282877 = t;
        double r282878 = r282876 / r282877;
        double r282879 = r282867 - r282878;
        double r282880 = 2.229337771929231e-115;
        bool r282881 = r282864 <= r282880;
        double r282882 = 1.0;
        double r282883 = log(r282868);
        double r282884 = 0.5;
        double r282885 = 2.0;
        double r282886 = pow(r282864, r282885);
        double r282887 = r282884 * r282886;
        double r282888 = r282868 * r282864;
        double r282889 = r282887 + r282888;
        double r282890 = r282869 * r282889;
        double r282891 = r282883 + r282890;
        double r282892 = r282877 / r282891;
        double r282893 = r282882 / r282892;
        double r282894 = r282867 - r282893;
        double r282895 = 0.5;
        double r282896 = r282895 * r282886;
        double r282897 = r282896 + r282864;
        double r282898 = r282869 * r282897;
        double r282899 = r282868 + r282898;
        double r282900 = log(r282899);
        double r282901 = r282900 / r282877;
        double r282902 = r282867 - r282901;
        double r282903 = r282881 ? r282894 : r282902;
        double r282904 = r282866 ? r282879 : r282903;
        return r282904;
}

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.9
Target16.0
Herbie8.7
\[\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 < -14.738053439146872

    1. Initial program 11.1

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

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

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

    if -14.738053439146872 < z < 2.229337771929231e-115

    1. Initial program 31.1

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

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

      \[\leadsto x - \frac{\color{blue}{\log 1 + y \cdot \left(0.5 \cdot {z}^{2} + 1 \cdot z\right)}}{t}\]
    4. Using strategy rm
    5. Applied clear-num6.6

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

    if 2.229337771929231e-115 < z

    1. Initial program 30.3

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

      \[\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. Simplified12.4

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

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

Reproduce

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