Average Error: 5.6 → 4.0
Time: 31.4s
Precision: 64
\[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}\]
\[\begin{array}{l} \mathbf{if}\;x \le 5.568098794776475 \cdot 10^{+44}:\\ \;\;\;\;\frac{\mathsf{fma}\left(z, z \cdot \left(0.0007936500793651 + y\right) - 0.0027777777777778, 0.083333333333333\right)}{x} - \frac{\mathsf{fma}\left(-\log x, x - 0.5, x\right) \cdot \mathsf{fma}\left(-\log x, x - 0.5, x\right) - 0.91893853320467 \cdot 0.91893853320467}{\mathsf{fma}\left(-\log x, x - 0.5, x\right) + 0.91893853320467}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(0.0007936500793651 + y\right) \cdot \frac{z \cdot z}{x} - \frac{z}{x} \cdot 0.0027777777777778\right) - \left(x - \mathsf{fma}\left(\log x, x - 0.5, 0.91893853320467\right)\right)\\ \end{array}\]
\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\begin{array}{l}
\mathbf{if}\;x \le 5.568098794776475 \cdot 10^{+44}:\\
\;\;\;\;\frac{\mathsf{fma}\left(z, z \cdot \left(0.0007936500793651 + y\right) - 0.0027777777777778, 0.083333333333333\right)}{x} - \frac{\mathsf{fma}\left(-\log x, x - 0.5, x\right) \cdot \mathsf{fma}\left(-\log x, x - 0.5, x\right) - 0.91893853320467 \cdot 0.91893853320467}{\mathsf{fma}\left(-\log x, x - 0.5, x\right) + 0.91893853320467}\\

\mathbf{else}:\\
\;\;\;\;\left(\left(0.0007936500793651 + y\right) \cdot \frac{z \cdot z}{x} - \frac{z}{x} \cdot 0.0027777777777778\right) - \left(x - \mathsf{fma}\left(\log x, x - 0.5, 0.91893853320467\right)\right)\\

\end{array}
double f(double x, double y, double z) {
        double r19434143 = x;
        double r19434144 = 0.5;
        double r19434145 = r19434143 - r19434144;
        double r19434146 = log(r19434143);
        double r19434147 = r19434145 * r19434146;
        double r19434148 = r19434147 - r19434143;
        double r19434149 = 0.91893853320467;
        double r19434150 = r19434148 + r19434149;
        double r19434151 = y;
        double r19434152 = 0.0007936500793651;
        double r19434153 = r19434151 + r19434152;
        double r19434154 = z;
        double r19434155 = r19434153 * r19434154;
        double r19434156 = 0.0027777777777778;
        double r19434157 = r19434155 - r19434156;
        double r19434158 = r19434157 * r19434154;
        double r19434159 = 0.083333333333333;
        double r19434160 = r19434158 + r19434159;
        double r19434161 = r19434160 / r19434143;
        double r19434162 = r19434150 + r19434161;
        return r19434162;
}

double f(double x, double y, double z) {
        double r19434163 = x;
        double r19434164 = 5.568098794776475e+44;
        bool r19434165 = r19434163 <= r19434164;
        double r19434166 = z;
        double r19434167 = 0.0007936500793651;
        double r19434168 = y;
        double r19434169 = r19434167 + r19434168;
        double r19434170 = r19434166 * r19434169;
        double r19434171 = 0.0027777777777778;
        double r19434172 = r19434170 - r19434171;
        double r19434173 = 0.083333333333333;
        double r19434174 = fma(r19434166, r19434172, r19434173);
        double r19434175 = r19434174 / r19434163;
        double r19434176 = log(r19434163);
        double r19434177 = -r19434176;
        double r19434178 = 0.5;
        double r19434179 = r19434163 - r19434178;
        double r19434180 = fma(r19434177, r19434179, r19434163);
        double r19434181 = r19434180 * r19434180;
        double r19434182 = 0.91893853320467;
        double r19434183 = r19434182 * r19434182;
        double r19434184 = r19434181 - r19434183;
        double r19434185 = r19434180 + r19434182;
        double r19434186 = r19434184 / r19434185;
        double r19434187 = r19434175 - r19434186;
        double r19434188 = r19434166 * r19434166;
        double r19434189 = r19434188 / r19434163;
        double r19434190 = r19434169 * r19434189;
        double r19434191 = r19434166 / r19434163;
        double r19434192 = r19434191 * r19434171;
        double r19434193 = r19434190 - r19434192;
        double r19434194 = fma(r19434176, r19434179, r19434182);
        double r19434195 = r19434163 - r19434194;
        double r19434196 = r19434193 - r19434195;
        double r19434197 = r19434165 ? r19434187 : r19434196;
        return r19434197;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original5.6
Target1.1
Herbie4.0
\[\left(\left(\left(x - 0.5\right) \cdot \log x + \left(0.91893853320467 - x\right)\right) + \frac{0.083333333333333}{x}\right) + \frac{z}{x} \cdot \left(z \cdot \left(y + 0.0007936500793651\right) - 0.0027777777777778\right)\]

Derivation

  1. Split input into 2 regimes
  2. if x < 5.568098794776475e+44

    1. Initial program 0.3

      \[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}\]
    2. Simplified0.3

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(z, \left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778, 0.083333333333333\right)}{x} - \left(x - \mathsf{fma}\left(\log x, x - 0.5, 0.91893853320467\right)\right)}\]
    3. Taylor expanded around inf 0.4

      \[\leadsto \frac{\mathsf{fma}\left(z, \left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778, 0.083333333333333\right)}{x} - \color{blue}{\left(\left(x + x \cdot \log \left(\frac{1}{x}\right)\right) - \left(0.5 \cdot \log \left(\frac{1}{x}\right) + 0.91893853320467\right)\right)}\]
    4. Simplified0.3

      \[\leadsto \frac{\mathsf{fma}\left(z, \left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778, 0.083333333333333\right)}{x} - \color{blue}{\left(\mathsf{fma}\left(-\log x, x - 0.5, x\right) - 0.91893853320467\right)}\]
    5. Using strategy rm
    6. Applied flip--0.3

      \[\leadsto \frac{\mathsf{fma}\left(z, \left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778, 0.083333333333333\right)}{x} - \color{blue}{\frac{\mathsf{fma}\left(-\log x, x - 0.5, x\right) \cdot \mathsf{fma}\left(-\log x, x - 0.5, x\right) - 0.91893853320467 \cdot 0.91893853320467}{\mathsf{fma}\left(-\log x, x - 0.5, x\right) + 0.91893853320467}}\]

    if 5.568098794776475e+44 < x

    1. Initial program 10.7

      \[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}\]
    2. Simplified10.7

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(z, \left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778, 0.083333333333333\right)}{x} - \left(x - \mathsf{fma}\left(\log x, x - 0.5, 0.91893853320467\right)\right)}\]
    3. Taylor expanded around inf 10.7

      \[\leadsto \color{blue}{\left(\left(0.0007936500793651 \cdot \frac{{z}^{2}}{x} + \frac{{z}^{2} \cdot y}{x}\right) - 0.0027777777777778 \cdot \frac{z}{x}\right)} - \left(x - \mathsf{fma}\left(\log x, x - 0.5, 0.91893853320467\right)\right)\]
    4. Simplified7.6

      \[\leadsto \color{blue}{\left(\frac{z \cdot z}{x} \cdot \left(y + 0.0007936500793651\right) - 0.0027777777777778 \cdot \frac{z}{x}\right)} - \left(x - \mathsf{fma}\left(\log x, x - 0.5, 0.91893853320467\right)\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification4.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le 5.568098794776475 \cdot 10^{+44}:\\ \;\;\;\;\frac{\mathsf{fma}\left(z, z \cdot \left(0.0007936500793651 + y\right) - 0.0027777777777778, 0.083333333333333\right)}{x} - \frac{\mathsf{fma}\left(-\log x, x - 0.5, x\right) \cdot \mathsf{fma}\left(-\log x, x - 0.5, x\right) - 0.91893853320467 \cdot 0.91893853320467}{\mathsf{fma}\left(-\log x, x - 0.5, x\right) + 0.91893853320467}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(0.0007936500793651 + y\right) \cdot \frac{z \cdot z}{x} - \frac{z}{x} \cdot 0.0027777777777778\right) - \left(x - \mathsf{fma}\left(\log x, x - 0.5, 0.91893853320467\right)\right)\\ \end{array}\]

Reproduce

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