Average Error: 25.4 → 8.7
Time: 24.3s
Precision: 64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.686418545870752049627844249002350807132 \cdot 10^{-4}:\\ \;\;\;\;x - \frac{1}{\frac{t}{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}}\\ \mathbf{elif}\;z \le -5.45176818415925318729220490532588980674 \cdot 10^{-129}:\\ \;\;\;\;x - \frac{\log \left(1 + y \cdot \left(\frac{1}{2} \cdot {z}^{2} + z\right)\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \left(\left(\frac{\log 1}{t} + 0.5 \cdot \frac{\frac{{z}^{2} \cdot y}{\sqrt[3]{t} \cdot \sqrt[3]{t}}}{\sqrt[3]{t}}\right) + 1 \cdot \left(\left(z \cdot y\right) \cdot \frac{1}{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 -1.686418545870752049627844249002350807132 \cdot 10^{-4}:\\
\;\;\;\;x - \frac{1}{\frac{t}{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}}\\

\mathbf{elif}\;z \le -5.45176818415925318729220490532588980674 \cdot 10^{-129}:\\
\;\;\;\;x - \frac{\log \left(1 + y \cdot \left(\frac{1}{2} \cdot {z}^{2} + z\right)\right)}{t}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r198056 = x;
        double r198057 = 1.0;
        double r198058 = y;
        double r198059 = r198057 - r198058;
        double r198060 = z;
        double r198061 = exp(r198060);
        double r198062 = r198058 * r198061;
        double r198063 = r198059 + r198062;
        double r198064 = log(r198063);
        double r198065 = t;
        double r198066 = r198064 / r198065;
        double r198067 = r198056 - r198066;
        return r198067;
}

double f(double x, double y, double z, double t) {
        double r198068 = z;
        double r198069 = -0.0001686418545870752;
        bool r198070 = r198068 <= r198069;
        double r198071 = x;
        double r198072 = 1.0;
        double r198073 = t;
        double r198074 = 1.0;
        double r198075 = y;
        double r198076 = r198074 - r198075;
        double r198077 = exp(r198068);
        double r198078 = r198075 * r198077;
        double r198079 = r198076 + r198078;
        double r198080 = log(r198079);
        double r198081 = r198073 / r198080;
        double r198082 = r198072 / r198081;
        double r198083 = r198071 - r198082;
        double r198084 = -5.451768184159253e-129;
        bool r198085 = r198068 <= r198084;
        double r198086 = 0.5;
        double r198087 = 2.0;
        double r198088 = pow(r198068, r198087);
        double r198089 = r198086 * r198088;
        double r198090 = r198089 + r198068;
        double r198091 = r198075 * r198090;
        double r198092 = r198074 + r198091;
        double r198093 = log(r198092);
        double r198094 = r198093 / r198073;
        double r198095 = r198071 - r198094;
        double r198096 = log(r198074);
        double r198097 = r198096 / r198073;
        double r198098 = 0.5;
        double r198099 = r198088 * r198075;
        double r198100 = cbrt(r198073);
        double r198101 = r198100 * r198100;
        double r198102 = r198099 / r198101;
        double r198103 = r198102 / r198100;
        double r198104 = r198098 * r198103;
        double r198105 = r198097 + r198104;
        double r198106 = r198068 * r198075;
        double r198107 = r198072 / r198073;
        double r198108 = r198106 * r198107;
        double r198109 = r198074 * r198108;
        double r198110 = r198105 + r198109;
        double r198111 = r198071 - r198110;
        double r198112 = r198085 ? r198095 : r198111;
        double r198113 = r198070 ? r198083 : r198112;
        return r198113;
}

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.4
Target16.8
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 < -0.0001686418545870752

    1. Initial program 12.3

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

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

    if -0.0001686418545870752 < z < -5.451768184159253e-129

    1. Initial program 30.3

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

      \[\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. Simplified10.6

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

    if -5.451768184159253e-129 < z

    1. Initial program 31.0

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

      \[\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. Using strategy rm
    4. Applied div-inv6.4

      \[\leadsto x - \left(1 \cdot \color{blue}{\left(\left(z \cdot y\right) \cdot \frac{1}{t}\right)} + \left(\frac{\log 1}{t} + 0.5 \cdot \frac{{z}^{2} \cdot y}{t}\right)\right)\]
    5. Using strategy rm
    6. Applied add-cube-cbrt6.4

      \[\leadsto x - \left(1 \cdot \left(\left(z \cdot y\right) \cdot \frac{1}{t}\right) + \left(\frac{\log 1}{t} + 0.5 \cdot \frac{{z}^{2} \cdot y}{\color{blue}{\left(\sqrt[3]{t} \cdot \sqrt[3]{t}\right) \cdot \sqrt[3]{t}}}\right)\right)\]
    7. Applied associate-/r*6.4

      \[\leadsto x - \left(1 \cdot \left(\left(z \cdot y\right) \cdot \frac{1}{t}\right) + \left(\frac{\log 1}{t} + 0.5 \cdot \color{blue}{\frac{\frac{{z}^{2} \cdot y}{\sqrt[3]{t} \cdot \sqrt[3]{t}}}{\sqrt[3]{t}}}\right)\right)\]
    8. Using strategy rm
    9. Applied +-commutative6.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.686418545870752049627844249002350807132 \cdot 10^{-4}:\\ \;\;\;\;x - \frac{1}{\frac{t}{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}}\\ \mathbf{elif}\;z \le -5.45176818415925318729220490532588980674 \cdot 10^{-129}:\\ \;\;\;\;x - \frac{\log \left(1 + y \cdot \left(\frac{1}{2} \cdot {z}^{2} + z\right)\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \left(\left(\frac{\log 1}{t} + 0.5 \cdot \frac{\frac{{z}^{2} \cdot y}{\sqrt[3]{t} \cdot \sqrt[3]{t}}}{\sqrt[3]{t}}\right) + 1 \cdot \left(\left(z \cdot y\right) \cdot \frac{1}{t}\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019291 
(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.88746230882079466e119) (- (- 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)))