Average Error: 5.9 → 0.9
Time: 28.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 4.451301717348988499663989487365386708889 \cdot 10^{102}:\\ \;\;\;\;\frac{\left(\left(z \cdot z\right) \cdot \left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) - z \cdot 0.002777777777777800001512975569539776188321\right) + 0.08333333333333299564049667651488562114537}{x} + \mathsf{fma}\left(x - 0.5, \log x, 0.9189385332046700050057097541866824030876 - x\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\left(\left(x - 0.5\right) \cdot \log \left(\sqrt[3]{x}\right) - x\right) + 0.9189385332046700050057097541866824030876\right) + \left(x - 0.5\right) \cdot \log \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right)\right) + \left(\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot \left(\frac{z}{x} \cdot z\right) - 0.002777777777777800001512975569539776188321 \cdot \frac{z}{x}\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 4.451301717348988499663989487365386708889 \cdot 10^{102}:\\
\;\;\;\;\frac{\left(\left(z \cdot z\right) \cdot \left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) - z \cdot 0.002777777777777800001512975569539776188321\right) + 0.08333333333333299564049667651488562114537}{x} + \mathsf{fma}\left(x - 0.5, \log x, 0.9189385332046700050057097541866824030876 - x\right)\\

\mathbf{else}:\\
\;\;\;\;\left(\left(\left(\left(x - 0.5\right) \cdot \log \left(\sqrt[3]{x}\right) - x\right) + 0.9189385332046700050057097541866824030876\right) + \left(x - 0.5\right) \cdot \log \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right)\right) + \left(\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot \left(\frac{z}{x} \cdot z\right) - 0.002777777777777800001512975569539776188321 \cdot \frac{z}{x}\right)\\

\end{array}
double f(double x, double y, double z) {
        double r19207947 = x;
        double r19207948 = 0.5;
        double r19207949 = r19207947 - r19207948;
        double r19207950 = log(r19207947);
        double r19207951 = r19207949 * r19207950;
        double r19207952 = r19207951 - r19207947;
        double r19207953 = 0.91893853320467;
        double r19207954 = r19207952 + r19207953;
        double r19207955 = y;
        double r19207956 = 0.0007936500793651;
        double r19207957 = r19207955 + r19207956;
        double r19207958 = z;
        double r19207959 = r19207957 * r19207958;
        double r19207960 = 0.0027777777777778;
        double r19207961 = r19207959 - r19207960;
        double r19207962 = r19207961 * r19207958;
        double r19207963 = 0.083333333333333;
        double r19207964 = r19207962 + r19207963;
        double r19207965 = r19207964 / r19207947;
        double r19207966 = r19207954 + r19207965;
        return r19207966;
}

double f(double x, double y, double z) {
        double r19207967 = x;
        double r19207968 = 4.4513017173489885e+102;
        bool r19207969 = r19207967 <= r19207968;
        double r19207970 = z;
        double r19207971 = r19207970 * r19207970;
        double r19207972 = y;
        double r19207973 = 0.0007936500793651;
        double r19207974 = r19207972 + r19207973;
        double r19207975 = r19207971 * r19207974;
        double r19207976 = 0.0027777777777778;
        double r19207977 = r19207970 * r19207976;
        double r19207978 = r19207975 - r19207977;
        double r19207979 = 0.083333333333333;
        double r19207980 = r19207978 + r19207979;
        double r19207981 = r19207980 / r19207967;
        double r19207982 = 0.5;
        double r19207983 = r19207967 - r19207982;
        double r19207984 = log(r19207967);
        double r19207985 = 0.91893853320467;
        double r19207986 = r19207985 - r19207967;
        double r19207987 = fma(r19207983, r19207984, r19207986);
        double r19207988 = r19207981 + r19207987;
        double r19207989 = cbrt(r19207967);
        double r19207990 = log(r19207989);
        double r19207991 = r19207983 * r19207990;
        double r19207992 = r19207991 - r19207967;
        double r19207993 = r19207992 + r19207985;
        double r19207994 = r19207989 * r19207989;
        double r19207995 = log(r19207994);
        double r19207996 = r19207983 * r19207995;
        double r19207997 = r19207993 + r19207996;
        double r19207998 = r19207970 / r19207967;
        double r19207999 = r19207998 * r19207970;
        double r19208000 = r19207974 * r19207999;
        double r19208001 = r19207976 * r19207998;
        double r19208002 = r19208000 - r19208001;
        double r19208003 = r19207997 + r19208002;
        double r19208004 = r19207969 ? r19207988 : r19208003;
        return r19208004;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original5.9
Target1.3
Herbie0.9
\[\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 < 4.4513017173489885e+102

    1. Initial program 1.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. Taylor expanded around 0 1.2

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x - 0.5, \log x, 0.9189385332046700050057097541866824030876 - x\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 0 1.1

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

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

    if 4.4513017173489885e+102 < x

    1. Initial program 12.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-cbrt12.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-prod12.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-rgt-in12.7

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

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

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

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

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

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

Reproduce

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