\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}
\mathbf{if}\;x \leq 7.87607369627486 \cdot 10^{-23}:\\
\;\;\;\;\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \left(\left(0.0007936500793651 \cdot \frac{{z}^{2}}{x} + \left(\frac{{z}^{2} \cdot y}{x} + 0.083333333333333 \cdot \frac{1}{x}\right)\right) - 0.0027777777777778 \cdot \frac{z}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log x, x - 0.5, 0.91893853320467 - x\right) + \mathsf{fma}\left(\frac{z}{x}, -0.0027777777777778, \mathsf{fma}\left(0.0007936500793651, \frac{z \cdot z}{x}, \mathsf{fma}\left(\frac{y}{x}, z \cdot z, \frac{0.083333333333333}{x}\right)\right)\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
(if (<= x 7.87607369627486e-23)
(+
(+ (- (* (- x 0.5) (log x)) x) 0.91893853320467)
(-
(+
(* 0.0007936500793651 (/ (pow z 2.0) x))
(+ (/ (* (pow z 2.0) y) x) (* 0.083333333333333 (/ 1.0 x))))
(* 0.0027777777777778 (/ z x))))
(+
(fma (log x) (- x 0.5) (- 0.91893853320467 x))
(fma
(/ z x)
-0.0027777777777778
(fma
0.0007936500793651
(/ (* z z) x)
(fma (/ y x) (* z z) (/ 0.083333333333333 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 tmp;
if (x <= 7.87607369627486e-23) {
tmp = ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + (((0.0007936500793651 * (pow(z, 2.0) / x)) + (((pow(z, 2.0) * y) / x) + (0.083333333333333 * (1.0 / x)))) - (0.0027777777777778 * (z / x)));
} else {
tmp = fma(log(x), (x - 0.5), (0.91893853320467 - x)) + fma((z / x), -0.0027777777777778, fma(0.0007936500793651, ((z * z) / x), fma((y / x), (z * z), (0.083333333333333 / x))));
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 6.3 |
|---|---|
| Target | 1.3 |
| Herbie | 4.5 |
if x < 7.87607369627486013e-23Initial program 0.4
Taylor expanded in y around 0 0.5
if 7.87607369627486013e-23 < x Initial program 10.0
Taylor expanded in x around 0 10.0
Simplified10.0
Applied add-cube-cbrt_binary6410.0
Applied associate-*l*_binary6410.0
Taylor expanded in y around 0 10.1
Simplified7.1
Final simplification4.5
herbie shell --seed 2022063
(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)))