(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) (- x)) 0.91893853320467))
(t_1 (* z (- (* (+ y 0.0007936500793651) z) 0.0027777777777778))))
(if (<= t_1 (- INFINITY))
(+ t_0 (/ 0.083333333333333 x))
(if (<= t_1 1.594554769117199e+280)
(+
t_0
(pow
(/
x
(fma
z
(fma (+ y 0.0007936500793651) z -0.0027777777777778)
0.083333333333333))
-1.0))
(+
(/ 0.083333333333333 x)
(+ 0.91893853320467 (- (* (- x 0.5) (log x)) 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), -x) + 0.91893853320467;
double t_1 = z * (((y + 0.0007936500793651) * z) - 0.0027777777777778);
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = t_0 + (0.083333333333333 / x);
} else if (t_1 <= 1.594554769117199e+280) {
tmp = t_0 + pow((x / fma(z, fma((y + 0.0007936500793651), z, -0.0027777777777778), 0.083333333333333)), -1.0);
} else {
tmp = (0.083333333333333 / x) + (0.91893853320467 + (((x - 0.5) * log(x)) - x));
}
return tmp;
}
function code(x, y, z) return Float64(Float64(Float64(Float64(Float64(x - 0.5) * log(x)) - x) + 0.91893853320467) + Float64(Float64(Float64(Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x)) end
function code(x, y, z) t_0 = Float64(fma(Float64(x - 0.5), log(x), Float64(-x)) + 0.91893853320467) t_1 = Float64(z * Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778)) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(t_0 + Float64(0.083333333333333 / x)); elseif (t_1 <= 1.594554769117199e+280) tmp = Float64(t_0 + (Float64(x / fma(z, fma(Float64(y + 0.0007936500793651), z, -0.0027777777777778), 0.083333333333333)) ^ -1.0)); else tmp = Float64(Float64(0.083333333333333 / x) + Float64(0.91893853320467 + Float64(Float64(Float64(x - 0.5) * log(x)) - x))); end return tmp end
code[x_, y_, z_] := N[(N[(N[(N[(N[(x - 0.5), $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] + 0.91893853320467), $MachinePrecision] + N[(N[(N[(N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z), $MachinePrecision] + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(x - 0.5), $MachinePrecision] * N[Log[x], $MachinePrecision] + (-x)), $MachinePrecision] + 0.91893853320467), $MachinePrecision]}, Block[{t$95$1 = N[(z * N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(t$95$0 + N[(0.083333333333333 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1.594554769117199e+280], N[(t$95$0 + N[Power[N[(x / N[(z * N[(N[(y + 0.0007936500793651), $MachinePrecision] * z + -0.0027777777777778), $MachinePrecision] + 0.083333333333333), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision], N[(N[(0.083333333333333 / x), $MachinePrecision] + N[(0.91893853320467 + N[(N[(N[(x - 0.5), $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\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, -x\right) + 0.91893853320467\\
t_1 := z \cdot \left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right)\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;t_0 + \frac{0.083333333333333}{x}\\
\mathbf{elif}\;t_1 \leq 1.594554769117199 \cdot 10^{+280}:\\
\;\;\;\;t_0 + {\left(\frac{x}{\mathsf{fma}\left(z, \mathsf{fma}\left(y + 0.0007936500793651, z, -0.0027777777777778\right), 0.083333333333333\right)}\right)}^{-1}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.083333333333333}{x} + \left(0.91893853320467 + \left(\left(x - 0.5\right) \cdot \log x - x\right)\right)\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 5.8 |
|---|---|
| Target | 1.4 |
| Herbie | 3.3 |
if (*.f64 (-.f64 (*.f64 (+.f64 y 7936500793651/10000000000000000) z) 13888888888889/5000000000000000) z) < -inf.0Initial program 64.0
Applied egg-rr64.0
Taylor expanded in z around 0 37.0
if -inf.0 < (*.f64 (-.f64 (*.f64 (+.f64 y 7936500793651/10000000000000000) z) 13888888888889/5000000000000000) z) < 1.59455476911719891e280Initial program 0.3
Applied egg-rr0.3
Applied egg-rr0.3
if 1.59455476911719891e280 < (*.f64 (-.f64 (*.f64 (+.f64 y 7936500793651/10000000000000000) z) 13888888888889/5000000000000000) z) Initial program 54.7
Taylor expanded in z around 0 28.7
Final simplification3.3
herbie shell --seed 2022133
(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)))