\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 7.8191391361236409 \cdot 10^{26}:\\
\;\;\;\;\mathsf{fma}\left(x - 0.5, \log \left(\sqrt{x}\right), \mathsf{fma}\left(\log \left(\sqrt{x}\right), x - 0.5, 0.91893853320467001 - x\right)\right) + \frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x}\\
\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 (((((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 <= 7.819139136123641e+26)) {
VAR = (fma((x - 0.5), log(sqrt(x)), fma(log(sqrt(x)), (x - 0.5), (0.91893853320467 - x))) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x));
} else {
VAR = fma((pow(z, 2.0) / x), y, ((0.0007936500793651 * (pow(z, 2.0) / x)) - fma(log((1.0 / x)), x, x)));
}
return VAR;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 6.0 |
|---|---|
| Target | 1.1 |
| Herbie | 4.4 |
if x < 7.819139136123641e+26Initial program 0.3
rmApplied add-sqr-sqrt0.3
Applied log-prod0.3
Applied distribute-lft-in0.3
Applied associate--l+0.3
Applied associate-+l+0.3
Simplified0.3
rmApplied fma-def0.2
if 7.819139136123641e+26 < x Initial program 10.8
Simplified10.7
Taylor expanded around inf 10.9
Simplified7.8
Final simplification4.4
herbie shell --seed 2020092 +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)))