Average Error: 6.0 → 4.1
Time: 14.7s
Precision: 64
\[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x}\]
\[\begin{array}{l} \mathbf{if}\;\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z \le -2.10986659489873168 \cdot 10^{122}:\\ \;\;\;\;\frac{{z}^{2}}{x} \cdot \left(y + 7.93650079365100015 \cdot 10^{-4}\right) - \mathsf{fma}\left(x, -\log x, x\right)\\ \mathbf{elif}\;\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z \le 6.70657235975613286 \cdot 10^{302}:\\ \;\;\;\;\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \frac{1}{\frac{x}{\mathsf{fma}\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778, z, 0.0833333333333329956\right)}}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \frac{1}{\mathsf{fma}\left(0.400000000000006406, x \cdot z, 12.000000000000048 \cdot x\right) - 0.100952278095241613 \cdot \left(x \cdot {z}^{2}\right)}\\ \end{array}\]
\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x}
\begin{array}{l}
\mathbf{if}\;\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z \le -2.10986659489873168 \cdot 10^{122}:\\
\;\;\;\;\frac{{z}^{2}}{x} \cdot \left(y + 7.93650079365100015 \cdot 10^{-4}\right) - \mathsf{fma}\left(x, -\log x, x\right)\\

\mathbf{elif}\;\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z \le 6.70657235975613286 \cdot 10^{302}:\\
\;\;\;\;\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \frac{1}{\frac{x}{\mathsf{fma}\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778, z, 0.0833333333333329956\right)}}\\

\mathbf{else}:\\
\;\;\;\;\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \frac{1}{\mathsf{fma}\left(0.400000000000006406, x \cdot z, 12.000000000000048 \cdot x\right) - 0.100952278095241613 \cdot \left(x \cdot {z}^{2}\right)}\\

\end{array}
double f(double x, double y, double z) {
        double r450841 = x;
        double r450842 = 0.5;
        double r450843 = r450841 - r450842;
        double r450844 = log(r450841);
        double r450845 = r450843 * r450844;
        double r450846 = r450845 - r450841;
        double r450847 = 0.91893853320467;
        double r450848 = r450846 + r450847;
        double r450849 = y;
        double r450850 = 0.0007936500793651;
        double r450851 = r450849 + r450850;
        double r450852 = z;
        double r450853 = r450851 * r450852;
        double r450854 = 0.0027777777777778;
        double r450855 = r450853 - r450854;
        double r450856 = r450855 * r450852;
        double r450857 = 0.083333333333333;
        double r450858 = r450856 + r450857;
        double r450859 = r450858 / r450841;
        double r450860 = r450848 + r450859;
        return r450860;
}

double f(double x, double y, double z) {
        double r450861 = y;
        double r450862 = 0.0007936500793651;
        double r450863 = r450861 + r450862;
        double r450864 = z;
        double r450865 = r450863 * r450864;
        double r450866 = 0.0027777777777778;
        double r450867 = r450865 - r450866;
        double r450868 = r450867 * r450864;
        double r450869 = -2.1098665948987317e+122;
        bool r450870 = r450868 <= r450869;
        double r450871 = 2.0;
        double r450872 = pow(r450864, r450871);
        double r450873 = x;
        double r450874 = r450872 / r450873;
        double r450875 = r450874 * r450863;
        double r450876 = log(r450873);
        double r450877 = -r450876;
        double r450878 = fma(r450873, r450877, r450873);
        double r450879 = r450875 - r450878;
        double r450880 = 6.706572359756133e+302;
        bool r450881 = r450868 <= r450880;
        double r450882 = 0.5;
        double r450883 = r450873 - r450882;
        double r450884 = r450883 * r450876;
        double r450885 = r450884 - r450873;
        double r450886 = 0.91893853320467;
        double r450887 = r450885 + r450886;
        double r450888 = 1.0;
        double r450889 = 0.083333333333333;
        double r450890 = fma(r450867, r450864, r450889);
        double r450891 = r450873 / r450890;
        double r450892 = r450888 / r450891;
        double r450893 = r450887 + r450892;
        double r450894 = 0.4000000000000064;
        double r450895 = r450873 * r450864;
        double r450896 = 12.000000000000048;
        double r450897 = r450896 * r450873;
        double r450898 = fma(r450894, r450895, r450897);
        double r450899 = 0.10095227809524161;
        double r450900 = r450873 * r450872;
        double r450901 = r450899 * r450900;
        double r450902 = r450898 - r450901;
        double r450903 = r450888 / r450902;
        double r450904 = r450887 + r450903;
        double r450905 = r450881 ? r450893 : r450904;
        double r450906 = r450870 ? r450879 : r450905;
        return r450906;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original6.0
Target1.1
Herbie4.1
\[\left(\left(\left(x - 0.5\right) \cdot \log x + \left(0.91893853320467001 - x\right)\right) + \frac{0.0833333333333329956}{x}\right) + \frac{z}{x} \cdot \left(z \cdot \left(y + 7.93650079365100015 \cdot 10^{-4}\right) - 0.0027777777777778\right)\]

Derivation

  1. Split input into 3 regimes
  2. if (* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z) < -2.1098665948987317e+122

    1. Initial program 25.0

      \[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x}\]
    2. Simplified25.0

      \[\leadsto \color{blue}{\mathsf{fma}\left(\log x, x - 0.5, \left(\frac{\mathsf{fma}\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778, z, 0.0833333333333329956\right)}{x} - x\right) + 0.91893853320467001\right)}\]
    3. Taylor expanded around inf 25.0

      \[\leadsto \color{blue}{\left(7.93650079365100015 \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. Simplified9.0

      \[\leadsto \color{blue}{\frac{{z}^{2}}{x} \cdot \left(y + 7.93650079365100015 \cdot 10^{-4}\right) - \mathsf{fma}\left(x, -\log x, x\right)}\]

    if -2.1098665948987317e+122 < (* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z) < 6.706572359756133e+302

    1. Initial program 0.2

      \[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x}\]
    2. Using strategy rm
    3. Applied clear-num0.3

      \[\leadsto \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \color{blue}{\frac{1}{\frac{x}{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}}}\]
    4. Simplified0.3

      \[\leadsto \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \frac{1}{\color{blue}{\frac{x}{\mathsf{fma}\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778, z, 0.0833333333333329956\right)}}}\]

    if 6.706572359756133e+302 < (* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z)

    1. Initial program 62.7

      \[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x}\]
    2. Using strategy rm
    3. Applied clear-num62.8

      \[\leadsto \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \color{blue}{\frac{1}{\frac{x}{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}}}\]
    4. Simplified62.8

      \[\leadsto \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \frac{1}{\color{blue}{\frac{x}{\mathsf{fma}\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778, z, 0.0833333333333329956\right)}}}\]
    5. Taylor expanded around 0 47.4

      \[\leadsto \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \frac{1}{\color{blue}{\left(0.400000000000006406 \cdot \left(x \cdot z\right) + 12.000000000000048 \cdot x\right) - 0.100952278095241613 \cdot \left(x \cdot {z}^{2}\right)}}\]
    6. Simplified47.4

      \[\leadsto \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \frac{1}{\color{blue}{\mathsf{fma}\left(0.400000000000006406, x \cdot z, 12.000000000000048 \cdot x\right) - 0.100952278095241613 \cdot \left(x \cdot {z}^{2}\right)}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification4.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z \le -2.10986659489873168 \cdot 10^{122}:\\ \;\;\;\;\frac{{z}^{2}}{x} \cdot \left(y + 7.93650079365100015 \cdot 10^{-4}\right) - \mathsf{fma}\left(x, -\log x, x\right)\\ \mathbf{elif}\;\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z \le 6.70657235975613286 \cdot 10^{302}:\\ \;\;\;\;\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \frac{1}{\frac{x}{\mathsf{fma}\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778, z, 0.0833333333333329956\right)}}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \frac{1}{\mathsf{fma}\left(0.400000000000006406, x \cdot z, 12.000000000000048 \cdot x\right) - 0.100952278095241613 \cdot \left(x \cdot {z}^{2}\right)}\\ \end{array}\]

Reproduce

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