Average Error: 24.6 → 9.2
Time: 7.1s
Precision: 64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \le -6.064026063174626 \cdot 10^{45}:\\ \;\;\;\;x - \frac{\log \left(\sqrt{\left(1 - y\right) + y \cdot e^{z}}\right) + \log \left(\sqrt{\left(1 - y\right) + y \cdot e^{z}}\right)}{t}\\ \mathbf{elif}\;z \le 6.7485748775422916 \cdot 10^{-44}:\\ \;\;\;\;x - \left(1 \cdot \left(\left(z \cdot y\right) \cdot \frac{1}{t}\right) + \frac{\log 1}{t}\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 -6.064026063174626 \cdot 10^{45}:\\
\;\;\;\;x - \frac{\log \left(\sqrt{\left(1 - y\right) + y \cdot e^{z}}\right) + \log \left(\sqrt{\left(1 - y\right) + y \cdot e^{z}}\right)}{t}\\

\mathbf{elif}\;z \le 6.7485748775422916 \cdot 10^{-44}:\\
\;\;\;\;x - \left(1 \cdot \left(\left(z \cdot y\right) \cdot \frac{1}{t}\right) + \frac{\log 1}{t}\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 r331605 = x;
        double r331606 = 1.0;
        double r331607 = y;
        double r331608 = r331606 - r331607;
        double r331609 = z;
        double r331610 = exp(r331609);
        double r331611 = r331607 * r331610;
        double r331612 = r331608 + r331611;
        double r331613 = log(r331612);
        double r331614 = t;
        double r331615 = r331613 / r331614;
        double r331616 = r331605 - r331615;
        return r331616;
}

double f(double x, double y, double z, double t) {
        double r331617 = z;
        double r331618 = -6.064026063174626e+45;
        bool r331619 = r331617 <= r331618;
        double r331620 = x;
        double r331621 = 1.0;
        double r331622 = y;
        double r331623 = r331621 - r331622;
        double r331624 = exp(r331617);
        double r331625 = r331622 * r331624;
        double r331626 = r331623 + r331625;
        double r331627 = sqrt(r331626);
        double r331628 = log(r331627);
        double r331629 = r331628 + r331628;
        double r331630 = t;
        double r331631 = r331629 / r331630;
        double r331632 = r331620 - r331631;
        double r331633 = 6.748574877542292e-44;
        bool r331634 = r331617 <= r331633;
        double r331635 = r331617 * r331622;
        double r331636 = 1.0;
        double r331637 = r331636 / r331630;
        double r331638 = r331635 * r331637;
        double r331639 = r331621 * r331638;
        double r331640 = log(r331621);
        double r331641 = r331640 / r331630;
        double r331642 = r331639 + r331641;
        double r331643 = r331620 - r331642;
        double r331644 = 0.5;
        double r331645 = 2.0;
        double r331646 = pow(r331617, r331645);
        double r331647 = r331644 * r331646;
        double r331648 = r331647 + r331617;
        double r331649 = r331622 * r331648;
        double r331650 = r331621 + r331649;
        double r331651 = log(r331650);
        double r331652 = r331651 / r331630;
        double r331653 = r331620 - r331652;
        double r331654 = r331634 ? r331643 : r331653;
        double r331655 = r331619 ? r331632 : r331654;
        return r331655;
}

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.6
Target16.0
Herbie9.2
\[\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 < -6.064026063174626e+45

    1. Initial program 11.5

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

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

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

    if -6.064026063174626e+45 < z < 6.748574877542292e-44

    1. Initial program 29.2

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

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

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

      \[\leadsto \color{blue}{x - \left(1 \cdot \frac{z \cdot y}{t} + \frac{\log 1}{t}\right)}\]
    5. Using strategy rm
    6. Applied div-inv8.0

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

    if 6.748574877542292e-44 < z

    1. Initial program 25.7

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

      \[\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.5

      \[\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 simplification9.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -6.064026063174626 \cdot 10^{45}:\\ \;\;\;\;x - \frac{\log \left(\sqrt{\left(1 - y\right) + y \cdot e^{z}}\right) + \log \left(\sqrt{\left(1 - y\right) + y \cdot e^{z}}\right)}{t}\\ \mathbf{elif}\;z \le 6.7485748775422916 \cdot 10^{-44}:\\ \;\;\;\;x - \left(1 \cdot \left(\left(z \cdot y\right) \cdot \frac{1}{t}\right) + \frac{\log 1}{t}\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 2020035 
(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)))