Average Error: 24.4 → 8.1
Time: 7.3s
Precision: 64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \le -7.43116738070796024 \cdot 10^{-6}:\\ \;\;\;\;x - \frac{1}{\frac{t}{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}}\\ \mathbf{elif}\;z \le 1.29880234871898036 \cdot 10^{-56}:\\ \;\;\;\;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)\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(1 + y \cdot \left(\frac{1}{2} \cdot {z}^{2} + z\right)\right)}{t}\\ \end{array}\]
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
\begin{array}{l}
\mathbf{if}\;z \le -7.43116738070796024 \cdot 10^{-6}:\\
\;\;\;\;x - \frac{1}{\frac{t}{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}}\\

\mathbf{elif}\;z \le 1.29880234871898036 \cdot 10^{-56}:\\
\;\;\;\;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)\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r364547 = x;
        double r364548 = 1.0;
        double r364549 = y;
        double r364550 = r364548 - r364549;
        double r364551 = z;
        double r364552 = exp(r364551);
        double r364553 = r364549 * r364552;
        double r364554 = r364550 + r364553;
        double r364555 = log(r364554);
        double r364556 = t;
        double r364557 = r364555 / r364556;
        double r364558 = r364547 - r364557;
        return r364558;
}

double f(double x, double y, double z, double t) {
        double r364559 = z;
        double r364560 = -7.43116738070796e-06;
        bool r364561 = r364559 <= r364560;
        double r364562 = x;
        double r364563 = 1.0;
        double r364564 = t;
        double r364565 = 1.0;
        double r364566 = y;
        double r364567 = r364565 - r364566;
        double r364568 = exp(r364559);
        double r364569 = r364566 * r364568;
        double r364570 = r364567 + r364569;
        double r364571 = log(r364570);
        double r364572 = r364564 / r364571;
        double r364573 = r364563 / r364572;
        double r364574 = r364562 - r364573;
        double r364575 = 1.2988023487189804e-56;
        bool r364576 = r364559 <= r364575;
        double r364577 = r364559 * r364566;
        double r364578 = r364577 / r364564;
        double r364579 = r364565 * r364578;
        double r364580 = log(r364565);
        double r364581 = r364580 / r364564;
        double r364582 = 0.5;
        double r364583 = 2.0;
        double r364584 = pow(r364559, r364583);
        double r364585 = r364584 * r364566;
        double r364586 = r364585 / r364564;
        double r364587 = r364582 * r364586;
        double r364588 = r364581 + r364587;
        double r364589 = r364579 + r364588;
        double r364590 = r364562 - r364589;
        double r364591 = 0.5;
        double r364592 = r364591 * r364584;
        double r364593 = r364592 + r364559;
        double r364594 = r364566 * r364593;
        double r364595 = r364565 + r364594;
        double r364596 = log(r364595);
        double r364597 = r364596 / r364564;
        double r364598 = r364562 - r364597;
        double r364599 = r364576 ? r364590 : r364598;
        double r364600 = r364561 ? r364574 : r364599;
        return r364600;
}

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.4
Target15.9
Herbie8.1
\[\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 3 regimes
  2. if z < -7.43116738070796e-06

    1. Initial program 11.4

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

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

    if -7.43116738070796e-06 < z < 1.2988023487189804e-56

    1. Initial program 30.0

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

      \[\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 *-un-lft-identity6.0

      \[\leadsto x - \left(1 \cdot \frac{z \cdot y}{\color{blue}{1 \cdot t}} + \left(\frac{\log 1}{t} + 0.5 \cdot \frac{{z}^{2} \cdot y}{t}\right)\right)\]
    5. Applied times-frac8.4

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

      \[\leadsto x - \left(1 \cdot \left(\color{blue}{z} \cdot \frac{y}{t}\right) + \left(\frac{\log 1}{t} + 0.5 \cdot \frac{{z}^{2} \cdot y}{t}\right)\right)\]
    7. Taylor expanded around 0 6.0

      \[\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)}\]

    if 1.2988023487189804e-56 < z

    1. Initial program 28.7

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

      \[\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. Simplified13.9

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

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

Reproduce

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