\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 4.2446005459555582 \cdot 10^{78}:\\
\;\;\;\;\mathsf{fma}\left(\log x, x - 0.5, \frac{\left(\mathsf{fma}\left(z, y, 7.93650079365100015 \cdot 10^{-4} \cdot z\right) - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x} - \left(x - 0.91893853320467001\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{{z}^{2}}{x}, y, 7.93650079365100015 \cdot 10^{-4} \cdot \frac{{z}^{2}}{x} - \mathsf{fma}\left(\log \left(\frac{1}{x}\right), x, x\right)\right)\\
\end{array}double code(double x, double y, double z) {
return ((double) (((double) (((double) (((double) (((double) (x - 0.5)) * ((double) log(x)))) - x)) + 0.91893853320467)) + ((double) (((double) (((double) (((double) (((double) (((double) (y + 0.0007936500793651)) * z)) - 0.0027777777777778)) * z)) + 0.083333333333333)) / x))));
}
double code(double x, double y, double z) {
double VAR;
if ((x <= 4.244600545955558e+78)) {
VAR = ((double) fma(((double) log(x)), ((double) (x - 0.5)), ((double) (((double) (((double) (((double) (((double) (((double) fma(z, y, ((double) (0.0007936500793651 * z)))) - 0.0027777777777778)) * z)) + 0.083333333333333)) / x)) - ((double) (x - 0.91893853320467))))));
} else {
VAR = ((double) fma(((double) (((double) pow(z, 2.0)) / x)), y, ((double) (((double) (0.0007936500793651 * ((double) (((double) pow(z, 2.0)) / x)))) - ((double) fma(((double) log(((double) (1.0 / x)))), x, x))))));
}
return VAR;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 5.9 |
|---|---|
| Target | 1.2 |
| Herbie | 4.1 |
if x < 4.244600545955558e+78Initial program 0.8
Simplified0.8
Taylor expanded around 0 0.8
Simplified0.8
if 4.244600545955558e+78 < x Initial program 11.8
Simplified11.8
Taylor expanded around inf 11.9
Simplified8.1
Final simplification4.1
herbie shell --seed 2020121 +o rules:numerics
(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)))