\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 41606032291.8435135:\\
\;\;\;\;\frac{\log x \cdot \left(x \cdot x - 0.5 \cdot 0.5\right)}{x + 0.5} + \left(\frac{\mathsf{fma}\left(y, {z}^{2}, 7.93650079365100015 \cdot 10^{-4} \cdot {z}^{2} - 0.0027777777777778 \cdot z\right) + 0.0833333333333329956}{x} - \left(x - 0.91893853320467001\right)\right)\\
\mathbf{elif}\;x \le 6.52148871011840621 \cdot 10^{132}:\\
\;\;\;\;\mathsf{fma}\left(\log x, x - 0.5, \mathsf{fma}\left(\frac{{z}^{2}}{x}, y + 7.93650079365100015 \cdot 10^{-4}, -0.0027777777777778 \cdot \frac{z}{x}\right) - \left(x - 0.91893853320467001\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log x, x - 0.5, \frac{1}{\mathsf{fma}\left(z \cdot 0.400000000000006406, x, x \cdot \left(12.000000000000048 - {z}^{2} \cdot 0.100952278095241613\right)\right)} - \left(x - 0.91893853320467001\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 <= 41606032291.84351)) {
VAR = (((log(x) * ((x * x) - (0.5 * 0.5))) / (x + 0.5)) + (((fma(y, pow(z, 2.0), ((0.0007936500793651 * pow(z, 2.0)) - (0.0027777777777778 * z))) + 0.083333333333333) / x) - (x - 0.91893853320467)));
} else {
double VAR_1;
if ((x <= 6.521488710118406e+132)) {
VAR_1 = fma(log(x), (x - 0.5), (fma((pow(z, 2.0) / x), (y + 0.0007936500793651), -(0.0027777777777778 * (z / x))) - (x - 0.91893853320467)));
} else {
VAR_1 = fma(log(x), (x - 0.5), ((1.0 / fma((z * 0.4000000000000064), x, (x * (12.000000000000048 - (pow(z, 2.0) * 0.10095227809524161))))) - (x - 0.91893853320467)));
}
VAR = VAR_1;
}
return VAR;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 5.8 |
|---|---|
| Target | 1.1 |
| Herbie | 2.4 |
if x < 41606032291.84351Initial program 0.1
Simplified0.1
rmApplied fma-udef0.1
Taylor expanded around 0 0.1
Simplified0.1
rmApplied flip--0.1
Applied associate-*r/0.1
if 41606032291.84351 < x < 6.521488710118406e+132Initial program 5.4
Simplified5.3
rmApplied clear-num5.3
Taylor expanded around inf 5.3
Simplified3.2
if 6.521488710118406e+132 < x Initial program 13.0
Simplified13.0
rmApplied clear-num13.0
Taylor expanded around 0 11.3
Simplified4.9
Final simplification2.4
herbie shell --seed 2020078 +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)))