Average Error: 5.5 → 3.8
Time: 7.3s
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 6.7356500259301125 \cdot 10^{24}:\\ \;\;\;\;\mathsf{fma}\left(\log x, x - 0.5, 1 \cdot \frac{\mathsf{fma}\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778, z, 0.0833333333333329956\right)}{x} - \left(x - 0.91893853320467001\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\log \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \left(x - 0.5\right) + \mathsf{fma}\left(\log \left(\sqrt[3]{x}\right), x - 0.5, 0.91893853320467001 - x\right)\right) + \mathsf{fma}\left(\frac{{z}^{2}}{x}, y + 7.93650079365100015 \cdot 10^{-4}, -0.0027777777777778 \cdot \frac{z}{x}\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 6.7356500259301125 \cdot 10^{24}:\\
\;\;\;\;\mathsf{fma}\left(\log x, x - 0.5, 1 \cdot \frac{\mathsf{fma}\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778, z, 0.0833333333333329956\right)}{x} - \left(x - 0.91893853320467001\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\left(\log \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \left(x - 0.5\right) + \mathsf{fma}\left(\log \left(\sqrt[3]{x}\right), x - 0.5, 0.91893853320467001 - x\right)\right) + \mathsf{fma}\left(\frac{{z}^{2}}{x}, y + 7.93650079365100015 \cdot 10^{-4}, -0.0027777777777778 \cdot \frac{z}{x}\right)\\

\end{array}
double f(double x, double y, double z) {
        double r465520 = x;
        double r465521 = 0.5;
        double r465522 = r465520 - r465521;
        double r465523 = log(r465520);
        double r465524 = r465522 * r465523;
        double r465525 = r465524 - r465520;
        double r465526 = 0.91893853320467;
        double r465527 = r465525 + r465526;
        double r465528 = y;
        double r465529 = 0.0007936500793651;
        double r465530 = r465528 + r465529;
        double r465531 = z;
        double r465532 = r465530 * r465531;
        double r465533 = 0.0027777777777778;
        double r465534 = r465532 - r465533;
        double r465535 = r465534 * r465531;
        double r465536 = 0.083333333333333;
        double r465537 = r465535 + r465536;
        double r465538 = r465537 / r465520;
        double r465539 = r465527 + r465538;
        return r465539;
}

double f(double x, double y, double z) {
        double r465540 = x;
        double r465541 = 6.735650025930113e+24;
        bool r465542 = r465540 <= r465541;
        double r465543 = log(r465540);
        double r465544 = 0.5;
        double r465545 = r465540 - r465544;
        double r465546 = 1.0;
        double r465547 = y;
        double r465548 = 0.0007936500793651;
        double r465549 = r465547 + r465548;
        double r465550 = z;
        double r465551 = r465549 * r465550;
        double r465552 = 0.0027777777777778;
        double r465553 = r465551 - r465552;
        double r465554 = 0.083333333333333;
        double r465555 = fma(r465553, r465550, r465554);
        double r465556 = r465555 / r465540;
        double r465557 = r465546 * r465556;
        double r465558 = 0.91893853320467;
        double r465559 = r465540 - r465558;
        double r465560 = r465557 - r465559;
        double r465561 = fma(r465543, r465545, r465560);
        double r465562 = cbrt(r465540);
        double r465563 = r465562 * r465562;
        double r465564 = log(r465563);
        double r465565 = r465564 * r465545;
        double r465566 = log(r465562);
        double r465567 = r465558 - r465540;
        double r465568 = fma(r465566, r465545, r465567);
        double r465569 = r465565 + r465568;
        double r465570 = 2.0;
        double r465571 = pow(r465550, r465570);
        double r465572 = r465571 / r465540;
        double r465573 = r465550 / r465540;
        double r465574 = r465552 * r465573;
        double r465575 = -r465574;
        double r465576 = fma(r465572, r465549, r465575);
        double r465577 = r465569 + r465576;
        double r465578 = r465542 ? r465561 : r465577;
        return r465578;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original5.5
Target1.2
Herbie3.8
\[\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 < 6.735650025930113e+24

    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. Simplified0.2

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

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

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

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

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

    if 6.735650025930113e+24 < x

    1. Initial program 10.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. Using strategy rm
    3. Applied add-cube-cbrt10.1

      \[\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.91893853320467001\right) + \frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x}\]
    4. Applied log-prod10.2

      \[\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.91893853320467001\right) + \frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x}\]
    5. Applied distribute-rgt-in10.2

      \[\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.91893853320467001\right) + \frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x}\]
    6. Applied associate--l+10.2

      \[\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.91893853320467001\right) + \frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x}\]
    7. Applied associate-+l+10.2

      \[\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.91893853320467001\right)\right)} + \frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x}\]
    8. Simplified10.1

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

      \[\leadsto \left(\log \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \left(x - 0.5\right) + \mathsf{fma}\left(\log \left(\sqrt[3]{x}\right), x - 0.5, 0.91893853320467001 - x\right)\right) + \color{blue}{\left(\left(7.93650079365100015 \cdot 10^{-4} \cdot \frac{{z}^{2}}{x} + \frac{{z}^{2} \cdot y}{x}\right) - 0.0027777777777778 \cdot \frac{z}{x}\right)}\]
    10. Simplified6.9

      \[\leadsto \left(\log \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \left(x - 0.5\right) + \mathsf{fma}\left(\log \left(\sqrt[3]{x}\right), x - 0.5, 0.91893853320467001 - x\right)\right) + \color{blue}{\mathsf{fma}\left(\frac{{z}^{2}}{x}, y + 7.93650079365100015 \cdot 10^{-4}, -0.0027777777777778 \cdot \frac{z}{x}\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification3.8

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

Reproduce

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