Average Error: 5.5 → 3.8
Time: 7.2s
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, \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, \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 r465536 = x;
        double r465537 = 0.5;
        double r465538 = r465536 - r465537;
        double r465539 = log(r465536);
        double r465540 = r465538 * r465539;
        double r465541 = r465540 - r465536;
        double r465542 = 0.91893853320467;
        double r465543 = r465541 + r465542;
        double r465544 = y;
        double r465545 = 0.0007936500793651;
        double r465546 = r465544 + r465545;
        double r465547 = z;
        double r465548 = r465546 * r465547;
        double r465549 = 0.0027777777777778;
        double r465550 = r465548 - r465549;
        double r465551 = r465550 * r465547;
        double r465552 = 0.083333333333333;
        double r465553 = r465551 + r465552;
        double r465554 = r465553 / r465536;
        double r465555 = r465543 + r465554;
        return r465555;
}

double f(double x, double y, double z) {
        double r465556 = x;
        double r465557 = 6.735650025930113e+24;
        bool r465558 = r465556 <= r465557;
        double r465559 = log(r465556);
        double r465560 = 0.5;
        double r465561 = r465556 - r465560;
        double r465562 = y;
        double r465563 = 0.0007936500793651;
        double r465564 = r465562 + r465563;
        double r465565 = z;
        double r465566 = r465564 * r465565;
        double r465567 = 0.0027777777777778;
        double r465568 = r465566 - r465567;
        double r465569 = 0.083333333333333;
        double r465570 = fma(r465568, r465565, r465569);
        double r465571 = r465570 / r465556;
        double r465572 = 0.91893853320467;
        double r465573 = r465556 - r465572;
        double r465574 = r465571 - r465573;
        double r465575 = fma(r465559, r465561, r465574);
        double r465576 = cbrt(r465556);
        double r465577 = r465576 * r465576;
        double r465578 = log(r465577);
        double r465579 = r465578 * r465561;
        double r465580 = log(r465576);
        double r465581 = r465572 - r465556;
        double r465582 = fma(r465580, r465561, r465581);
        double r465583 = r465579 + r465582;
        double r465584 = 2.0;
        double r465585 = pow(r465565, r465584);
        double r465586 = r465585 / r465556;
        double r465587 = r465565 / r465556;
        double r465588 = r465567 * r465587;
        double r465589 = -r465588;
        double r465590 = fma(r465586, r465564, r465589);
        double r465591 = r465583 + r465590;
        double r465592 = r465558 ? r465575 : r465591;
        return r465592;
}

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 associate-*r/0.2

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

      \[\leadsto \mathsf{fma}\left(\log x, x - 0.5, \frac{\color{blue}{\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, \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)))