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

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

\end{array}
double f(double x, double y, double z) {
        double r26832857 = x;
        double r26832858 = 0.5;
        double r26832859 = r26832857 - r26832858;
        double r26832860 = log(r26832857);
        double r26832861 = r26832859 * r26832860;
        double r26832862 = r26832861 - r26832857;
        double r26832863 = 0.91893853320467;
        double r26832864 = r26832862 + r26832863;
        double r26832865 = y;
        double r26832866 = 0.0007936500793651;
        double r26832867 = r26832865 + r26832866;
        double r26832868 = z;
        double r26832869 = r26832867 * r26832868;
        double r26832870 = 0.0027777777777778;
        double r26832871 = r26832869 - r26832870;
        double r26832872 = r26832871 * r26832868;
        double r26832873 = 0.083333333333333;
        double r26832874 = r26832872 + r26832873;
        double r26832875 = r26832874 / r26832857;
        double r26832876 = r26832864 + r26832875;
        return r26832876;
}

double f(double x, double y, double z) {
        double r26832877 = x;
        double r26832878 = 97714149.37215932;
        bool r26832879 = r26832877 <= r26832878;
        double r26832880 = y;
        double r26832881 = 0.0007936500793651;
        double r26832882 = r26832880 + r26832881;
        double r26832883 = z;
        double r26832884 = r26832882 * r26832883;
        double r26832885 = 0.0027777777777778;
        double r26832886 = r26832884 - r26832885;
        double r26832887 = 0.083333333333333;
        double r26832888 = fma(r26832886, r26832883, r26832887);
        double r26832889 = r26832888 / r26832877;
        double r26832890 = log(r26832877);
        double r26832891 = r26832877 * r26832890;
        double r26832892 = 0.91893853320467;
        double r26832893 = 0.5;
        double r26832894 = r26832890 * r26832893;
        double r26832895 = r26832892 - r26832894;
        double r26832896 = r26832895 - r26832877;
        double r26832897 = r26832891 + r26832896;
        double r26832898 = r26832889 + r26832897;
        double r26832899 = r26832883 * r26832883;
        double r26832900 = r26832899 / r26832877;
        double r26832901 = r26832881 * r26832900;
        double r26832902 = fma(r26832900, r26832880, r26832901);
        double r26832903 = r26832883 / r26832877;
        double r26832904 = r26832885 * r26832903;
        double r26832905 = r26832902 - r26832904;
        double r26832906 = fma(r26832890, r26832893, r26832877);
        double r26832907 = r26832892 - r26832906;
        double r26832908 = fma(r26832877, r26832890, r26832907);
        double r26832909 = r26832905 + r26832908;
        double r26832910 = r26832879 ? r26832898 : r26832909;
        return r26832910;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original6.2
Target1.2
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 < 97714149.37215932

    1. Initial program 0.1

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

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

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

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

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

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

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

    if 97714149.37215932 < x

    1. Initial program 10.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. Simplified10.8

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

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

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

      \[\leadsto \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)} + \mathsf{fma}\left(x, \log x, 0.9189385332046700050057097541866824030876 - \mathsf{fma}\left(\log x, 0.5, x\right)\right)\]
    6. Simplified7.2

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

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

Reproduce

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