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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r357012 = x;
        double r357013 = 1.0;
        double r357014 = y;
        double r357015 = r357013 - r357014;
        double r357016 = z;
        double r357017 = exp(r357016);
        double r357018 = r357014 * r357017;
        double r357019 = r357015 + r357018;
        double r357020 = log(r357019);
        double r357021 = t;
        double r357022 = r357020 / r357021;
        double r357023 = r357012 - r357022;
        return r357023;
}

double f(double x, double y, double z, double t) {
        double r357024 = z;
        double r357025 = exp(r357024);
        double r357026 = 0.9999999999943705;
        bool r357027 = r357025 <= r357026;
        double r357028 = x;
        double r357029 = 1.0;
        double r357030 = y;
        double r357031 = r357029 - r357030;
        double r357032 = r357030 * r357025;
        double r357033 = r357031 + r357032;
        double r357034 = log(r357033);
        double r357035 = 1.0;
        double r357036 = t;
        double r357037 = r357035 / r357036;
        double r357038 = r357034 * r357037;
        double r357039 = r357028 - r357038;
        double r357040 = r357024 * r357030;
        double r357041 = r357037 * r357040;
        double r357042 = r357029 * r357041;
        double r357043 = log(r357029);
        double r357044 = r357043 / r357036;
        double r357045 = r357042 + r357044;
        double r357046 = r357028 - r357045;
        double r357047 = r357027 ? r357039 : r357046;
        return r357047;
}

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 (exp z) < 0.9999999999943705

    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 div-inv12.0

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

    if 0.9999999999943705 < (exp 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}{\log 1 + y \cdot \left(0.5 \cdot {z}^{2} + 1 \cdot z\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 clear-num7.2

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

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

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

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

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

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

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

Reproduce

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