\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\begin{array}{l}
t_0 := \mathsf{fma}\left(x - 0.5, \log x, 0.91893853320467\right) - x\\
\mathbf{if}\;x \leq 4.0281667929952995 \cdot 10^{+67}:\\
\;\;\;\;t_0 + \frac{\mathsf{fma}\left(z, \mathsf{fma}\left(y + 0.0007936500793651, z, -0.0027777777777778\right), 0.083333333333333\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;t_0 + z \cdot \left(\left(y + 0.0007936500793651\right) \cdot \frac{z}{x}\right)\\
\end{array}
(FPCore (x y z)
:precision binary64
(+
(+ (- (* (- x 0.5) (log x)) x) 0.91893853320467)
(/
(+
(* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z)
0.083333333333333)
x)))(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (fma (- x 0.5) (log x) 0.91893853320467) x)))
(if (<= x 4.0281667929952995e+67)
(+
t_0
(/
(fma
z
(fma (+ y 0.0007936500793651) z -0.0027777777777778)
0.083333333333333)
x))
(+ t_0 (* z (* (+ y 0.0007936500793651) (/ z x)))))))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 t_0 = fma((x - 0.5), log(x), 0.91893853320467) - x;
double tmp;
if (x <= 4.0281667929952995e+67) {
tmp = t_0 + (fma(z, fma((y + 0.0007936500793651), z, -0.0027777777777778), 0.083333333333333) / x);
} else {
tmp = t_0 + (z * ((y + 0.0007936500793651) * (z / x)));
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 4.0 |
|---|---|
| Target | 0.9 |
| Herbie | 0.4 |
if x < 4.0281667929952995e67Initial program 0.5
Simplified0.5
Applied *-un-lft-identity_binary640.5
Applied cancel-sign-sub-inv_binary640.5
if 4.0281667929952995e67 < x Initial program 9.8
Simplified9.8
Taylor expanded in z around 0 14.6
Simplified0.4
Taylor expanded in z around inf 6.6
Simplified0.3
Final simplification0.4
herbie shell --seed 2022088
(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)))