Average Error: 6.2 → 4.2
Time: 21.6s
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 864747444454020.625:\\ \;\;\;\;\left(\left(\sqrt[3]{\mathsf{fma}\left(x - 0.5, \log x, 0.9189385332046700050057097541866824030876\right)} \cdot \sqrt[3]{\mathsf{fma}\left(x - 0.5, \log x, 0.9189385332046700050057097541866824030876\right)}\right) \cdot \sqrt[3]{\mathsf{fma}\left(x - 0.5, \log x, 0.9189385332046700050057097541866824030876\right)} + \frac{\mathsf{fma}\left(\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321, z, 0.08333333333333299564049667651488562114537\right)}{x}\right) - x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{{z}^{2}}{x}, y, \mathsf{fma}\left(7.936500793651000149400709382518925849581 \cdot 10^{-4}, \frac{{z}^{2}}{x}, \mathsf{fma}\left(\log x, x, -x\right)\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 864747444454020.625:\\
\;\;\;\;\left(\left(\sqrt[3]{\mathsf{fma}\left(x - 0.5, \log x, 0.9189385332046700050057097541866824030876\right)} \cdot \sqrt[3]{\mathsf{fma}\left(x - 0.5, \log x, 0.9189385332046700050057097541866824030876\right)}\right) \cdot \sqrt[3]{\mathsf{fma}\left(x - 0.5, \log x, 0.9189385332046700050057097541866824030876\right)} + \frac{\mathsf{fma}\left(\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321, z, 0.08333333333333299564049667651488562114537\right)}{x}\right) - x\\

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

\end{array}
double f(double x, double y, double z) {
        double r384453 = x;
        double r384454 = 0.5;
        double r384455 = r384453 - r384454;
        double r384456 = log(r384453);
        double r384457 = r384455 * r384456;
        double r384458 = r384457 - r384453;
        double r384459 = 0.91893853320467;
        double r384460 = r384458 + r384459;
        double r384461 = y;
        double r384462 = 0.0007936500793651;
        double r384463 = r384461 + r384462;
        double r384464 = z;
        double r384465 = r384463 * r384464;
        double r384466 = 0.0027777777777778;
        double r384467 = r384465 - r384466;
        double r384468 = r384467 * r384464;
        double r384469 = 0.083333333333333;
        double r384470 = r384468 + r384469;
        double r384471 = r384470 / r384453;
        double r384472 = r384460 + r384471;
        return r384472;
}

double f(double x, double y, double z) {
        double r384473 = x;
        double r384474 = 864747444454020.6;
        bool r384475 = r384473 <= r384474;
        double r384476 = 0.5;
        double r384477 = r384473 - r384476;
        double r384478 = log(r384473);
        double r384479 = 0.91893853320467;
        double r384480 = fma(r384477, r384478, r384479);
        double r384481 = cbrt(r384480);
        double r384482 = r384481 * r384481;
        double r384483 = r384482 * r384481;
        double r384484 = y;
        double r384485 = 0.0007936500793651;
        double r384486 = r384484 + r384485;
        double r384487 = z;
        double r384488 = r384486 * r384487;
        double r384489 = 0.0027777777777778;
        double r384490 = r384488 - r384489;
        double r384491 = 0.083333333333333;
        double r384492 = fma(r384490, r384487, r384491);
        double r384493 = r384492 / r384473;
        double r384494 = r384483 + r384493;
        double r384495 = r384494 - r384473;
        double r384496 = 2.0;
        double r384497 = pow(r384487, r384496);
        double r384498 = r384497 / r384473;
        double r384499 = -r384473;
        double r384500 = fma(r384478, r384473, r384499);
        double r384501 = fma(r384485, r384498, r384500);
        double r384502 = fma(r384498, r384484, r384501);
        double r384503 = r384475 ? r384495 : r384502;
        return r384503;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original6.2
Target1.1
Herbie4.2
\[\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 < 864747444454020.6

    1. Initial program 0.2

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

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

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

    if 864747444454020.6 < x

    1. Initial program 10.6

      \[\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. Simplified10.6

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

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

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

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

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

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

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

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

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

      \[\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)}\]
    14. Simplified7.1

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

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

Reproduce

herbie shell --seed 2019212 +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.91893853320467001 x)) (/ 0.0833333333333329956 x)) (* (/ z x) (- (* z (+ y 7.93650079365100015e-4)) 0.0027777777777778)))

  (+ (+ (- (* (- x 0.5) (log x)) x) 0.91893853320467001) (/ (+ (* (- (* (+ y 7.93650079365100015e-4) z) 0.0027777777777778) z) 0.0833333333333329956) x)))