Average Error: 5.8 → 4.8
Time: 11.6s
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}\]
\[\begin{array}{l} \mathbf{if}\;z \cdot \left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \leq 3.704179924344528 \cdot 10^{+304}:\\ \;\;\;\;\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{z \cdot \left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) + 0.083333333333333}{x}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{1}{x \cdot \left(12.000000000000048 + z \cdot 0.40000000000000646\right) - 0.10095227809524163 \cdot \left(x \cdot \left(z \cdot z\right)\right)}\\ \end{array}\]
\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}
\begin{array}{l}
\mathbf{if}\;z \cdot \left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \leq 3.704179924344528 \cdot 10^{+304}:\\
\;\;\;\;\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{z \cdot \left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) + 0.083333333333333}{x}\\

\mathbf{else}:\\
\;\;\;\;\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{1}{x \cdot \left(12.000000000000048 + z \cdot 0.40000000000000646\right) - 0.10095227809524163 \cdot \left(x \cdot \left(z \cdot z\right)\right)}\\

\end{array}
(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
 (if (<=
      (* z (- (* (+ y 0.0007936500793651) z) 0.0027777777777778))
      3.704179924344528e+304)
   (+
    (+ (- (* (- x 0.5) (log x)) x) 0.91893853320467)
    (/
     (+
      (* z (- (* (+ y 0.0007936500793651) z) 0.0027777777777778))
      0.083333333333333)
     x))
   (+
    (+ (- (* (- x 0.5) (log x)) x) 0.91893853320467)
    (/
     1.0
     (-
      (* x (+ 12.000000000000048 (* z 0.40000000000000646)))
      (* 0.10095227809524163 (* x (* z z))))))))
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) {
	double tmp;
	if ((z * (((y + 0.0007936500793651) * z) - 0.0027777777777778)) <= 3.704179924344528e+304) {
		tmp = ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + (((z * (((y + 0.0007936500793651) * z) - 0.0027777777777778)) + 0.083333333333333) / x);
	} else {
		tmp = ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + (1.0 / ((x * (12.000000000000048 + (z * 0.40000000000000646))) - (0.10095227809524163 * (x * (z * z)))));
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original5.8
Target1.2
Herbie4.8
\[\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. Split input into 2 regimes
  2. if (*.f64 (-.f64 (*.f64 (+.f64 y 7320129949063637/9223372036854775808) z) 3202559735019045/1152921504606846976) z) < 3.70417992434452793e304

    1. Initial program 1.7

      \[\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}\]

    if 3.70417992434452793e304 < (*.f64 (-.f64 (*.f64 (+.f64 y 7320129949063637/9223372036854775808) z) 3202559735019045/1152921504606846976) z)

    1. Initial program 62.7

      \[\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. Using strategy rm
    3. Applied clear-num_binary64_1337662.7

      \[\leadsto \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \color{blue}{\frac{1}{\frac{x}{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}}}\]
    4. Simplified62.7

      \[\leadsto \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{1}{\color{blue}{\frac{x}{z \cdot \left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) + 0.083333333333333}}}\]
    5. Taylor expanded around 0 47.7

      \[\leadsto \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{1}{\color{blue}{\left(12.000000000000048 \cdot x + 0.40000000000000646 \cdot \left(x \cdot z\right)\right) - 0.10095227809524163 \cdot \left(x \cdot {z}^{2}\right)}}\]
    6. Simplified47.7

      \[\leadsto \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{1}{\color{blue}{x \cdot \left(12.000000000000048 + 0.40000000000000646 \cdot z\right) - 0.10095227809524163 \cdot \left(x \cdot \left(z \cdot z\right)\right)}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification4.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot \left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \leq 3.704179924344528 \cdot 10^{+304}:\\ \;\;\;\;\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{z \cdot \left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) + 0.083333333333333}{x}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{1}{x \cdot \left(12.000000000000048 + z \cdot 0.40000000000000646\right) - 0.10095227809524163 \cdot \left(x \cdot \left(z \cdot z\right)\right)}\\ \end{array}\]

Reproduce

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