Average Error: 24.4 → 7.9
Time: 20.4s
Precision: 64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \le -200.7607659959793409143458120524883270264:\\ \;\;\;\;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.010313960630697195821945826958268942993 \cdot 10^{-40}:\\ \;\;\;\;x - \left(\frac{z \cdot \left(1 + 0.5 \cdot z\right)}{t} \cdot y + \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 -200.7607659959793409143458120524883270264:\\
\;\;\;\;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.010313960630697195821945826958268942993 \cdot 10^{-40}:\\
\;\;\;\;x - \left(\frac{z \cdot \left(1 + 0.5 \cdot z\right)}{t} \cdot y + \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 r224823 = x;
        double r224824 = 1.0;
        double r224825 = y;
        double r224826 = r224824 - r224825;
        double r224827 = z;
        double r224828 = exp(r224827);
        double r224829 = r224825 * r224828;
        double r224830 = r224826 + r224829;
        double r224831 = log(r224830);
        double r224832 = t;
        double r224833 = r224831 / r224832;
        double r224834 = r224823 - r224833;
        return r224834;
}

double f(double x, double y, double z, double t) {
        double r224835 = z;
        double r224836 = -200.76076599597934;
        bool r224837 = r224835 <= r224836;
        double r224838 = x;
        double r224839 = 1.0;
        double r224840 = y;
        double r224841 = r224839 - r224840;
        double r224842 = exp(r224835);
        double r224843 = r224840 * r224842;
        double r224844 = r224841 + r224843;
        double r224845 = sqrt(r224844);
        double r224846 = log(r224845);
        double r224847 = r224846 + r224846;
        double r224848 = t;
        double r224849 = r224847 / r224848;
        double r224850 = r224838 - r224849;
        double r224851 = 2.010313960630697e-40;
        bool r224852 = r224835 <= r224851;
        double r224853 = 0.5;
        double r224854 = r224853 * r224835;
        double r224855 = r224839 + r224854;
        double r224856 = r224835 * r224855;
        double r224857 = r224856 / r224848;
        double r224858 = r224857 * r224840;
        double r224859 = log(r224839);
        double r224860 = r224859 / r224848;
        double r224861 = r224858 + r224860;
        double r224862 = r224838 - r224861;
        double r224863 = 0.5;
        double r224864 = 2.0;
        double r224865 = pow(r224835, r224864);
        double r224866 = r224863 * r224865;
        double r224867 = r224835 + r224866;
        double r224868 = r224840 * r224867;
        double r224869 = r224839 + r224868;
        double r224870 = log(r224869);
        double r224871 = r224870 / r224848;
        double r224872 = r224838 - r224871;
        double r224873 = r224852 ? r224862 : r224872;
        double r224874 = r224837 ? r224850 : r224873;
        return r224874;
}

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
Herbie7.9
\[\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 < -200.76076599597934

    1. Initial program 11.3

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

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

      \[\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 -200.76076599597934 < z < 2.010313960630697e-40

    1. Initial program 30.1

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

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

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

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

      \[\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 associate-/r/7.0

      \[\leadsto x - \color{blue}{\frac{1}{t} \cdot \left(\left(z \cdot \left(1 + 0.5 \cdot z\right)\right) \cdot y + \log 1\right)}\]
    9. Using strategy rm
    10. Applied distribute-lft-in7.0

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

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

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

    if 2.010313960630697e-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 simplification7.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -200.7607659959793409143458120524883270264:\\ \;\;\;\;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.010313960630697195821945826958268942993 \cdot 10^{-40}:\\ \;\;\;\;x - \left(\frac{z \cdot \left(1 + 0.5 \cdot z\right)}{t} \cdot y + \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)))