Average Error: 25.0 → 9.5
Time: 29.2s
Precision: 64
\[x - \frac{\log \left(\left(1.0 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;e^{z} \le 0.9999999999999964:\\ \;\;\;\;x - \frac{1}{\frac{t}{\log \left(y \cdot e^{z} + \left(1.0 - y\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;x - \left(\frac{\log 1.0}{t} + \left(\frac{z}{\frac{t}{y}} \cdot 1.0 + \frac{0.5 \cdot \left(\left(z \cdot y\right) \cdot z\right)}{t}\right)\right)\\ \end{array}\]
x - \frac{\log \left(\left(1.0 - y\right) + y \cdot e^{z}\right)}{t}
\begin{array}{l}
\mathbf{if}\;e^{z} \le 0.9999999999999964:\\
\;\;\;\;x - \frac{1}{\frac{t}{\log \left(y \cdot e^{z} + \left(1.0 - y\right)\right)}}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r16410739 = x;
        double r16410740 = 1.0;
        double r16410741 = y;
        double r16410742 = r16410740 - r16410741;
        double r16410743 = z;
        double r16410744 = exp(r16410743);
        double r16410745 = r16410741 * r16410744;
        double r16410746 = r16410742 + r16410745;
        double r16410747 = log(r16410746);
        double r16410748 = t;
        double r16410749 = r16410747 / r16410748;
        double r16410750 = r16410739 - r16410749;
        return r16410750;
}

double f(double x, double y, double z, double t) {
        double r16410751 = z;
        double r16410752 = exp(r16410751);
        double r16410753 = 0.9999999999999964;
        bool r16410754 = r16410752 <= r16410753;
        double r16410755 = x;
        double r16410756 = 1.0;
        double r16410757 = t;
        double r16410758 = y;
        double r16410759 = r16410758 * r16410752;
        double r16410760 = 1.0;
        double r16410761 = r16410760 - r16410758;
        double r16410762 = r16410759 + r16410761;
        double r16410763 = log(r16410762);
        double r16410764 = r16410757 / r16410763;
        double r16410765 = r16410756 / r16410764;
        double r16410766 = r16410755 - r16410765;
        double r16410767 = log(r16410760);
        double r16410768 = r16410767 / r16410757;
        double r16410769 = r16410757 / r16410758;
        double r16410770 = r16410751 / r16410769;
        double r16410771 = r16410770 * r16410760;
        double r16410772 = 0.5;
        double r16410773 = r16410751 * r16410758;
        double r16410774 = r16410773 * r16410751;
        double r16410775 = r16410772 * r16410774;
        double r16410776 = r16410775 / r16410757;
        double r16410777 = r16410771 + r16410776;
        double r16410778 = r16410768 + r16410777;
        double r16410779 = r16410755 - r16410778;
        double r16410780 = r16410754 ? r16410766 : r16410779;
        return r16410780;
}

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
Target16.3
Herbie9.5
\[\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 (exp z) < 0.9999999999999964

    1. Initial program 11.6

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

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

    if 0.9999999999999964 < (exp z)

    1. Initial program 30.9

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

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

      \[\leadsto x - \color{blue}{\left(\frac{\log 1.0}{t} + \left(\frac{0.5 \cdot \left(\left(y \cdot z\right) \cdot z\right)}{t} + \frac{\left(1.0 \cdot z\right) \cdot y}{t}\right)\right)}\]
    4. Taylor expanded around 0 7.1

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

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

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

Reproduce

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