Average Error: 6.2 → 0.3
Time: 5.5s
Precision: binary64
\[\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 2246989294872715:\\ \;\;\;\;\frac{\log x \cdot \left(x \cdot x - 0.5 \cdot 0.5\right)}{x + 0.5} + \left(0.91893853320467001 + \left(\frac{z \cdot \left(z \cdot \left(y + 7.93650079365100015 \cdot 10^{-4}\right) - 0.0027777777777778\right) + 0.0833333333333329956}{x} - x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot \frac{z}{\frac{x}{z}} + x \cdot \left(\log 1 - \left(1 + \left(-\log x\right)\right)\right)\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original6.2
Target1.2
Herbie0.3
\[\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 < 2246989294872715

    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}{\left(x - 0.5\right) \cdot \log x + \left(0.91893853320467001 + \left(\frac{z \cdot \left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) + 0.0833333333333329956}{x} - x\right)\right)}\]
    3. Using strategy rm
    4. Applied flip--0.2

      \[\leadsto \color{blue}{\frac{x \cdot x - 0.5 \cdot 0.5}{x + 0.5}} \cdot \log x + \left(0.91893853320467001 + \left(\frac{z \cdot \left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) + 0.0833333333333329956}{x} - x\right)\right)\]
    5. Applied associate-*l/0.2

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

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

    if 2246989294872715 < x

    1. Initial program 11.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. Simplified11.0

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

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

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

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

Reproduce

herbie shell --seed 2020179 
(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)))