\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 := \left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\\
t_1 := t_0 + \frac{0.083333333333333 - z \cdot 0.0027777777777778}{x}\\
t_2 := \frac{z \cdot z}{x}\\
\mathbf{if}\;z \leq -1.3543156149683942 \cdot 10^{+154}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -0.00019444066752115447:\\
\;\;\;\;\left(0.91893853320467 + \mathsf{fma}\left(x - 0.5, \log x, -x\right)\right) + \mathsf{fma}\left(0.0007936500793651, t_2, \mathsf{fma}\left(\frac{y}{x}, z \cdot z, \frac{z}{x} \cdot -0.0027777777777778\right)\right)\\
\mathbf{elif}\;z \leq 48939846456029.02:\\
\;\;\;\;\left(0.91893853320467 + \mathsf{fma}\left(\log x, x - 0.5, -x\right)\right) + \frac{\frac{1}{x}}{\frac{1}{\mathsf{fma}\left(z, \mathsf{fma}\left(z, 0.0007936500793651 + y, -0.0027777777777778\right), 0.083333333333333\right)}}\\
\mathbf{elif}\;z \leq 2.1822361911060752 \cdot 10^{+120}:\\
\;\;\;\;t_0 + t_2 \cdot \left(0.0007936500793651 + y\right)\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\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 (+ (- (* (- x 0.5) (log x)) x) 0.91893853320467))
(t_1 (+ t_0 (/ (- 0.083333333333333 (* z 0.0027777777777778)) x)))
(t_2 (/ (* z z) x)))
(if (<= z -1.3543156149683942e+154)
t_1
(if (<= z -0.00019444066752115447)
(+
(+ 0.91893853320467 (fma (- x 0.5) (log x) (- x)))
(fma
0.0007936500793651
t_2
(fma (/ y x) (* z z) (* (/ z x) -0.0027777777777778))))
(if (<= z 48939846456029.02)
(+
(+ 0.91893853320467 (fma (log x) (- x 0.5) (- x)))
(/
(/ 1.0 x)
(/
1.0
(fma
z
(fma z (+ 0.0007936500793651 y) -0.0027777777777778)
0.083333333333333))))
(if (<= z 2.1822361911060752e+120)
(+ t_0 (* t_2 (+ 0.0007936500793651 y)))
t_1))))))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 = (((x - 0.5) * log(x)) - x) + 0.91893853320467;
double t_1 = t_0 + ((0.083333333333333 - (z * 0.0027777777777778)) / x);
double t_2 = (z * z) / x;
double tmp;
if (z <= -1.3543156149683942e+154) {
tmp = t_1;
} else if (z <= -0.00019444066752115447) {
tmp = (0.91893853320467 + fma((x - 0.5), log(x), -x)) + fma(0.0007936500793651, t_2, fma((y / x), (z * z), ((z / x) * -0.0027777777777778)));
} else if (z <= 48939846456029.02) {
tmp = (0.91893853320467 + fma(log(x), (x - 0.5), -x)) + ((1.0 / x) / (1.0 / fma(z, fma(z, (0.0007936500793651 + y), -0.0027777777777778), 0.083333333333333)));
} else if (z <= 2.1822361911060752e+120) {
tmp = t_0 + (t_2 * (0.0007936500793651 + y));
} else {
tmp = t_1;
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 6.1 |
|---|---|
| Target | 1.1 |
| Herbie | 2.7 |
if z < -1.3543156149683942e154 or 2.18223619110607522e120 < z Initial program 54.3
Taylor expanded in z around 0 28.0
Simplified28.0
if -1.3543156149683942e154 < z < -1.94440667521154469e-4Initial program 8.5
Applied egg-rr8.5
Applied egg-rr8.5
Taylor expanded in z around inf 9.9
Simplified1.7
if -1.94440667521154469e-4 < z < 48939846456029.0234Initial program 0.4
Applied egg-rr0.3
Applied egg-rr0.3
Applied egg-rr0.3
Taylor expanded in x around 0 0.3
Simplified0.3
if 48939846456029.0234 < z < 2.18223619110607522e120Initial program 6.2
Taylor expanded in z around inf 6.3
Simplified0.5
Final simplification2.7
herbie shell --seed 2022130
(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)))