Average Error: 25.5 → 8.0
Time: 1.2m
Precision: 64
\[x - \frac{\log \left(\left(1.0 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \le -0.005019481635896301:\\ \;\;\;\;x - \log \left(e^{z} \cdot y + \left(1.0 - y\right)\right) \cdot \frac{1}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \left(\frac{\log 1.0}{t} + 1.0 \cdot \left(\frac{z}{t} \cdot y\right)\right)\\ \end{array}\]
x - \frac{\log \left(\left(1.0 - y\right) + y \cdot e^{z}\right)}{t}
\begin{array}{l}
\mathbf{if}\;z \le -0.005019481635896301:\\
\;\;\;\;x - \log \left(e^{z} \cdot y + \left(1.0 - y\right)\right) \cdot \frac{1}{t}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r14057102 = x;
        double r14057103 = 1.0;
        double r14057104 = y;
        double r14057105 = r14057103 - r14057104;
        double r14057106 = z;
        double r14057107 = exp(r14057106);
        double r14057108 = r14057104 * r14057107;
        double r14057109 = r14057105 + r14057108;
        double r14057110 = log(r14057109);
        double r14057111 = t;
        double r14057112 = r14057110 / r14057111;
        double r14057113 = r14057102 - r14057112;
        return r14057113;
}

double f(double x, double y, double z, double t) {
        double r14057114 = z;
        double r14057115 = -0.005019481635896301;
        bool r14057116 = r14057114 <= r14057115;
        double r14057117 = x;
        double r14057118 = exp(r14057114);
        double r14057119 = y;
        double r14057120 = r14057118 * r14057119;
        double r14057121 = 1.0;
        double r14057122 = r14057121 - r14057119;
        double r14057123 = r14057120 + r14057122;
        double r14057124 = log(r14057123);
        double r14057125 = 1.0;
        double r14057126 = t;
        double r14057127 = r14057125 / r14057126;
        double r14057128 = r14057124 * r14057127;
        double r14057129 = r14057117 - r14057128;
        double r14057130 = log(r14057121);
        double r14057131 = r14057130 / r14057126;
        double r14057132 = r14057114 / r14057126;
        double r14057133 = r14057132 * r14057119;
        double r14057134 = r14057121 * r14057133;
        double r14057135 = r14057131 + r14057134;
        double r14057136 = r14057117 - r14057135;
        double r14057137 = r14057116 ? r14057129 : r14057136;
        return r14057137;
}

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.5
Target16.7
Herbie8.0
\[\begin{array}{l} \mathbf{if}\;z \lt -2.8874623088207947 \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.0}{z}}{z \cdot z}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(1.0 + z \cdot y\right)}{t}\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if z < -0.005019481635896301

    1. Initial program 11.7

      \[x - \frac{\log \left(\left(1.0 - y\right) + y \cdot e^{z}\right)}{t}\]
    2. Using strategy rm
    3. Applied div-inv11.7

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

    if -0.005019481635896301 < z

    1. Initial program 31.6

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

      \[\leadsto \color{blue}{x - \left(1.0 \cdot \frac{z \cdot y}{t} + \frac{\log 1.0}{t}\right)}\]
    3. Using strategy rm
    4. Applied clear-num7.3

      \[\leadsto x - \left(1.0 \cdot \color{blue}{\frac{1}{\frac{t}{z \cdot y}}} + \frac{\log 1.0}{t}\right)\]
    5. Using strategy rm
    6. Applied *-un-lft-identity7.3

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

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

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

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

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

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

Reproduce

herbie shell --seed 2019165 
(FPCore (x y z t)
  :name "System.Random.MWC.Distributions:truncatedExp from mwc-random-0.13.3.2"

  :herbie-target
  (if (< z -2.8874623088207947e+119) (- (- x (/ (/ (- 0.5) (* y t)) (* z z))) (* (/ (- 0.5) (* y t)) (/ (/ 2.0 z) (* z z)))) (- x (/ (log (+ 1.0 (* z y))) t)))

  (- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)))