\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 := z \cdot \left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right)\\
t_1 := \log \left(\sqrt{x}\right)\\
\mathbf{if}\;t_0 \leq -1.371162106624129 \cdot 10^{+301}:\\
\;\;\;\;\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \left(\frac{0.083333333333333}{x} - 0.0027777777777778 \cdot \frac{z}{x}\right)\\
\mathbf{elif}\;t_0 \leq 2.1114119818840957 \cdot 10^{+307}:\\
\;\;\;\;\mathsf{fma}\left(\log x, x - 0.5, 0.91893853320467 - x\right) + \frac{\frac{1}{x}}{\frac{1}{\mathsf{fma}\left(z, \mathsf{fma}\left(z, y + 0.0007936500793651, -0.0027777777777778\right), 0.083333333333333\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.083333333333333}{x} + \left(\left(x - 0.5\right) \cdot t_1 + \mathsf{fma}\left(x - 0.5, t_1, 0.91893853320467 - x\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
(let* ((t_0 (* z (- (* (+ y 0.0007936500793651) z) 0.0027777777777778)))
(t_1 (log (sqrt x))))
(if (<= t_0 -1.371162106624129e+301)
(+
(+ (- (* (- x 0.5) (log x)) x) 0.91893853320467)
(- (/ 0.083333333333333 x) (* 0.0027777777777778 (/ z x))))
(if (<= t_0 2.1114119818840957e+307)
(+
(fma (log x) (- x 0.5) (- 0.91893853320467 x))
(/
(/ 1.0 x)
(/
1.0
(fma
z
(fma z (+ y 0.0007936500793651) -0.0027777777777778)
0.083333333333333))))
(+
(/ 0.083333333333333 x)
(+ (* (- x 0.5) t_1) (fma (- x 0.5) t_1 (- 0.91893853320467 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 = z * (((y + 0.0007936500793651) * z) - 0.0027777777777778);
double t_1 = log(sqrt(x));
double tmp;
if (t_0 <= -1.371162106624129e+301) {
tmp = ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + ((0.083333333333333 / x) - (0.0027777777777778 * (z / x)));
} else if (t_0 <= 2.1114119818840957e+307) {
tmp = fma(log(x), (x - 0.5), (0.91893853320467 - x)) + ((1.0 / x) / (1.0 / fma(z, fma(z, (y + 0.0007936500793651), -0.0027777777777778), 0.083333333333333)));
} else {
tmp = (0.083333333333333 / x) + (((x - 0.5) * t_1) + fma((x - 0.5), t_1, (0.91893853320467 - x)));
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 6.2 |
|---|---|
| Target | 1.3 |
| Herbie | 3.2 |
if (*.f64 (-.f64 (*.f64 (+.f64 y 7936500793651/10000000000000000) z) 13888888888889/5000000000000000) z) < -1.37116210662412908e301Initial program 60.8
Taylor expanded in z around 0 31.6
Simplified31.6
if -1.37116210662412908e301 < (*.f64 (-.f64 (*.f64 (+.f64 y 7936500793651/10000000000000000) z) 13888888888889/5000000000000000) z) < 2.1114119818840957e307Initial program 0.4
Taylor expanded in x around 0 0.4
Simplified0.3
Applied clear-num_binary640.3
Simplified0.3
Applied div-inv_binary640.3
Applied associate-/r*_binary640.3
if 2.1114119818840957e307 < (*.f64 (-.f64 (*.f64 (+.f64 y 7936500793651/10000000000000000) z) 13888888888889/5000000000000000) z) Initial program 63.7
Applied add-sqr-sqrt_binary6463.7
Applied log-prod_binary6463.7
Applied distribute-rgt-in_binary6463.7
Applied associate--l+_binary6463.7
Applied associate-+l+_binary6463.7
Simplified63.7
Taylor expanded in z around 0 31.4
Final simplification3.2
herbie shell --seed 2022125
(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)))