\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;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 5.8 |
|---|---|
| Target | 1.1 |
| Herbie | 3.0 |
if x < 5.242142044533714e+122Initial program 1.6
rmApplied flip--1.6
Applied associate-*l/1.6
if 5.242142044533714e+122 < x Initial program 12.8
rmApplied clear-num12.8
rmApplied div-inv12.8
Applied associate-/r*12.8
Taylor expanded around 0 5.3
Final simplification3.0
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)))