Average Error: 5.8 → 3.3
Time: 18.6s
Precision: 64
\[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x}\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.3467080675490262 \cdot 10^{154}:\\ \;\;\;\;\left(\mathsf{fma}\left(\log x, x - 0.5, \frac{1}{\mathsf{fma}\left(0.400000000000006406, x \cdot z, x \cdot \left(12.000000000000048 - {z}^{2} \cdot 0.100952278095241613\right)\right)}\right) + 0.91893853320467001\right) - x\\ \mathbf{elif}\;z \le -2.8321661325580685 \cdot 10^{38} \lor \neg \left(z \le 7.8988963074104728\right):\\ \;\;\;\;\frac{{z}^{2}}{x} \cdot \left(y + 7.93650079365100015 \cdot 10^{-4}\right) - \mathsf{fma}\left(x, -\log x, x\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\mathsf{fma}\left(\log x, x - 0.5, \frac{\mathsf{fma}\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778, z, 0.0833333333333329956\right)}{x}\right) + 0.91893853320467001\right) - x\\ \end{array}\]
\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x}
\begin{array}{l}
\mathbf{if}\;z \le -1.3467080675490262 \cdot 10^{154}:\\
\;\;\;\;\left(\mathsf{fma}\left(\log x, x - 0.5, \frac{1}{\mathsf{fma}\left(0.400000000000006406, x \cdot z, x \cdot \left(12.000000000000048 - {z}^{2} \cdot 0.100952278095241613\right)\right)}\right) + 0.91893853320467001\right) - x\\

\mathbf{elif}\;z \le -2.8321661325580685 \cdot 10^{38} \lor \neg \left(z \le 7.8988963074104728\right):\\
\;\;\;\;\frac{{z}^{2}}{x} \cdot \left(y + 7.93650079365100015 \cdot 10^{-4}\right) - \mathsf{fma}\left(x, -\log x, x\right)\\

\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(\log x, x - 0.5, \frac{\mathsf{fma}\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778, z, 0.0833333333333329956\right)}{x}\right) + 0.91893853320467001\right) - x\\

\end{array}
double f(double x, double y, double z) {
        double r626993 = x;
        double r626994 = 0.5;
        double r626995 = r626993 - r626994;
        double r626996 = log(r626993);
        double r626997 = r626995 * r626996;
        double r626998 = r626997 - r626993;
        double r626999 = 0.91893853320467;
        double r627000 = r626998 + r626999;
        double r627001 = y;
        double r627002 = 0.0007936500793651;
        double r627003 = r627001 + r627002;
        double r627004 = z;
        double r627005 = r627003 * r627004;
        double r627006 = 0.0027777777777778;
        double r627007 = r627005 - r627006;
        double r627008 = r627007 * r627004;
        double r627009 = 0.083333333333333;
        double r627010 = r627008 + r627009;
        double r627011 = r627010 / r626993;
        double r627012 = r627000 + r627011;
        return r627012;
}

double f(double x, double y, double z) {
        double r627013 = z;
        double r627014 = -1.3467080675490262e+154;
        bool r627015 = r627013 <= r627014;
        double r627016 = x;
        double r627017 = log(r627016);
        double r627018 = 0.5;
        double r627019 = r627016 - r627018;
        double r627020 = 1.0;
        double r627021 = 0.4000000000000064;
        double r627022 = r627016 * r627013;
        double r627023 = 12.000000000000048;
        double r627024 = 2.0;
        double r627025 = pow(r627013, r627024);
        double r627026 = 0.10095227809524161;
        double r627027 = r627025 * r627026;
        double r627028 = r627023 - r627027;
        double r627029 = r627016 * r627028;
        double r627030 = fma(r627021, r627022, r627029);
        double r627031 = r627020 / r627030;
        double r627032 = fma(r627017, r627019, r627031);
        double r627033 = 0.91893853320467;
        double r627034 = r627032 + r627033;
        double r627035 = r627034 - r627016;
        double r627036 = -2.8321661325580685e+38;
        bool r627037 = r627013 <= r627036;
        double r627038 = 7.898896307410473;
        bool r627039 = r627013 <= r627038;
        double r627040 = !r627039;
        bool r627041 = r627037 || r627040;
        double r627042 = r627025 / r627016;
        double r627043 = y;
        double r627044 = 0.0007936500793651;
        double r627045 = r627043 + r627044;
        double r627046 = r627042 * r627045;
        double r627047 = -r627017;
        double r627048 = fma(r627016, r627047, r627016);
        double r627049 = r627046 - r627048;
        double r627050 = r627045 * r627013;
        double r627051 = 0.0027777777777778;
        double r627052 = r627050 - r627051;
        double r627053 = 0.083333333333333;
        double r627054 = fma(r627052, r627013, r627053);
        double r627055 = r627054 / r627016;
        double r627056 = fma(r627017, r627019, r627055);
        double r627057 = r627056 + r627033;
        double r627058 = r627057 - r627016;
        double r627059 = r627041 ? r627049 : r627058;
        double r627060 = r627015 ? r627035 : r627059;
        return r627060;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original5.8
Target1.2
Herbie3.3
\[\left(\left(\left(x - 0.5\right) \cdot \log x + \left(0.91893853320467001 - x\right)\right) + \frac{0.0833333333333329956}{x}\right) + \frac{z}{x} \cdot \left(z \cdot \left(y + 7.93650079365100015 \cdot 10^{-4}\right) - 0.0027777777777778\right)\]

Derivation

  1. Split input into 3 regimes
  2. if z < -1.3467080675490262e+154

    1. Initial program 63.7

      \[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x}\]
    2. Simplified63.7

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(\log x, x - 0.5, \frac{\mathsf{fma}\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778, z, 0.0833333333333329956\right)}{x}\right) + 0.91893853320467001\right) - x}\]
    3. Using strategy rm
    4. Applied clear-num63.7

      \[\leadsto \left(\mathsf{fma}\left(\log x, x - 0.5, \color{blue}{\frac{1}{\frac{x}{\mathsf{fma}\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778, z, 0.0833333333333329956\right)}}}\right) + 0.91893853320467001\right) - x\]
    5. Taylor expanded around 0 33.2

      \[\leadsto \left(\mathsf{fma}\left(\log x, x - 0.5, \frac{1}{\color{blue}{\left(0.400000000000006406 \cdot \left(x \cdot z\right) + 12.000000000000048 \cdot x\right) - 0.100952278095241613 \cdot \left(x \cdot {z}^{2}\right)}}\right) + 0.91893853320467001\right) - x\]
    6. Simplified33.2

      \[\leadsto \left(\mathsf{fma}\left(\log x, x - 0.5, \frac{1}{\color{blue}{\mathsf{fma}\left(0.400000000000006406, x \cdot z, x \cdot \left(12.000000000000048 - {z}^{2} \cdot 0.100952278095241613\right)\right)}}\right) + 0.91893853320467001\right) - x\]

    if -1.3467080675490262e+154 < z < -2.8321661325580685e+38 or 7.898896307410473 < z

    1. Initial program 16.9

      \[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x}\]
    2. Simplified16.9

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(\log x, x - 0.5, \frac{\mathsf{fma}\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778, z, 0.0833333333333329956\right)}{x}\right) + 0.91893853320467001\right) - x}\]
    3. Using strategy rm
    4. Applied clear-num16.9

      \[\leadsto \left(\mathsf{fma}\left(\log x, x - 0.5, \color{blue}{\frac{1}{\frac{x}{\mathsf{fma}\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778, z, 0.0833333333333329956\right)}}}\right) + 0.91893853320467001\right) - x\]
    5. Taylor expanded around inf 17.9

      \[\leadsto \color{blue}{\left(7.93650079365100015 \cdot 10^{-4} \cdot \frac{{z}^{2}}{x} + \frac{{z}^{2} \cdot y}{x}\right) - \left(x + x \cdot \log \left(\frac{1}{x}\right)\right)}\]
    6. Simplified9.5

      \[\leadsto \color{blue}{\frac{{z}^{2}}{x} \cdot \left(y + 7.93650079365100015 \cdot 10^{-4}\right) - \mathsf{fma}\left(x, -\log x, x\right)}\]

    if -2.8321661325580685e+38 < z < 7.898896307410473

    1. Initial program 0.3

      \[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x}\]
    2. Simplified0.3

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(\log x, x - 0.5, \frac{\mathsf{fma}\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778, z, 0.0833333333333329956\right)}{x}\right) + 0.91893853320467001\right) - x}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification3.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.3467080675490262 \cdot 10^{154}:\\ \;\;\;\;\left(\mathsf{fma}\left(\log x, x - 0.5, \frac{1}{\mathsf{fma}\left(0.400000000000006406, x \cdot z, x \cdot \left(12.000000000000048 - {z}^{2} \cdot 0.100952278095241613\right)\right)}\right) + 0.91893853320467001\right) - x\\ \mathbf{elif}\;z \le -2.8321661325580685 \cdot 10^{38} \lor \neg \left(z \le 7.8988963074104728\right):\\ \;\;\;\;\frac{{z}^{2}}{x} \cdot \left(y + 7.93650079365100015 \cdot 10^{-4}\right) - \mathsf{fma}\left(x, -\log x, x\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\mathsf{fma}\left(\log x, x - 0.5, \frac{\mathsf{fma}\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778, z, 0.0833333333333329956\right)}{x}\right) + 0.91893853320467001\right) - x\\ \end{array}\]

Reproduce

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

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