Average Error: 25.0 → 8.5
Time: 19.6s
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.8708591394256368634074760848307050764561:\\ \;\;\;\;x - \frac{\log \left(1 - \left(y - y \cdot e^{z}\right)\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log 1 + y \cdot \left(0.5 \cdot \left(z \cdot z\right) + 1 \cdot z\right)}{t}\\ \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.8708591394256368634074760848307050764561:\\
\;\;\;\;x - \frac{\log \left(1 - \left(y - y \cdot e^{z}\right)\right)}{t}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r15343622 = x;
        double r15343623 = 1.0;
        double r15343624 = y;
        double r15343625 = r15343623 - r15343624;
        double r15343626 = z;
        double r15343627 = exp(r15343626);
        double r15343628 = r15343624 * r15343627;
        double r15343629 = r15343625 + r15343628;
        double r15343630 = log(r15343629);
        double r15343631 = t;
        double r15343632 = r15343630 / r15343631;
        double r15343633 = r15343622 - r15343632;
        return r15343633;
}

double f(double x, double y, double z, double t) {
        double r15343634 = z;
        double r15343635 = exp(r15343634);
        double r15343636 = 0.8708591394256369;
        bool r15343637 = r15343635 <= r15343636;
        double r15343638 = x;
        double r15343639 = 1.0;
        double r15343640 = y;
        double r15343641 = r15343640 * r15343635;
        double r15343642 = r15343640 - r15343641;
        double r15343643 = r15343639 - r15343642;
        double r15343644 = log(r15343643);
        double r15343645 = t;
        double r15343646 = r15343644 / r15343645;
        double r15343647 = r15343638 - r15343646;
        double r15343648 = log(r15343639);
        double r15343649 = 0.5;
        double r15343650 = r15343634 * r15343634;
        double r15343651 = r15343649 * r15343650;
        double r15343652 = r15343639 * r15343634;
        double r15343653 = r15343651 + r15343652;
        double r15343654 = r15343640 * r15343653;
        double r15343655 = r15343648 + r15343654;
        double r15343656 = r15343655 / r15343645;
        double r15343657 = r15343638 - r15343656;
        double r15343658 = r15343637 ? r15343647 : r15343657;
        return r15343658;
}

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.0
Target15.7
Herbie8.5
\[\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 2 regimes
  2. if (exp z) < 0.8708591394256369

    1. Initial program 11.2

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

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

    if 0.8708591394256369 < (exp z)

    1. Initial program 30.7

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

      \[\leadsto x - \frac{\log \color{blue}{\left(1 - \left(y - y \cdot e^{z}\right)\right)}}{t}\]
    4. Taylor expanded around 0 7.4

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

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

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

Reproduce

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