Average Error: 24.1 → 8.8
Time: 29.8s
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 r17580076 = x;
        double r17580077 = 1.0;
        double r17580078 = y;
        double r17580079 = r17580077 - r17580078;
        double r17580080 = z;
        double r17580081 = exp(r17580080);
        double r17580082 = r17580078 * r17580081;
        double r17580083 = r17580079 + r17580082;
        double r17580084 = log(r17580083);
        double r17580085 = t;
        double r17580086 = r17580084 / r17580085;
        double r17580087 = r17580076 - r17580086;
        return r17580087;
}

double f(double x, double y, double z, double t) {
        double r17580088 = z;
        double r17580089 = -8.871302153578205e-14;
        bool r17580090 = r17580088 <= r17580089;
        double r17580091 = x;
        double r17580092 = exp(r17580088);
        double r17580093 = sqrt(r17580092);
        double r17580094 = y;
        double r17580095 = r17580093 * r17580094;
        double r17580096 = r17580095 * r17580093;
        double r17580097 = 1.0;
        double r17580098 = r17580097 - r17580094;
        double r17580099 = r17580096 + r17580098;
        double r17580100 = log(r17580099);
        double r17580101 = t;
        double r17580102 = r17580100 / r17580101;
        double r17580103 = r17580091 - r17580102;
        double r17580104 = 1.8362327647799437e-96;
        bool r17580105 = r17580088 <= r17580104;
        double r17580106 = r17580094 * r17580088;
        double r17580107 = r17580106 / r17580101;
        double r17580108 = r17580097 * r17580107;
        double r17580109 = log(r17580097);
        double r17580110 = r17580109 / r17580101;
        double r17580111 = r17580108 + r17580110;
        double r17580112 = r17580091 - r17580111;
        double r17580113 = 3.023041139807338e-37;
        bool r17580114 = r17580088 <= r17580113;
        double r17580115 = 0.5;
        double r17580116 = r17580088 * r17580088;
        double r17580117 = r17580115 * r17580116;
        double r17580118 = r17580117 + r17580088;
        double r17580119 = r17580094 * r17580118;
        double r17580120 = r17580119 + r17580097;
        double r17580121 = log(r17580120);
        double r17580122 = r17580121 / r17580101;
        double r17580123 = r17580091 - r17580122;
        double r17580124 = 1.0;
        double r17580125 = cbrt(r17580101);
        double r17580126 = r17580125 * r17580125;
        double r17580127 = r17580124 / r17580126;
        double r17580128 = 0.5;
        double r17580129 = r17580088 * r17580128;
        double r17580130 = r17580097 + r17580129;
        double r17580131 = r17580088 * r17580130;
        double r17580132 = r17580094 * r17580131;
        double r17580133 = r17580132 + r17580109;
        double r17580134 = r17580133 / r17580125;
        double r17580135 = r17580127 * r17580134;
        double r17580136 = r17580091 - r17580135;
        double r17580137 = r17580114 ? r17580123 : r17580136;
        double r17580138 = r17580105 ? r17580112 : r17580137;
        double r17580139 = r17580090 ? r17580103 : r17580138;
        return r17580139;
}

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)))