Average Error: 24.7 → 8.8
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 -3.63277017838052457 \cdot 10^{-12}:\\ \;\;\;\;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{else}:\\ \;\;\;\;x - \left(1 \cdot \left(\left(z \cdot y\right) \cdot \frac{1}{t}\right) + \frac{\log 1}{t}\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.63277017838052457 \cdot 10^{-12}:\\
\;\;\;\;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{else}:\\
\;\;\;\;x - \left(1 \cdot \left(\left(z \cdot y\right) \cdot \frac{1}{t}\right) + \frac{\log 1}{t}\right)\\

\end{array}
double f(double x, double y, double z, double t) {
        double r214873 = x;
        double r214874 = 1.0;
        double r214875 = y;
        double r214876 = r214874 - r214875;
        double r214877 = z;
        double r214878 = exp(r214877);
        double r214879 = r214875 * r214878;
        double r214880 = r214876 + r214879;
        double r214881 = log(r214880);
        double r214882 = t;
        double r214883 = r214881 / r214882;
        double r214884 = r214873 - r214883;
        return r214884;
}

double f(double x, double y, double z, double t) {
        double r214885 = z;
        double r214886 = -3.6327701783805246e-12;
        bool r214887 = r214885 <= r214886;
        double r214888 = x;
        double r214889 = 1.0;
        double r214890 = y;
        double r214891 = r214889 - r214890;
        double r214892 = exp(r214885);
        double r214893 = r214890 * r214892;
        double r214894 = r214891 + r214893;
        double r214895 = sqrt(r214894);
        double r214896 = log(r214895);
        double r214897 = r214896 + r214896;
        double r214898 = t;
        double r214899 = r214897 / r214898;
        double r214900 = r214888 - r214899;
        double r214901 = r214885 * r214890;
        double r214902 = 1.0;
        double r214903 = r214902 / r214898;
        double r214904 = r214901 * r214903;
        double r214905 = r214889 * r214904;
        double r214906 = log(r214889);
        double r214907 = r214906 / r214898;
        double r214908 = r214905 + r214907;
        double r214909 = r214888 - r214908;
        double r214910 = r214887 ? r214900 : r214909;
        return r214910;
}

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.4
Herbie8.8
\[\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 2 regimes
  2. if z < -3.6327701783805246e-12

    1. Initial program 12.0

      \[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt12.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-prod12.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 -3.6327701783805246e-12 < z

    1. Initial program 30.6

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

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

      \[\leadsto x - \frac{\color{blue}{\mathsf{fma}\left(0.5, {z}^{2} \cdot y, \mathsf{fma}\left(1, z \cdot y, \log 1\right)\right)}}{t}\]
    4. Taylor expanded around 0 7.2

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

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

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

Reproduce

herbie shell --seed 2020027 +o rules:numerics
(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)))