\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}\;z \le -1.40766130450651064 \cdot 10^{85} \lor \neg \left(z \le 2.0917626344359026 \cdot 10^{45}\right):\\
\;\;\;\;\mathsf{fma}\left(\log x, x - 0.5, \mathsf{fma}\left(7.93650079365100015 \cdot 10^{-4}, \frac{{z}^{1}}{\frac{x}{z}}, 0.0833333333333329956 \cdot \frac{1}{x} - 0.0027777777777778 \cdot \frac{z}{x}\right) - \left(x - 0.91893853320467001\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \left(\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956\right) \cdot \frac{1}{x}\\
\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 (((z <= -1.4076613045065106e+85) || !(z <= 2.0917626344359026e+45))) {
VAR = fma(log(x), (x - 0.5), (fma(0.0007936500793651, (pow(z, 1.0) / (x / z)), ((0.083333333333333 * (1.0 / x)) - (0.0027777777777778 * (z / x)))) - (x - 0.91893853320467)));
} else {
VAR = (((((x - 0.5) * log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) * (1.0 / x)));
}
return VAR;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 6.0 |
|---|---|
| Target | 1.2 |
| Herbie | 2.8 |
if z < -1.4076613045065106e+85 or 2.0917626344359026e+45 < z Initial program 30.8
Simplified30.8
Taylor expanded around 0 31.0
Simplified31.0
rmApplied sqr-pow31.0
Applied associate-/l*11.9
Simplified11.9
if -1.4076613045065106e+85 < z < 2.0917626344359026e+45Initial program 0.8
rmApplied div-inv0.9
Final simplification2.8
herbie shell --seed 2020071 +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)))