Average Error: 5.3 → 4.0
Time: 19.3s
Precision: 64
\[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}\]
\[\begin{array}{l} \mathbf{if}\;x \le 1.562291000289737 \cdot 10^{+231}:\\ \;\;\;\;\left(\left(\mathsf{fma}\left(x, -1, x\right) + 0.91893853320467\right) + \mathsf{fma}\left(x - 0.5, \log x, \left(\left(-e^{\frac{1}{3} \cdot \log x}\right) \cdot e^{\frac{1}{3} \cdot \log x}\right) \cdot \sqrt[3]{x}\right)\right) + \frac{0.083333333333333 + \left(\left(0.0007936500793651 + y\right) \cdot z - 0.0027777777777778\right) \cdot z}{x}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\log x, x - 0.5, \left(0.91893853320467 - x\right) + \frac{\mathsf{fma}\left(\left(\left(\left(0.0007936500793651 + y\right) \cdot z - 0.0027777777777778\right)\right), z, 0.083333333333333\right)}{x}\right)\\ \end{array}\]
\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\begin{array}{l}
\mathbf{if}\;x \le 1.562291000289737 \cdot 10^{+231}:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(x, -1, x\right) + 0.91893853320467\right) + \mathsf{fma}\left(x - 0.5, \log x, \left(\left(-e^{\frac{1}{3} \cdot \log x}\right) \cdot e^{\frac{1}{3} \cdot \log x}\right) \cdot \sqrt[3]{x}\right)\right) + \frac{0.083333333333333 + \left(\left(0.0007936500793651 + y\right) \cdot z - 0.0027777777777778\right) \cdot z}{x}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log x, x - 0.5, \left(0.91893853320467 - x\right) + \frac{\mathsf{fma}\left(\left(\left(\left(0.0007936500793651 + y\right) \cdot z - 0.0027777777777778\right)\right), z, 0.083333333333333\right)}{x}\right)\\

\end{array}
double f(double x, double y, double z) {
        double r7725688 = x;
        double r7725689 = 0.5;
        double r7725690 = r7725688 - r7725689;
        double r7725691 = log(r7725688);
        double r7725692 = r7725690 * r7725691;
        double r7725693 = r7725692 - r7725688;
        double r7725694 = 0.91893853320467;
        double r7725695 = r7725693 + r7725694;
        double r7725696 = y;
        double r7725697 = 0.0007936500793651;
        double r7725698 = r7725696 + r7725697;
        double r7725699 = z;
        double r7725700 = r7725698 * r7725699;
        double r7725701 = 0.0027777777777778;
        double r7725702 = r7725700 - r7725701;
        double r7725703 = r7725702 * r7725699;
        double r7725704 = 0.083333333333333;
        double r7725705 = r7725703 + r7725704;
        double r7725706 = r7725705 / r7725688;
        double r7725707 = r7725695 + r7725706;
        return r7725707;
}

double f(double x, double y, double z) {
        double r7725708 = x;
        double r7725709 = 1.562291000289737e+231;
        bool r7725710 = r7725708 <= r7725709;
        double r7725711 = -1.0;
        double r7725712 = fma(r7725708, r7725711, r7725708);
        double r7725713 = 0.91893853320467;
        double r7725714 = r7725712 + r7725713;
        double r7725715 = 0.5;
        double r7725716 = r7725708 - r7725715;
        double r7725717 = log(r7725708);
        double r7725718 = 0.3333333333333333;
        double r7725719 = r7725718 * r7725717;
        double r7725720 = exp(r7725719);
        double r7725721 = -r7725720;
        double r7725722 = r7725721 * r7725720;
        double r7725723 = cbrt(r7725708);
        double r7725724 = r7725722 * r7725723;
        double r7725725 = fma(r7725716, r7725717, r7725724);
        double r7725726 = r7725714 + r7725725;
        double r7725727 = 0.083333333333333;
        double r7725728 = 0.0007936500793651;
        double r7725729 = y;
        double r7725730 = r7725728 + r7725729;
        double r7725731 = z;
        double r7725732 = r7725730 * r7725731;
        double r7725733 = 0.0027777777777778;
        double r7725734 = r7725732 - r7725733;
        double r7725735 = r7725734 * r7725731;
        double r7725736 = r7725727 + r7725735;
        double r7725737 = r7725736 / r7725708;
        double r7725738 = r7725726 + r7725737;
        double r7725739 = r7725713 - r7725708;
        double r7725740 = /* ERROR: no posit support in C */;
        double r7725741 = /* ERROR: no posit support in C */;
        double r7725742 = fma(r7725741, r7725731, r7725727);
        double r7725743 = r7725742 / r7725708;
        double r7725744 = r7725739 + r7725743;
        double r7725745 = fma(r7725717, r7725716, r7725744);
        double r7725746 = r7725710 ? r7725738 : r7725745;
        return r7725746;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original5.3
Target1.2
Herbie4.0
\[\left(\left(\left(x - 0.5\right) \cdot \log x + \left(0.91893853320467 - x\right)\right) + \frac{0.083333333333333}{x}\right) + \frac{z}{x} \cdot \left(z \cdot \left(y + 0.0007936500793651\right) - 0.0027777777777778\right)\]

Derivation

  1. Split input into 2 regimes
  2. if x < 1.562291000289737e+231

    1. Initial program 3.8

      \[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}\]
    2. Using strategy rm
    3. Applied add-cube-cbrt3.8

      \[\leadsto \left(\left(\left(x - 0.5\right) \cdot \log x - \color{blue}{\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \sqrt[3]{x}}\right) + 0.91893853320467\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}\]
    4. Applied prod-diff3.7

      \[\leadsto \left(\color{blue}{\left(\mathsf{fma}\left(x - 0.5, \log x, -\sqrt[3]{x} \cdot \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right)\right) + \mathsf{fma}\left(-\sqrt[3]{x}, \sqrt[3]{x} \cdot \sqrt[3]{x}, \sqrt[3]{x} \cdot \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right)\right)\right)} + 0.91893853320467\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}\]
    5. Applied associate-+l+3.7

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(x - 0.5, \log x, -\sqrt[3]{x} \cdot \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right)\right) + \left(\mathsf{fma}\left(-\sqrt[3]{x}, \sqrt[3]{x} \cdot \sqrt[3]{x}, \sqrt[3]{x} \cdot \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right)\right) + 0.91893853320467\right)\right)} + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}\]
    6. Simplified3.7

      \[\leadsto \left(\mathsf{fma}\left(x - 0.5, \log x, -\sqrt[3]{x} \cdot \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right)\right) + \color{blue}{\left(\mathsf{fma}\left(x, -1, x\right) + 0.91893853320467\right)}\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}\]
    7. Using strategy rm
    8. Applied add-exp-log3.8

      \[\leadsto \left(\mathsf{fma}\left(x - 0.5, \log x, -\sqrt[3]{x} \cdot \left(\color{blue}{e^{\log \left(\sqrt[3]{x}\right)}} \cdot \sqrt[3]{x}\right)\right) + \left(\mathsf{fma}\left(x, -1, x\right) + 0.91893853320467\right)\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}\]
    9. Simplified3.7

      \[\leadsto \left(\mathsf{fma}\left(x - 0.5, \log x, -\sqrt[3]{x} \cdot \left(e^{\color{blue}{\frac{1}{3} \cdot \log x}} \cdot \sqrt[3]{x}\right)\right) + \left(\mathsf{fma}\left(x, -1, x\right) + 0.91893853320467\right)\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}\]
    10. Using strategy rm
    11. Applied add-exp-log3.7

      \[\leadsto \left(\mathsf{fma}\left(x - 0.5, \log x, -\sqrt[3]{x} \cdot \left(e^{\frac{1}{3} \cdot \log x} \cdot \color{blue}{e^{\log \left(\sqrt[3]{x}\right)}}\right)\right) + \left(\mathsf{fma}\left(x, -1, x\right) + 0.91893853320467\right)\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}\]
    12. Simplified3.8

      \[\leadsto \left(\mathsf{fma}\left(x - 0.5, \log x, -\sqrt[3]{x} \cdot \left(e^{\frac{1}{3} \cdot \log x} \cdot e^{\color{blue}{\frac{1}{3} \cdot \log x}}\right)\right) + \left(\mathsf{fma}\left(x, -1, x\right) + 0.91893853320467\right)\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}\]

    if 1.562291000289737e+231 < x

    1. Initial program 14.1

      \[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}\]
    2. Simplified14.0

      \[\leadsto \color{blue}{\mathsf{fma}\left(\log x, x - 0.5, \left(0.91893853320467 - x\right) + \frac{\mathsf{fma}\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778, z, 0.083333333333333\right)}{x}\right)}\]
    3. Using strategy rm
    4. Applied insert-posit165.4

      \[\leadsto \mathsf{fma}\left(\log x, x - 0.5, \left(0.91893853320467 - x\right) + \frac{\mathsf{fma}\left(\color{blue}{\left(\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right)\right)}, z, 0.083333333333333\right)}{x}\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification4.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le 1.562291000289737 \cdot 10^{+231}:\\ \;\;\;\;\left(\left(\mathsf{fma}\left(x, -1, x\right) + 0.91893853320467\right) + \mathsf{fma}\left(x - 0.5, \log x, \left(\left(-e^{\frac{1}{3} \cdot \log x}\right) \cdot e^{\frac{1}{3} \cdot \log x}\right) \cdot \sqrt[3]{x}\right)\right) + \frac{0.083333333333333 + \left(\left(0.0007936500793651 + y\right) \cdot z - 0.0027777777777778\right) \cdot z}{x}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\log x, x - 0.5, \left(0.91893853320467 - x\right) + \frac{\mathsf{fma}\left(\left(\left(\left(0.0007936500793651 + y\right) \cdot z - 0.0027777777777778\right)\right), z, 0.083333333333333\right)}{x}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019156 +o rules:numerics
(FPCore (x y z)
  :name "Numeric.SpecFunctions:$slogFactorial from math-functions-0.1.5.2, B"

  :herbie-target
  (+ (+ (+ (* (- x 0.5) (log x)) (- 0.91893853320467 x)) (/ 0.083333333333333 x)) (* (/ z x) (- (* z (+ y 0.0007936500793651)) 0.0027777777777778)))

  (+ (+ (- (* (- x 0.5) (log x)) x) 0.91893853320467) (/ (+ (* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z) 0.083333333333333) x)))