Average Error: 24.4 → 8.7
Time: 20.6s
Precision: 64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \le -8059157933548560711680:\\ \;\;\;\;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 3.301941885926770582986010706187964104802 \cdot 10^{-40}:\\ \;\;\;\;x - \left(1 \cdot \frac{z \cdot y}{t} + \frac{\log 1}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(1 + y \cdot \left(z + \frac{1}{2} \cdot {z}^{2}\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 -8059157933548560711680:\\
\;\;\;\;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 3.301941885926770582986010706187964104802 \cdot 10^{-40}:\\
\;\;\;\;x - \left(1 \cdot \frac{z \cdot y}{t} + \frac{\log 1}{t}\right)\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r198964 = x;
        double r198965 = 1.0;
        double r198966 = y;
        double r198967 = r198965 - r198966;
        double r198968 = z;
        double r198969 = exp(r198968);
        double r198970 = r198966 * r198969;
        double r198971 = r198967 + r198970;
        double r198972 = log(r198971);
        double r198973 = t;
        double r198974 = r198972 / r198973;
        double r198975 = r198964 - r198974;
        return r198975;
}

double f(double x, double y, double z, double t) {
        double r198976 = z;
        double r198977 = -8.059157933548561e+21;
        bool r198978 = r198976 <= r198977;
        double r198979 = x;
        double r198980 = 1.0;
        double r198981 = y;
        double r198982 = r198980 - r198981;
        double r198983 = exp(r198976);
        double r198984 = r198981 * r198983;
        double r198985 = r198982 + r198984;
        double r198986 = sqrt(r198985);
        double r198987 = log(r198986);
        double r198988 = r198987 + r198987;
        double r198989 = t;
        double r198990 = r198988 / r198989;
        double r198991 = r198979 - r198990;
        double r198992 = 3.3019418859267706e-40;
        bool r198993 = r198976 <= r198992;
        double r198994 = r198976 * r198981;
        double r198995 = r198994 / r198989;
        double r198996 = r198980 * r198995;
        double r198997 = log(r198980);
        double r198998 = r198997 / r198989;
        double r198999 = r198996 + r198998;
        double r199000 = r198979 - r198999;
        double r199001 = 0.5;
        double r199002 = 2.0;
        double r199003 = pow(r198976, r199002);
        double r199004 = r199001 * r199003;
        double r199005 = r198976 + r199004;
        double r199006 = r198981 * r199005;
        double r199007 = r198980 + r199006;
        double r199008 = log(r199007);
        double r199009 = r199008 / r198989;
        double r199010 = r198979 - r199009;
        double r199011 = r198993 ? r199000 : r199010;
        double r199012 = r198978 ? r198991 : r199011;
        return r199012;
}

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.4
Target16.5
Herbie8.7
\[\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 3 regimes
  2. if z < -8.059157933548561e+21

    1. Initial program 11.0

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

      \[\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.0

      \[\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 -8.059157933548561e+21 < z < 3.3019418859267706e-40

    1. Initial program 29.7

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

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

      \[\leadsto x - \frac{1}{\color{blue}{\frac{t}{\left(z \cdot \left(1 + 0.5 \cdot z\right)\right) \cdot y + \log 1}}}\]
    7. Using strategy rm
    8. Applied div-inv7.7

      \[\leadsto x - \frac{1}{\color{blue}{t \cdot \frac{1}{\left(z \cdot \left(1 + 0.5 \cdot z\right)\right) \cdot y + \log 1}}}\]
    9. Applied add-cube-cbrt7.7

      \[\leadsto x - \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{t \cdot \frac{1}{\left(z \cdot \left(1 + 0.5 \cdot z\right)\right) \cdot y + \log 1}}\]
    10. Applied times-frac7.7

      \[\leadsto x - \color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{t} \cdot \frac{\sqrt[3]{1}}{\frac{1}{\left(z \cdot \left(1 + 0.5 \cdot z\right)\right) \cdot y + \log 1}}}\]
    11. Simplified7.7

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

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

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

    if 3.3019418859267706e-40 < z

    1. Initial program 25.6

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -8059157933548560711680:\\ \;\;\;\;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 3.301941885926770582986010706187964104802 \cdot 10^{-40}:\\ \;\;\;\;x - \left(1 \cdot \frac{z \cdot y}{t} + \frac{\log 1}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(1 + y \cdot \left(z + \frac{1}{2} \cdot {z}^{2}\right)\right)}{t}\\ \end{array}\]

Reproduce

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