Average Error: 24.1 → 8.8
Time: 31.7s
Precision: 64
\[x - \frac{\log \left(\left(1.0 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \le -8.871302153578205 \cdot 10^{-14}:\\ \;\;\;\;x - \frac{\log \left(\left(\sqrt{e^{z}} \cdot y\right) \cdot \sqrt{e^{z}} + \left(1.0 - y\right)\right)}{t}\\ \mathbf{elif}\;z \le 1.8362327647799437 \cdot 10^{-96}:\\ \;\;\;\;x - \left(1.0 \cdot \frac{y \cdot z}{t} + \frac{\log 1.0}{t}\right)\\ \mathbf{elif}\;z \le 3.023041139807338 \cdot 10^{-37}:\\ \;\;\;\;x - \frac{\log \left(y \cdot \left(\frac{1}{2} \cdot \left(z \cdot z\right) + z\right) + 1.0\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{1}{\sqrt[3]{t} \cdot \sqrt[3]{t}} \cdot \frac{y \cdot \left(z \cdot \left(1.0 + z \cdot 0.5\right)\right) + \log 1.0}{\sqrt[3]{t}}\\ \end{array}\]
x - \frac{\log \left(\left(1.0 - y\right) + y \cdot e^{z}\right)}{t}
\begin{array}{l}
\mathbf{if}\;z \le -8.871302153578205 \cdot 10^{-14}:\\
\;\;\;\;x - \frac{\log \left(\left(\sqrt{e^{z}} \cdot y\right) \cdot \sqrt{e^{z}} + \left(1.0 - y\right)\right)}{t}\\

\mathbf{elif}\;z \le 1.8362327647799437 \cdot 10^{-96}:\\
\;\;\;\;x - \left(1.0 \cdot \frac{y \cdot z}{t} + \frac{\log 1.0}{t}\right)\\

\mathbf{elif}\;z \le 3.023041139807338 \cdot 10^{-37}:\\
\;\;\;\;x - \frac{\log \left(y \cdot \left(\frac{1}{2} \cdot \left(z \cdot z\right) + z\right) + 1.0\right)}{t}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r18318681 = x;
        double r18318682 = 1.0;
        double r18318683 = y;
        double r18318684 = r18318682 - r18318683;
        double r18318685 = z;
        double r18318686 = exp(r18318685);
        double r18318687 = r18318683 * r18318686;
        double r18318688 = r18318684 + r18318687;
        double r18318689 = log(r18318688);
        double r18318690 = t;
        double r18318691 = r18318689 / r18318690;
        double r18318692 = r18318681 - r18318691;
        return r18318692;
}

double f(double x, double y, double z, double t) {
        double r18318693 = z;
        double r18318694 = -8.871302153578205e-14;
        bool r18318695 = r18318693 <= r18318694;
        double r18318696 = x;
        double r18318697 = exp(r18318693);
        double r18318698 = sqrt(r18318697);
        double r18318699 = y;
        double r18318700 = r18318698 * r18318699;
        double r18318701 = r18318700 * r18318698;
        double r18318702 = 1.0;
        double r18318703 = r18318702 - r18318699;
        double r18318704 = r18318701 + r18318703;
        double r18318705 = log(r18318704);
        double r18318706 = t;
        double r18318707 = r18318705 / r18318706;
        double r18318708 = r18318696 - r18318707;
        double r18318709 = 1.8362327647799437e-96;
        bool r18318710 = r18318693 <= r18318709;
        double r18318711 = r18318699 * r18318693;
        double r18318712 = r18318711 / r18318706;
        double r18318713 = r18318702 * r18318712;
        double r18318714 = log(r18318702);
        double r18318715 = r18318714 / r18318706;
        double r18318716 = r18318713 + r18318715;
        double r18318717 = r18318696 - r18318716;
        double r18318718 = 3.023041139807338e-37;
        bool r18318719 = r18318693 <= r18318718;
        double r18318720 = 0.5;
        double r18318721 = r18318693 * r18318693;
        double r18318722 = r18318720 * r18318721;
        double r18318723 = r18318722 + r18318693;
        double r18318724 = r18318699 * r18318723;
        double r18318725 = r18318724 + r18318702;
        double r18318726 = log(r18318725);
        double r18318727 = r18318726 / r18318706;
        double r18318728 = r18318696 - r18318727;
        double r18318729 = 1.0;
        double r18318730 = cbrt(r18318706);
        double r18318731 = r18318730 * r18318730;
        double r18318732 = r18318729 / r18318731;
        double r18318733 = 0.5;
        double r18318734 = r18318693 * r18318733;
        double r18318735 = r18318702 + r18318734;
        double r18318736 = r18318693 * r18318735;
        double r18318737 = r18318699 * r18318736;
        double r18318738 = r18318737 + r18318714;
        double r18318739 = r18318738 / r18318730;
        double r18318740 = r18318732 * r18318739;
        double r18318741 = r18318696 - r18318740;
        double r18318742 = r18318719 ? r18318728 : r18318741;
        double r18318743 = r18318710 ? r18318717 : r18318742;
        double r18318744 = r18318695 ? r18318708 : r18318743;
        return r18318744;
}

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.1
Target16.3
Herbie8.8
\[\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 4 regimes
  2. if z < -8.871302153578205e-14

    1. Initial program 12.0

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

      \[\leadsto x - \frac{\log \left(\left(1.0 - y\right) + y \cdot \color{blue}{\left(\sqrt{e^{z}} \cdot \sqrt{e^{z}}\right)}\right)}{t}\]
    4. Applied associate-*r*12.0

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

    if -8.871302153578205e-14 < z < 1.8362327647799437e-96

    1. Initial program 30.1

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

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

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

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

    if 1.8362327647799437e-96 < z < 3.023041139807338e-37

    1. Initial program 29.8

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

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

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

    if 3.023041139807338e-37 < z

    1. Initial program 26.2

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

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

      \[\leadsto x - \frac{\color{blue}{y \cdot \left(z \cdot \left(1.0 + 0.5 \cdot z\right)\right) + \log 1.0}}{t}\]
    4. Using strategy rm
    5. Applied add-cube-cbrt17.9

      \[\leadsto x - \frac{y \cdot \left(z \cdot \left(1.0 + 0.5 \cdot z\right)\right) + \log 1.0}{\color{blue}{\left(\sqrt[3]{t} \cdot \sqrt[3]{t}\right) \cdot \sqrt[3]{t}}}\]
    6. Applied *-un-lft-identity17.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -8.871302153578205 \cdot 10^{-14}:\\ \;\;\;\;x - \frac{\log \left(\left(\sqrt{e^{z}} \cdot y\right) \cdot \sqrt{e^{z}} + \left(1.0 - y\right)\right)}{t}\\ \mathbf{elif}\;z \le 1.8362327647799437 \cdot 10^{-96}:\\ \;\;\;\;x - \left(1.0 \cdot \frac{y \cdot z}{t} + \frac{\log 1.0}{t}\right)\\ \mathbf{elif}\;z \le 3.023041139807338 \cdot 10^{-37}:\\ \;\;\;\;x - \frac{\log \left(y \cdot \left(\frac{1}{2} \cdot \left(z \cdot z\right) + z\right) + 1.0\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{1}{\sqrt[3]{t} \cdot \sqrt[3]{t}} \cdot \frac{y \cdot \left(z \cdot \left(1.0 + z \cdot 0.5\right)\right) + \log 1.0}{\sqrt[3]{t}}\\ \end{array}\]

Reproduce

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