Average Error: 6.0 → 4.0
Time: 15.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}\;\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z \le -4.02520276056568099 \cdot 10^{151}:\\ \;\;\;\;\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \left(\frac{{z}^{2}}{x} \cdot \left(y + 7.93650079365100015 \cdot 10^{-4}\right) - 0.0027777777777778 \cdot \frac{z}{x}\right)\\ \mathbf{elif}\;\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z \le 6.70657235975613286 \cdot 10^{302}:\\ \;\;\;\;\left(\left(\left(x - 0.5\right) \cdot \log \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) + \left(\left(x - 0.5\right) \cdot \log \left(\sqrt[3]{x}\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}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(0.400000000000006406, x \cdot z, x \cdot \left(12.000000000000048 - 0.100952278095241613 \cdot {z}^{2}\right)\right)} + \left(\left(\left(0.91893853320467001 - x\right) + x\right) + \mathsf{fma}\left(x - 0.5, \log 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}\;\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z \le -4.02520276056568099 \cdot 10^{151}:\\
\;\;\;\;\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \left(\frac{{z}^{2}}{x} \cdot \left(y + 7.93650079365100015 \cdot 10^{-4}\right) - 0.0027777777777778 \cdot \frac{z}{x}\right)\\

\mathbf{elif}\;\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z \le 6.70657235975613286 \cdot 10^{302}:\\
\;\;\;\;\left(\left(\left(x - 0.5\right) \cdot \log \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) + \left(\left(x - 0.5\right) \cdot \log \left(\sqrt[3]{x}\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}\\

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

\end{array}
double f(double x, double y, double z) {
        double r424349 = x;
        double r424350 = 0.5;
        double r424351 = r424349 - r424350;
        double r424352 = log(r424349);
        double r424353 = r424351 * r424352;
        double r424354 = r424353 - r424349;
        double r424355 = 0.91893853320467;
        double r424356 = r424354 + r424355;
        double r424357 = y;
        double r424358 = 0.0007936500793651;
        double r424359 = r424357 + r424358;
        double r424360 = z;
        double r424361 = r424359 * r424360;
        double r424362 = 0.0027777777777778;
        double r424363 = r424361 - r424362;
        double r424364 = r424363 * r424360;
        double r424365 = 0.083333333333333;
        double r424366 = r424364 + r424365;
        double r424367 = r424366 / r424349;
        double r424368 = r424356 + r424367;
        return r424368;
}

double f(double x, double y, double z) {
        double r424369 = y;
        double r424370 = 0.0007936500793651;
        double r424371 = r424369 + r424370;
        double r424372 = z;
        double r424373 = r424371 * r424372;
        double r424374 = 0.0027777777777778;
        double r424375 = r424373 - r424374;
        double r424376 = r424375 * r424372;
        double r424377 = -4.025202760565681e+151;
        bool r424378 = r424376 <= r424377;
        double r424379 = x;
        double r424380 = 0.5;
        double r424381 = r424379 - r424380;
        double r424382 = log(r424379);
        double r424383 = r424381 * r424382;
        double r424384 = r424383 - r424379;
        double r424385 = 0.91893853320467;
        double r424386 = r424384 + r424385;
        double r424387 = 2.0;
        double r424388 = pow(r424372, r424387);
        double r424389 = r424388 / r424379;
        double r424390 = r424389 * r424371;
        double r424391 = r424372 / r424379;
        double r424392 = r424374 * r424391;
        double r424393 = r424390 - r424392;
        double r424394 = r424386 + r424393;
        double r424395 = 6.706572359756133e+302;
        bool r424396 = r424376 <= r424395;
        double r424397 = cbrt(r424379);
        double r424398 = r424397 * r424397;
        double r424399 = log(r424398);
        double r424400 = r424381 * r424399;
        double r424401 = log(r424397);
        double r424402 = r424381 * r424401;
        double r424403 = r424402 - r424379;
        double r424404 = r424400 + r424403;
        double r424405 = r424404 + r424385;
        double r424406 = 0.083333333333333;
        double r424407 = r424376 + r424406;
        double r424408 = r424407 / r424379;
        double r424409 = r424405 + r424408;
        double r424410 = 1.0;
        double r424411 = 0.4000000000000064;
        double r424412 = r424379 * r424372;
        double r424413 = 12.000000000000048;
        double r424414 = 0.10095227809524161;
        double r424415 = r424414 * r424388;
        double r424416 = r424413 - r424415;
        double r424417 = r424379 * r424416;
        double r424418 = fma(r424411, r424412, r424417);
        double r424419 = r424410 / r424418;
        double r424420 = r424385 - r424379;
        double r424421 = r424420 + r424379;
        double r424422 = -r424379;
        double r424423 = fma(r424381, r424382, r424422);
        double r424424 = r424421 + r424423;
        double r424425 = r424419 + r424424;
        double r424426 = r424396 ? r424409 : r424425;
        double r424427 = r424378 ? r424394 : r424426;
        return r424427;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original6.0
Target1.1
Herbie4.0
\[\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 (* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z) < -4.025202760565681e+151

    1. Initial program 28.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. Taylor expanded around inf 28.0

      \[\leadsto \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\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)}\]
    3. Simplified10.0

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

    if -4.025202760565681e+151 < (* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z) < 6.706572359756133e+302

    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-cube-cbrt0.2

      \[\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-prod0.3

      \[\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-lft-in0.3

      \[\leadsto \left(\left(\color{blue}{\left(\left(x - 0.5\right) \cdot \log \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) + \left(x - 0.5\right) \cdot \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}\]
    6. Applied associate--l+0.3

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

    if 6.706572359756133e+302 < (* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z)

    1. Initial program 62.7

      \[\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 *-un-lft-identity62.7

      \[\leadsto \left(\left(\left(x - 0.5\right) \cdot \log x - \color{blue}{1 \cdot 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 prod-diff62.7

      \[\leadsto \left(\color{blue}{\left(\mathsf{fma}\left(x - 0.5, \log x, -x \cdot 1\right) + \mathsf{fma}\left(-x, 1, x \cdot 1\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}\]
    5. Applied associate-+l+62.7

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(x - 0.5, \log x, -x \cdot 1\right) + \left(\mathsf{fma}\left(-x, 1, x \cdot 1\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}\]
    6. Simplified62.7

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

      \[\leadsto \left(\mathsf{fma}\left(x - 0.5, \log x, -x \cdot 1\right) + \left(\left(0.91893853320467001 - x\right) + x\right)\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}}}\]
    9. Simplified62.7

      \[\leadsto \left(\mathsf{fma}\left(x - 0.5, \log x, -x \cdot 1\right) + \left(\left(0.91893853320467001 - x\right) + x\right)\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)}}}\]
    10. Taylor expanded around 0 47.3

      \[\leadsto \left(\mathsf{fma}\left(x - 0.5, \log x, -x \cdot 1\right) + \left(\left(0.91893853320467001 - x\right) + x\right)\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)}}\]
    11. Simplified47.3

      \[\leadsto \left(\mathsf{fma}\left(x - 0.5, \log x, -x \cdot 1\right) + \left(\left(0.91893853320467001 - x\right) + x\right)\right) + \frac{1}{\color{blue}{\mathsf{fma}\left(0.400000000000006406, x \cdot z, x \cdot \left(12.000000000000048 - 0.100952278095241613 \cdot {z}^{2}\right)\right)}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification4.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z \le -4.02520276056568099 \cdot 10^{151}:\\ \;\;\;\;\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \left(\frac{{z}^{2}}{x} \cdot \left(y + 7.93650079365100015 \cdot 10^{-4}\right) - 0.0027777777777778 \cdot \frac{z}{x}\right)\\ \mathbf{elif}\;\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z \le 6.70657235975613286 \cdot 10^{302}:\\ \;\;\;\;\left(\left(\left(x - 0.5\right) \cdot \log \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) + \left(\left(x - 0.5\right) \cdot \log \left(\sqrt[3]{x}\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}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(0.400000000000006406, x \cdot z, x \cdot \left(12.000000000000048 - 0.100952278095241613 \cdot {z}^{2}\right)\right)} + \left(\left(\left(0.91893853320467001 - x\right) + x\right) + \mathsf{fma}\left(x - 0.5, \log x, -x\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)))