Average Error: 6.0 → 4.1
Time: 10.5s
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}\;x \le 8439582884.126038:\\ \;\;\;\;\log x \cdot \left(x - 0.5\right) + \left(\frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x} - \left(x - 0.91893853320467001\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{{z}^{2}}{x}, y, 7.93650079365100015 \cdot 10^{-4} \cdot \frac{{z}^{2}}{x} - \mathsf{fma}\left(\log \left(\frac{1}{x}\right), x, x\right)\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}\;x \le 8439582884.126038:\\
\;\;\;\;\log x \cdot \left(x - 0.5\right) + \left(\frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x} - \left(x - 0.91893853320467001\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{{z}^{2}}{x}, y, 7.93650079365100015 \cdot 10^{-4} \cdot \frac{{z}^{2}}{x} - \mathsf{fma}\left(\log \left(\frac{1}{x}\right), x, x\right)\right)\\

\end{array}
double f(double x, double y, double z) {
        double r454685 = x;
        double r454686 = 0.5;
        double r454687 = r454685 - r454686;
        double r454688 = log(r454685);
        double r454689 = r454687 * r454688;
        double r454690 = r454689 - r454685;
        double r454691 = 0.91893853320467;
        double r454692 = r454690 + r454691;
        double r454693 = y;
        double r454694 = 0.0007936500793651;
        double r454695 = r454693 + r454694;
        double r454696 = z;
        double r454697 = r454695 * r454696;
        double r454698 = 0.0027777777777778;
        double r454699 = r454697 - r454698;
        double r454700 = r454699 * r454696;
        double r454701 = 0.083333333333333;
        double r454702 = r454700 + r454701;
        double r454703 = r454702 / r454685;
        double r454704 = r454692 + r454703;
        return r454704;
}

double f(double x, double y, double z) {
        double r454705 = x;
        double r454706 = 8439582884.126038;
        bool r454707 = r454705 <= r454706;
        double r454708 = log(r454705);
        double r454709 = 0.5;
        double r454710 = r454705 - r454709;
        double r454711 = r454708 * r454710;
        double r454712 = y;
        double r454713 = 0.0007936500793651;
        double r454714 = r454712 + r454713;
        double r454715 = z;
        double r454716 = r454714 * r454715;
        double r454717 = 0.0027777777777778;
        double r454718 = r454716 - r454717;
        double r454719 = r454718 * r454715;
        double r454720 = 0.083333333333333;
        double r454721 = r454719 + r454720;
        double r454722 = r454721 / r454705;
        double r454723 = 0.91893853320467;
        double r454724 = r454705 - r454723;
        double r454725 = r454722 - r454724;
        double r454726 = r454711 + r454725;
        double r454727 = 2.0;
        double r454728 = pow(r454715, r454727);
        double r454729 = r454728 / r454705;
        double r454730 = r454713 * r454729;
        double r454731 = 1.0;
        double r454732 = r454731 / r454705;
        double r454733 = log(r454732);
        double r454734 = fma(r454733, r454705, r454705);
        double r454735 = r454730 - r454734;
        double r454736 = fma(r454729, r454712, r454735);
        double r454737 = r454707 ? r454726 : r454736;
        return r454737;
}

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 2 regimes
  2. if x < 8439582884.126038

    1. Initial program 0.1

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

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

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

    if 8439582884.126038 < x

    1. Initial program 10.5

      \[\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. Simplified10.4

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

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

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

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

Reproduce

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