Average Error: 6.0 → 4.3
Time: 7.1s
Precision: 64
\[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.9189385332046700050057097541866824030876\right) + \frac{\left(\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321\right) \cdot z + 0.08333333333333299564049667651488562114537}{x}\]
\[\begin{array}{l} \mathbf{if}\;x \le 2.717425698450508370910792508296994577267 \cdot 10^{63}:\\ \;\;\;\;\mathsf{fma}\left(\log x, x - 0.5, \frac{\mathsf{fma}\left(\mathsf{fma}\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}, z, -0.002777777777777800001512975569539776188321\right), z, 0.08333333333333299564049667651488562114537\right)}{x} - \left(x - 0.9189385332046700050057097541866824030876\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{{z}^{2}}{x}, y, 7.936500793651000149400709382518925849581 \cdot 10^{-4} \cdot \frac{{z}^{2}}{x} - \mathsf{fma}\left(\log \left(\frac{1}{x}\right), x, x\right)\right)\\ \end{array}\]
\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.9189385332046700050057097541866824030876\right) + \frac{\left(\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321\right) \cdot z + 0.08333333333333299564049667651488562114537}{x}
\begin{array}{l}
\mathbf{if}\;x \le 2.717425698450508370910792508296994577267 \cdot 10^{63}:\\
\;\;\;\;\mathsf{fma}\left(\log x, x - 0.5, \frac{\mathsf{fma}\left(\mathsf{fma}\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}, z, -0.002777777777777800001512975569539776188321\right), z, 0.08333333333333299564049667651488562114537\right)}{x} - \left(x - 0.9189385332046700050057097541866824030876\right)\right)\\

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

\end{array}
double f(double x, double y, double z) {
        double r367226 = x;
        double r367227 = 0.5;
        double r367228 = r367226 - r367227;
        double r367229 = log(r367226);
        double r367230 = r367228 * r367229;
        double r367231 = r367230 - r367226;
        double r367232 = 0.91893853320467;
        double r367233 = r367231 + r367232;
        double r367234 = y;
        double r367235 = 0.0007936500793651;
        double r367236 = r367234 + r367235;
        double r367237 = z;
        double r367238 = r367236 * r367237;
        double r367239 = 0.0027777777777778;
        double r367240 = r367238 - r367239;
        double r367241 = r367240 * r367237;
        double r367242 = 0.083333333333333;
        double r367243 = r367241 + r367242;
        double r367244 = r367243 / r367226;
        double r367245 = r367233 + r367244;
        return r367245;
}

double f(double x, double y, double z) {
        double r367246 = x;
        double r367247 = 2.7174256984505084e+63;
        bool r367248 = r367246 <= r367247;
        double r367249 = log(r367246);
        double r367250 = 0.5;
        double r367251 = r367246 - r367250;
        double r367252 = y;
        double r367253 = 0.0007936500793651;
        double r367254 = r367252 + r367253;
        double r367255 = z;
        double r367256 = 0.0027777777777778;
        double r367257 = -r367256;
        double r367258 = fma(r367254, r367255, r367257);
        double r367259 = 0.083333333333333;
        double r367260 = fma(r367258, r367255, r367259);
        double r367261 = r367260 / r367246;
        double r367262 = 0.91893853320467;
        double r367263 = r367246 - r367262;
        double r367264 = r367261 - r367263;
        double r367265 = fma(r367249, r367251, r367264);
        double r367266 = 2.0;
        double r367267 = pow(r367255, r367266);
        double r367268 = r367267 / r367246;
        double r367269 = r367253 * r367268;
        double r367270 = 1.0;
        double r367271 = r367270 / r367246;
        double r367272 = log(r367271);
        double r367273 = fma(r367272, r367246, r367246);
        double r367274 = r367269 - r367273;
        double r367275 = fma(r367268, r367252, r367274);
        double r367276 = r367248 ? r367265 : r367275;
        return r367276;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original6.0
Target1.1
Herbie4.3
\[\left(\left(\left(x - 0.5\right) \cdot \log x + \left(0.9189385332046700050057097541866824030876 - x\right)\right) + \frac{0.08333333333333299564049667651488562114537}{x}\right) + \frac{z}{x} \cdot \left(z \cdot \left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) - 0.002777777777777800001512975569539776188321\right)\]

Derivation

  1. Split input into 2 regimes
  2. if x < 2.7174256984505084e+63

    1. Initial program 0.7

      \[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.9189385332046700050057097541866824030876\right) + \frac{\left(\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321\right) \cdot z + 0.08333333333333299564049667651488562114537}{x}\]
    2. Simplified0.6

      \[\leadsto \color{blue}{\mathsf{fma}\left(\log x, x - 0.5, \frac{\left(\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321\right) \cdot z + 0.08333333333333299564049667651488562114537}{x} - \left(x - 0.9189385332046700050057097541866824030876\right)\right)}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity0.6

      \[\leadsto \mathsf{fma}\left(\log x, x - 0.5, \frac{\left(\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321\right) \cdot z + 0.08333333333333299564049667651488562114537}{\color{blue}{1 \cdot x}} - \left(x - 0.9189385332046700050057097541866824030876\right)\right)\]
    5. Applied associate-/r*0.6

      \[\leadsto \mathsf{fma}\left(\log x, x - 0.5, \color{blue}{\frac{\frac{\left(\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321\right) \cdot z + 0.08333333333333299564049667651488562114537}{1}}{x}} - \left(x - 0.9189385332046700050057097541866824030876\right)\right)\]
    6. Simplified0.6

      \[\leadsto \mathsf{fma}\left(\log x, x - 0.5, \frac{\color{blue}{\mathsf{fma}\left(\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321, z, 0.08333333333333299564049667651488562114537\right)}}{x} - \left(x - 0.9189385332046700050057097541866824030876\right)\right)\]
    7. Using strategy rm
    8. Applied fma-neg0.6

      \[\leadsto \mathsf{fma}\left(\log x, x - 0.5, \frac{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}, z, -0.002777777777777800001512975569539776188321\right)}, z, 0.08333333333333299564049667651488562114537\right)}{x} - \left(x - 0.9189385332046700050057097541866824030876\right)\right)\]

    if 2.7174256984505084e+63 < x

    1. Initial program 11.8

      \[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.9189385332046700050057097541866824030876\right) + \frac{\left(\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321\right) \cdot z + 0.08333333333333299564049667651488562114537}{x}\]
    2. Simplified11.8

      \[\leadsto \color{blue}{\mathsf{fma}\left(\log x, x - 0.5, \frac{\left(\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321\right) \cdot z + 0.08333333333333299564049667651488562114537}{x} - \left(x - 0.9189385332046700050057097541866824030876\right)\right)}\]
    3. Taylor expanded around inf 12.0

      \[\leadsto \color{blue}{\left(7.936500793651000149400709382518925849581 \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)}\]
    4. Simplified8.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le 2.717425698450508370910792508296994577267 \cdot 10^{63}:\\ \;\;\;\;\mathsf{fma}\left(\log x, x - 0.5, \frac{\mathsf{fma}\left(\mathsf{fma}\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}, z, -0.002777777777777800001512975569539776188321\right), z, 0.08333333333333299564049667651488562114537\right)}{x} - \left(x - 0.9189385332046700050057097541866824030876\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{{z}^{2}}{x}, y, 7.936500793651000149400709382518925849581 \cdot 10^{-4} \cdot \frac{{z}^{2}}{x} - \mathsf{fma}\left(\log \left(\frac{1}{x}\right), x, x\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019354 +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)))