Average Error: 25.4 → 8.8
Time: 8.1s
Precision: 64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \le -0.01243893441116220889564036866659080260433:\\ \;\;\;\;x - \frac{1}{\frac{t}{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}}\\ \mathbf{elif}\;z \le 4.549364555403628313368183381315866295653 \cdot 10^{-95}:\\ \;\;\;\;x - \left(1 \cdot \frac{\frac{z \cdot y}{\sqrt[3]{t} \cdot \sqrt[3]{t}}}{\sqrt[3]{t}} + \left(\frac{\log 1}{t} + 0.5 \cdot \frac{{z}^{2} \cdot y}{t}\right)\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 -0.01243893441116220889564036866659080260433:\\
\;\;\;\;x - \frac{1}{\frac{t}{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}}\\

\mathbf{elif}\;z \le 4.549364555403628313368183381315866295653 \cdot 10^{-95}:\\
\;\;\;\;x - \left(1 \cdot \frac{\frac{z \cdot y}{\sqrt[3]{t} \cdot \sqrt[3]{t}}}{\sqrt[3]{t}} + \left(\frac{\log 1}{t} + 0.5 \cdot \frac{{z}^{2} \cdot y}{t}\right)\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 r343479 = x;
        double r343480 = 1.0;
        double r343481 = y;
        double r343482 = r343480 - r343481;
        double r343483 = z;
        double r343484 = exp(r343483);
        double r343485 = r343481 * r343484;
        double r343486 = r343482 + r343485;
        double r343487 = log(r343486);
        double r343488 = t;
        double r343489 = r343487 / r343488;
        double r343490 = r343479 - r343489;
        return r343490;
}

double f(double x, double y, double z, double t) {
        double r343491 = z;
        double r343492 = -0.012438934411162209;
        bool r343493 = r343491 <= r343492;
        double r343494 = x;
        double r343495 = 1.0;
        double r343496 = t;
        double r343497 = 1.0;
        double r343498 = y;
        double r343499 = r343497 - r343498;
        double r343500 = exp(r343491);
        double r343501 = r343498 * r343500;
        double r343502 = r343499 + r343501;
        double r343503 = log(r343502);
        double r343504 = r343496 / r343503;
        double r343505 = r343495 / r343504;
        double r343506 = r343494 - r343505;
        double r343507 = 4.549364555403628e-95;
        bool r343508 = r343491 <= r343507;
        double r343509 = r343491 * r343498;
        double r343510 = cbrt(r343496);
        double r343511 = r343510 * r343510;
        double r343512 = r343509 / r343511;
        double r343513 = r343512 / r343510;
        double r343514 = r343497 * r343513;
        double r343515 = log(r343497);
        double r343516 = r343515 / r343496;
        double r343517 = 0.5;
        double r343518 = 2.0;
        double r343519 = pow(r343491, r343518);
        double r343520 = r343519 * r343498;
        double r343521 = r343520 / r343496;
        double r343522 = r343517 * r343521;
        double r343523 = r343516 + r343522;
        double r343524 = r343514 + r343523;
        double r343525 = r343494 - r343524;
        double r343526 = 0.5;
        double r343527 = r343526 * r343519;
        double r343528 = r343527 + r343491;
        double r343529 = r343498 * r343528;
        double r343530 = r343497 + r343529;
        double r343531 = log(r343530);
        double r343532 = r343531 / r343496;
        double r343533 = r343494 - r343532;
        double r343534 = r343508 ? r343525 : r343533;
        double r343535 = r343493 ? r343506 : r343534;
        return r343535;
}

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

    1. Initial program 12.3

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

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

    if -0.012438934411162209 < z < 4.549364555403628e-95

    1. Initial program 31.6

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

      \[\leadsto x - \color{blue}{\left(1 \cdot \frac{z \cdot y}{t} + \left(\frac{\log 1}{t} + 0.5 \cdot \frac{{z}^{2} \cdot y}{t}\right)\right)}\]
    3. Using strategy rm
    4. Applied add-cube-cbrt6.4

      \[\leadsto x - \left(1 \cdot \frac{z \cdot y}{\color{blue}{\left(\sqrt[3]{t} \cdot \sqrt[3]{t}\right) \cdot \sqrt[3]{t}}} + \left(\frac{\log 1}{t} + 0.5 \cdot \frac{{z}^{2} \cdot y}{t}\right)\right)\]
    5. Applied associate-/r*6.4

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

    if 4.549364555403628e-95 < z

    1. Initial program 28.4

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

      \[\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. Simplified12.4

      \[\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 simplification8.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -0.01243893441116220889564036866659080260433:\\ \;\;\;\;x - \frac{1}{\frac{t}{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}}\\ \mathbf{elif}\;z \le 4.549364555403628313368183381315866295653 \cdot 10^{-95}:\\ \;\;\;\;x - \left(1 \cdot \frac{\frac{z \cdot y}{\sqrt[3]{t} \cdot \sqrt[3]{t}}}{\sqrt[3]{t}} + \left(\frac{\log 1}{t} + 0.5 \cdot \frac{{z}^{2} \cdot y}{t}\right)\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 2019354 
(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)))