Average Error: 6.0 → 1.3
Time: 7.0s
Precision: binary64
\[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x} \]
\[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \mathsf{fma}\left(0.0007936500793651, z \cdot \frac{z}{x}, \frac{\sqrt{0.083333333333333}}{\frac{x}{\sqrt{0.083333333333333}}} + \frac{z}{x} \cdot \mathsf{fma}\left(z, y, -0.0027777777777778\right)\right) \]
\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \mathsf{fma}\left(0.0007936500793651, z \cdot \frac{z}{x}, \frac{\sqrt{0.083333333333333}}{\frac{x}{\sqrt{0.083333333333333}}} + \frac{z}{x} \cdot \mathsf{fma}\left(z, y, -0.0027777777777778\right)\right)
(FPCore (x y z)
 :precision binary64
 (+
  (+ (- (* (- x 0.5) (log x)) x) 0.91893853320467)
  (/
   (+
    (* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z)
    0.083333333333333)
   x)))
(FPCore (x y z)
 :precision binary64
 (+
  (+ (- (* (- x 0.5) (log x)) x) 0.91893853320467)
  (fma
   0.0007936500793651
   (* z (/ z x))
   (+
    (/ (sqrt 0.083333333333333) (/ x (sqrt 0.083333333333333)))
    (* (/ z x) (fma z y -0.0027777777777778))))))
double code(double x, double y, double z) {
	return ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x);
}
double code(double x, double y, double z) {
	return ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + fma(0.0007936500793651, (z * (z / x)), ((sqrt(0.083333333333333) / (x / sqrt(0.083333333333333))) + ((z / x) * fma(z, y, -0.0027777777777778))));
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original6.0
Target1.2
Herbie1.3
\[\left(\left(\left(x - 0.5\right) \cdot \log x + \left(0.91893853320467 - x\right)\right) + \frac{0.083333333333333}{x}\right) + \frac{z}{x} \cdot \left(z \cdot \left(y + 0.0007936500793651\right) - 0.0027777777777778\right) \]

Derivation

  1. Initial program 6.0

    \[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x} \]
  2. Taylor expanded in y around 0 6.1

    \[\leadsto \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \color{blue}{\left(\left(0.0007936500793651 \cdot \frac{{z}^{2}}{x} + \left(\frac{y \cdot {z}^{2}}{x} + 0.083333333333333 \cdot \frac{1}{x}\right)\right) - 0.0027777777777778 \cdot \frac{z}{x}\right)} \]
  3. Simplified5.6

    \[\leadsto \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \color{blue}{\mathsf{fma}\left(0.0007936500793651, \frac{z \cdot z}{x}, \frac{0.083333333333333}{x} + \mathsf{fma}\left(z, \frac{z \cdot y}{x}, z \cdot \frac{-0.0027777777777778}{x}\right)\right)} \]
  4. Applied *-un-lft-identity_binary645.6

    \[\leadsto \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \mathsf{fma}\left(0.0007936500793651, \frac{z \cdot z}{\color{blue}{1 \cdot x}}, \frac{0.083333333333333}{x} + \mathsf{fma}\left(z, \frac{z \cdot y}{x}, z \cdot \frac{-0.0027777777777778}{x}\right)\right) \]
  5. Applied times-frac_binary642.1

    \[\leadsto \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \mathsf{fma}\left(0.0007936500793651, \color{blue}{\frac{z}{1} \cdot \frac{z}{x}}, \frac{0.083333333333333}{x} + \mathsf{fma}\left(z, \frac{z \cdot y}{x}, z \cdot \frac{-0.0027777777777778}{x}\right)\right) \]
  6. Simplified2.1

    \[\leadsto \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \mathsf{fma}\left(0.0007936500793651, \color{blue}{z} \cdot \frac{z}{x}, \frac{0.083333333333333}{x} + \mathsf{fma}\left(z, \frac{z \cdot y}{x}, z \cdot \frac{-0.0027777777777778}{x}\right)\right) \]
  7. Taylor expanded in z around 0 6.1

    \[\leadsto \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \mathsf{fma}\left(0.0007936500793651, z \cdot \frac{z}{x}, \frac{0.083333333333333}{x} + \color{blue}{\left(\frac{y \cdot {z}^{2}}{x} - 0.0027777777777778 \cdot \frac{z}{x}\right)}\right) \]
  8. Simplified1.3

    \[\leadsto \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \mathsf{fma}\left(0.0007936500793651, z \cdot \frac{z}{x}, \frac{0.083333333333333}{x} + \color{blue}{\frac{z}{x} \cdot \mathsf{fma}\left(z, y, -0.0027777777777778\right)}\right) \]
  9. Applied add-sqr-sqrt_binary641.5

    \[\leadsto \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \mathsf{fma}\left(0.0007936500793651, z \cdot \frac{z}{x}, \frac{\color{blue}{\sqrt{0.083333333333333} \cdot \sqrt{0.083333333333333}}}{x} + \frac{z}{x} \cdot \mathsf{fma}\left(z, y, -0.0027777777777778\right)\right) \]
  10. Applied associate-/l*_binary641.3

    \[\leadsto \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \mathsf{fma}\left(0.0007936500793651, z \cdot \frac{z}{x}, \color{blue}{\frac{\sqrt{0.083333333333333}}{\frac{x}{\sqrt{0.083333333333333}}}} + \frac{z}{x} \cdot \mathsf{fma}\left(z, y, -0.0027777777777778\right)\right) \]
  11. Final simplification1.3

    \[\leadsto \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \mathsf{fma}\left(0.0007936500793651, z \cdot \frac{z}{x}, \frac{\sqrt{0.083333333333333}}{\frac{x}{\sqrt{0.083333333333333}}} + \frac{z}{x} \cdot \mathsf{fma}\left(z, y, -0.0027777777777778\right)\right) \]

Reproduce

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