Average Error: 25.2 → 9.1
Time: 16.4s
Precision: 64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \le -0.49844384939791808:\\ \;\;\;\;x - \frac{\log \left(\left(1 - y\right) + \left(\sqrt[3]{y \cdot e^{z}} \cdot \sqrt[3]{y \cdot e^{z}}\right) \cdot \sqrt[3]{y \cdot e^{z}}\right)}{t}\\ \mathbf{elif}\;z \le 9.2741206798617679 \cdot 10^{-221}:\\ \;\;\;\;x - \mathsf{fma}\left(\frac{z \cdot y}{t}, 1, \mathsf{fma}\left(0.5, \frac{\left(\sqrt[3]{{z}^{2}} \cdot \sqrt[3]{{z}^{2}}\right) \cdot \left(\sqrt[3]{{z}^{2}} \cdot y\right)}{t}, \frac{\log 1}{t}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(\mathsf{fma}\left(\frac{1}{2}, {z}^{2} \cdot y, \mathsf{fma}\left(z, y, 1\right)\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.49844384939791808:\\
\;\;\;\;x - \frac{\log \left(\left(1 - y\right) + \left(\sqrt[3]{y \cdot e^{z}} \cdot \sqrt[3]{y \cdot e^{z}}\right) \cdot \sqrt[3]{y \cdot e^{z}}\right)}{t}\\

\mathbf{elif}\;z \le 9.2741206798617679 \cdot 10^{-221}:\\
\;\;\;\;x - \mathsf{fma}\left(\frac{z \cdot y}{t}, 1, \mathsf{fma}\left(0.5, \frac{\left(\sqrt[3]{{z}^{2}} \cdot \sqrt[3]{{z}^{2}}\right) \cdot \left(\sqrt[3]{{z}^{2}} \cdot y\right)}{t}, \frac{\log 1}{t}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;x - \frac{\log \left(\mathsf{fma}\left(\frac{1}{2}, {z}^{2} \cdot y, \mathsf{fma}\left(z, y, 1\right)\right)\right)}{t}\\

\end{array}
double f(double x, double y, double z, double t) {
        double r1525 = x;
        double r1526 = 1.0;
        double r1527 = y;
        double r1528 = r1526 - r1527;
        double r1529 = z;
        double r1530 = exp(r1529);
        double r1531 = r1527 * r1530;
        double r1532 = r1528 + r1531;
        double r1533 = log(r1532);
        double r1534 = t;
        double r1535 = r1533 / r1534;
        double r1536 = r1525 - r1535;
        return r1536;
}

double f(double x, double y, double z, double t) {
        double r1537 = z;
        double r1538 = -0.4984438493979181;
        bool r1539 = r1537 <= r1538;
        double r1540 = x;
        double r1541 = 1.0;
        double r1542 = y;
        double r1543 = r1541 - r1542;
        double r1544 = exp(r1537);
        double r1545 = r1542 * r1544;
        double r1546 = cbrt(r1545);
        double r1547 = r1546 * r1546;
        double r1548 = r1547 * r1546;
        double r1549 = r1543 + r1548;
        double r1550 = log(r1549);
        double r1551 = t;
        double r1552 = r1550 / r1551;
        double r1553 = r1540 - r1552;
        double r1554 = 9.274120679861768e-221;
        bool r1555 = r1537 <= r1554;
        double r1556 = r1537 * r1542;
        double r1557 = r1556 / r1551;
        double r1558 = 0.5;
        double r1559 = 2.0;
        double r1560 = pow(r1537, r1559);
        double r1561 = cbrt(r1560);
        double r1562 = r1561 * r1561;
        double r1563 = r1561 * r1542;
        double r1564 = r1562 * r1563;
        double r1565 = r1564 / r1551;
        double r1566 = log(r1541);
        double r1567 = r1566 / r1551;
        double r1568 = fma(r1558, r1565, r1567);
        double r1569 = fma(r1557, r1541, r1568);
        double r1570 = r1540 - r1569;
        double r1571 = 0.5;
        double r1572 = r1560 * r1542;
        double r1573 = fma(r1537, r1542, r1541);
        double r1574 = fma(r1571, r1572, r1573);
        double r1575 = log(r1574);
        double r1576 = r1575 / r1551;
        double r1577 = r1540 - r1576;
        double r1578 = r1555 ? r1570 : r1577;
        double r1579 = r1539 ? r1553 : r1578;
        return r1579;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original25.2
Target16.4
Herbie9.1
\[\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 < -0.4984438493979181

    1. Initial program 11.2

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

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

    if -0.4984438493979181 < z < 9.274120679861768e-221

    1. Initial program 31.5

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

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

      \[\leadsto x - \mathsf{fma}\left(\frac{z \cdot y}{t}, 1, \mathsf{fma}\left(0.5, \frac{\color{blue}{\left(\left(\sqrt[3]{{z}^{2}} \cdot \sqrt[3]{{z}^{2}}\right) \cdot \sqrt[3]{{z}^{2}}\right)} \cdot y}{t}, \frac{\log 1}{t}\right)\right)\]
    6. Applied associate-*l*6.2

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

    if 9.274120679861768e-221 < z

    1. Initial program 31.5

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

      \[\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. Simplified11.9

      \[\leadsto x - \frac{\log \color{blue}{\left(\mathsf{fma}\left(\frac{1}{2}, {z}^{2} \cdot y, \mathsf{fma}\left(z, y, 1\right)\right)\right)}}{t}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification9.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -0.49844384939791808:\\ \;\;\;\;x - \frac{\log \left(\left(1 - y\right) + \left(\sqrt[3]{y \cdot e^{z}} \cdot \sqrt[3]{y \cdot e^{z}}\right) \cdot \sqrt[3]{y \cdot e^{z}}\right)}{t}\\ \mathbf{elif}\;z \le 9.2741206798617679 \cdot 10^{-221}:\\ \;\;\;\;x - \mathsf{fma}\left(\frac{z \cdot y}{t}, 1, \mathsf{fma}\left(0.5, \frac{\left(\sqrt[3]{{z}^{2}} \cdot \sqrt[3]{{z}^{2}}\right) \cdot \left(\sqrt[3]{{z}^{2}} \cdot y\right)}{t}, \frac{\log 1}{t}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(\mathsf{fma}\left(\frac{1}{2}, {z}^{2} \cdot y, \mathsf{fma}\left(z, y, 1\right)\right)\right)}{t}\\ \end{array}\]

Reproduce

herbie shell --seed 2020025 +o rules:numerics
(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)))