Average Error: 6.0 → 2.7
Time: 8.1s
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 3317354487842124.5:\\ \;\;\;\;\left(\left(\sqrt{\left(x - 0.5\right) \cdot \log x} \cdot \sqrt{\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}\\ \mathbf{elif}\;x \le 1.2009024989148773 \cdot 10^{200}:\\ \;\;\;\;\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)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \frac{1}{\mathsf{fma}\left(0.400000000000006406 \cdot x, z, 12.000000000000048 \cdot x - 0.100952278095241613 \cdot \left(x \cdot {z}^{2}\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 3317354487842124.5:\\
\;\;\;\;\left(\left(\sqrt{\left(x - 0.5\right) \cdot \log x} \cdot \sqrt{\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}\\

\mathbf{elif}\;x \le 1.2009024989148773 \cdot 10^{200}:\\
\;\;\;\;\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)\\

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

\end{array}
double f(double x, double y, double z) {
        double r458697 = x;
        double r458698 = 0.5;
        double r458699 = r458697 - r458698;
        double r458700 = log(r458697);
        double r458701 = r458699 * r458700;
        double r458702 = r458701 - r458697;
        double r458703 = 0.91893853320467;
        double r458704 = r458702 + r458703;
        double r458705 = y;
        double r458706 = 0.0007936500793651;
        double r458707 = r458705 + r458706;
        double r458708 = z;
        double r458709 = r458707 * r458708;
        double r458710 = 0.0027777777777778;
        double r458711 = r458709 - r458710;
        double r458712 = r458711 * r458708;
        double r458713 = 0.083333333333333;
        double r458714 = r458712 + r458713;
        double r458715 = r458714 / r458697;
        double r458716 = r458704 + r458715;
        return r458716;
}

double f(double x, double y, double z) {
        double r458717 = x;
        double r458718 = 3317354487842124.5;
        bool r458719 = r458717 <= r458718;
        double r458720 = 0.5;
        double r458721 = r458717 - r458720;
        double r458722 = log(r458717);
        double r458723 = r458721 * r458722;
        double r458724 = sqrt(r458723);
        double r458725 = r458724 * r458724;
        double r458726 = r458725 - r458717;
        double r458727 = 0.91893853320467;
        double r458728 = r458726 + r458727;
        double r458729 = y;
        double r458730 = 0.0007936500793651;
        double r458731 = r458729 + r458730;
        double r458732 = z;
        double r458733 = r458731 * r458732;
        double r458734 = 0.0027777777777778;
        double r458735 = r458733 - r458734;
        double r458736 = r458735 * r458732;
        double r458737 = 0.083333333333333;
        double r458738 = r458736 + r458737;
        double r458739 = r458738 / r458717;
        double r458740 = r458728 + r458739;
        double r458741 = 1.2009024989148773e+200;
        bool r458742 = r458717 <= r458741;
        double r458743 = 2.0;
        double r458744 = pow(r458732, r458743);
        double r458745 = r458744 / r458717;
        double r458746 = r458730 * r458745;
        double r458747 = 1.0;
        double r458748 = r458747 / r458717;
        double r458749 = log(r458748);
        double r458750 = fma(r458749, r458717, r458717);
        double r458751 = r458746 - r458750;
        double r458752 = fma(r458745, r458729, r458751);
        double r458753 = r458723 - r458717;
        double r458754 = r458753 + r458727;
        double r458755 = 0.4000000000000064;
        double r458756 = r458755 * r458717;
        double r458757 = 12.000000000000048;
        double r458758 = r458757 * r458717;
        double r458759 = 0.10095227809524161;
        double r458760 = r458717 * r458744;
        double r458761 = r458759 * r458760;
        double r458762 = r458758 - r458761;
        double r458763 = fma(r458756, r458732, r458762);
        double r458764 = r458747 / r458763;
        double r458765 = r458754 + r458764;
        double r458766 = r458742 ? r458752 : r458765;
        double r458767 = r458719 ? r458740 : r458766;
        return r458767;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original6.0
Target1.1
Herbie2.7
\[\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 x < 3317354487842124.5

    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 add-sqr-sqrt0.2

      \[\leadsto \left(\left(\color{blue}{\sqrt{\left(x - 0.5\right) \cdot \log x} \cdot \sqrt{\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}\]

    if 3317354487842124.5 < x < 1.2009024989148773e+200

    1. Initial program 8.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. Simplified8.0

      \[\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 8.1

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

      \[\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)}\]

    if 1.2009024989148773e+200 < x

    1. Initial program 14.4

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

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

      \[\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 12.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. Simplified3.5

      \[\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 \cdot x, z, 12.000000000000048 \cdot x - 0.100952278095241613 \cdot \left(x \cdot {z}^{2}\right)\right)}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification2.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le 3317354487842124.5:\\ \;\;\;\;\left(\left(\sqrt{\left(x - 0.5\right) \cdot \log x} \cdot \sqrt{\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}\\ \mathbf{elif}\;x \le 1.2009024989148773 \cdot 10^{200}:\\ \;\;\;\;\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)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \frac{1}{\mathsf{fma}\left(0.400000000000006406 \cdot x, z, 12.000000000000048 \cdot x - 0.100952278095241613 \cdot \left(x \cdot {z}^{2}\right)\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)))