Average Error: 6.3 → 4.4
Time: 26.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 1.517605033250208516623734790433865590207 \cdot 10^{66}:\\ \;\;\;\;\left(\left(\left(\left(2 \cdot \log \left(\sqrt[3]{x}\right)\right) \cdot \left(x - 0.5\right) + \log \left({x}^{\frac{1}{3}}\right) \cdot \left(x - 0.5\right)\right) - 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}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.5, -\log x, 0.9189385332046700050057097541866824030876 - \mathsf{fma}\left(-\log x, x, x\right)\right) + \mathsf{fma}\left(\frac{z}{x}, -0.002777777777777800001512975569539776188321, \frac{{z}^{2}}{x} \cdot \left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\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 1.517605033250208516623734790433865590207 \cdot 10^{66}:\\
\;\;\;\;\left(\left(\left(\left(2 \cdot \log \left(\sqrt[3]{x}\right)\right) \cdot \left(x - 0.5\right) + \log \left({x}^{\frac{1}{3}}\right) \cdot \left(x - 0.5\right)\right) - 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}\\

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

\end{array}
double f(double x, double y, double z) {
        double r361032 = x;
        double r361033 = 0.5;
        double r361034 = r361032 - r361033;
        double r361035 = log(r361032);
        double r361036 = r361034 * r361035;
        double r361037 = r361036 - r361032;
        double r361038 = 0.91893853320467;
        double r361039 = r361037 + r361038;
        double r361040 = y;
        double r361041 = 0.0007936500793651;
        double r361042 = r361040 + r361041;
        double r361043 = z;
        double r361044 = r361042 * r361043;
        double r361045 = 0.0027777777777778;
        double r361046 = r361044 - r361045;
        double r361047 = r361046 * r361043;
        double r361048 = 0.083333333333333;
        double r361049 = r361047 + r361048;
        double r361050 = r361049 / r361032;
        double r361051 = r361039 + r361050;
        return r361051;
}

double f(double x, double y, double z) {
        double r361052 = x;
        double r361053 = 1.5176050332502085e+66;
        bool r361054 = r361052 <= r361053;
        double r361055 = 2.0;
        double r361056 = cbrt(r361052);
        double r361057 = log(r361056);
        double r361058 = r361055 * r361057;
        double r361059 = 0.5;
        double r361060 = r361052 - r361059;
        double r361061 = r361058 * r361060;
        double r361062 = 0.3333333333333333;
        double r361063 = pow(r361052, r361062);
        double r361064 = log(r361063);
        double r361065 = r361064 * r361060;
        double r361066 = r361061 + r361065;
        double r361067 = r361066 - r361052;
        double r361068 = 0.91893853320467;
        double r361069 = r361067 + r361068;
        double r361070 = y;
        double r361071 = 0.0007936500793651;
        double r361072 = r361070 + r361071;
        double r361073 = z;
        double r361074 = r361072 * r361073;
        double r361075 = 0.0027777777777778;
        double r361076 = r361074 - r361075;
        double r361077 = r361076 * r361073;
        double r361078 = 0.083333333333333;
        double r361079 = r361077 + r361078;
        double r361080 = r361079 / r361052;
        double r361081 = r361069 + r361080;
        double r361082 = log(r361052);
        double r361083 = -r361082;
        double r361084 = fma(r361083, r361052, r361052);
        double r361085 = r361068 - r361084;
        double r361086 = fma(r361059, r361083, r361085);
        double r361087 = r361073 / r361052;
        double r361088 = -r361075;
        double r361089 = pow(r361073, r361055);
        double r361090 = r361089 / r361052;
        double r361091 = r361090 * r361072;
        double r361092 = fma(r361087, r361088, r361091);
        double r361093 = r361086 + r361092;
        double r361094 = r361054 ? r361081 : r361093;
        return r361094;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original6.3
Target1.3
Herbie4.4
\[\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 < 1.5176050332502085e+66

    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. Using strategy rm
    3. Applied add-cube-cbrt0.7

      \[\leadsto \left(\left(\left(x - 0.5\right) \cdot \log \color{blue}{\left(\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \sqrt[3]{x}\right)} - 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}\]
    4. Applied log-prod0.7

      \[\leadsto \left(\left(\left(x - 0.5\right) \cdot \color{blue}{\left(\log \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) + \log \left(\sqrt[3]{x}\right)\right)} - 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}\]
    5. Applied distribute-lft-in0.7

      \[\leadsto \left(\left(\color{blue}{\left(\left(x - 0.5\right) \cdot \log \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) + \left(x - 0.5\right) \cdot \log \left(\sqrt[3]{x}\right)\right)} - 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}\]
    6. Simplified0.7

      \[\leadsto \left(\left(\left(\color{blue}{\left(2 \cdot \log \left(\sqrt[3]{x}\right)\right) \cdot \left(x - 0.5\right)} + \left(x - 0.5\right) \cdot \log \left(\sqrt[3]{x}\right)\right) - 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}\]
    7. Simplified0.7

      \[\leadsto \left(\left(\left(\left(2 \cdot \log \left(\sqrt[3]{x}\right)\right) \cdot \left(x - 0.5\right) + \color{blue}{\log \left(\sqrt[3]{x}\right) \cdot \left(x - 0.5\right)}\right) - 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}\]
    8. Using strategy rm
    9. Applied pow1/30.7

      \[\leadsto \left(\left(\left(\left(2 \cdot \log \left(\sqrt[3]{x}\right)\right) \cdot \left(x - 0.5\right) + \log \color{blue}{\left({x}^{\frac{1}{3}}\right)} \cdot \left(x - 0.5\right)\right) - 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}\]

    if 1.5176050332502085e+66 < x

    1. Initial program 12.5

      \[\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. Taylor expanded around inf 12.5

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le 1.517605033250208516623734790433865590207 \cdot 10^{66}:\\ \;\;\;\;\left(\left(\left(\left(2 \cdot \log \left(\sqrt[3]{x}\right)\right) \cdot \left(x - 0.5\right) + \log \left({x}^{\frac{1}{3}}\right) \cdot \left(x - 0.5\right)\right) - 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}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.5, -\log x, 0.9189385332046700050057097541866824030876 - \mathsf{fma}\left(-\log x, x, x\right)\right) + \mathsf{fma}\left(\frac{z}{x}, -0.002777777777777800001512975569539776188321, \frac{{z}^{2}}{x} \cdot \left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right)\right)\\ \end{array}\]

Reproduce

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