Average Error: 5.8 → 3.0
Time: 7.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}\;x \le 5.24214204453371374 \cdot 10^{122}:\\ \;\;\;\;\left(\left(\frac{\left(x \cdot x - 0.5 \cdot 0.5\right) \cdot \log x}{x + 0.5} - 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}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \frac{\frac{1}{x}}{\left(0.400000000000006406 \cdot z + 12.000000000000048\right) - 0.100952278095241613 \cdot {z}^{2}}\\ \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 5.24214204453371374 \cdot 10^{122}:\\
\;\;\;\;\left(\left(\frac{\left(x \cdot x - 0.5 \cdot 0.5\right) \cdot \log x}{x + 0.5} - 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}\\

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

\end{array}
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 VAR;
	if ((x <= 5.242142044533714e+122)) {
		VAR = (((((((x * x) - (0.5 * 0.5)) * log(x)) / (x + 0.5)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x));
	} else {
		VAR = (((((x - 0.5) * log(x)) - x) + 0.91893853320467) + ((1.0 / x) / (((0.4000000000000064 * z) + 12.000000000000048) - (0.10095227809524161 * pow(z, 2.0)))));
	}
	return VAR;
}

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.1
Herbie3.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 2 regimes
  2. if x < 5.242142044533714e+122

    1. Initial program 1.6

      \[\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 flip--1.6

      \[\leadsto \left(\left(\color{blue}{\frac{x \cdot x - 0.5 \cdot 0.5}{x + 0.5}} \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}\]
    4. Applied associate-*l/1.6

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

    if 5.242142044533714e+122 < x

    1. Initial program 12.8

      \[\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 clear-num12.8

      \[\leadsto \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\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}}}\]
    4. Using strategy rm
    5. Applied div-inv12.8

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le 5.24214204453371374 \cdot 10^{122}:\\ \;\;\;\;\left(\left(\frac{\left(x \cdot x - 0.5 \cdot 0.5\right) \cdot \log x}{x + 0.5} - 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}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \frac{\frac{1}{x}}{\left(0.400000000000006406 \cdot z + 12.000000000000048\right) - 0.100952278095241613 \cdot {z}^{2}}\\ \end{array}\]

Reproduce

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