Average Error: 25.3 → 8.3
Time: 13.5s
Precision: 64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \le -3.775171204884956955301025662648153197187 \cdot 10^{-12}:\\ \;\;\;\;x - \frac{\log \left(1 - y \cdot \left(1 - e^{z}\right)\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \left(1 \cdot \frac{z \cdot y}{t} + \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 -3.775171204884956955301025662648153197187 \cdot 10^{-12}:\\
\;\;\;\;x - \frac{\log \left(1 - y \cdot \left(1 - e^{z}\right)\right)}{t}\\

\mathbf{else}:\\
\;\;\;\;x - \left(1 \cdot \frac{z \cdot y}{t} + \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 r357824 = x;
        double r357825 = 1.0;
        double r357826 = y;
        double r357827 = r357825 - r357826;
        double r357828 = z;
        double r357829 = exp(r357828);
        double r357830 = r357826 * r357829;
        double r357831 = r357827 + r357830;
        double r357832 = log(r357831);
        double r357833 = t;
        double r357834 = r357832 / r357833;
        double r357835 = r357824 - r357834;
        return r357835;
}

double f(double x, double y, double z, double t) {
        double r357836 = z;
        double r357837 = -3.775171204884957e-12;
        bool r357838 = r357836 <= r357837;
        double r357839 = x;
        double r357840 = 1.0;
        double r357841 = y;
        double r357842 = 1.0;
        double r357843 = exp(r357836);
        double r357844 = r357842 - r357843;
        double r357845 = r357841 * r357844;
        double r357846 = r357840 - r357845;
        double r357847 = log(r357846);
        double r357848 = t;
        double r357849 = r357847 / r357848;
        double r357850 = r357839 - r357849;
        double r357851 = r357836 * r357841;
        double r357852 = r357851 / r357848;
        double r357853 = r357840 * r357852;
        double r357854 = log(r357840);
        double r357855 = r357854 / r357848;
        double r357856 = 0.5;
        double r357857 = 2.0;
        double r357858 = pow(r357836, r357857);
        double r357859 = r357858 * r357841;
        double r357860 = r357859 / r357848;
        double r357861 = r357856 * r357860;
        double r357862 = r357855 + r357861;
        double r357863 = r357853 + r357862;
        double r357864 = r357839 - r357863;
        double r357865 = r357838 ? r357850 : r357864;
        return r357865;
}

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

Original25.3
Target16.7
Herbie8.3
\[\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 2 regimes
  2. if z < -3.775171204884957e-12

    1. Initial program 11.7

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

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

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

    if -3.775171204884957e-12 < z

    1. Initial program 31.4

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

      \[\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. Recombined 2 regimes into one program.
  4. Final simplification8.3

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

Reproduce

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