(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 (<= z -6e+15)
(-
(- 0.91893853320467 (fma (log x) (- 0.5 x) x))
(/ z (/ x (+ 0.0027777777777778 (* z (- -0.0007936500793651 y))))))
(if (<= z 3.05e+66)
(+
(- 0.91893853320467 (fma (- 0.5 x) (log x) x))
(/
(fma
z
(fma (+ y 0.0007936500793651) z -0.0027777777777778)
0.083333333333333)
x))
(+
(- 0.91893853320467 (+ x (* (log x) (- 0.5 x))))
(* z (* z (/ (+ y 0.0007936500793651) 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 (z <= -6e+15) {
tmp = (0.91893853320467 - fma(log(x), (0.5 - x), x)) - (z / (x / (0.0027777777777778 + (z * (-0.0007936500793651 - y)))));
} else if (z <= 3.05e+66) {
tmp = (0.91893853320467 - fma((0.5 - x), log(x), x)) + (fma(z, fma((y + 0.0007936500793651), z, -0.0027777777777778), 0.083333333333333) / x);
} else {
tmp = (0.91893853320467 - (x + (log(x) * (0.5 - x)))) + (z * (z * ((y + 0.0007936500793651) / 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) tmp = 0.0 if (z <= -6e+15) tmp = Float64(Float64(0.91893853320467 - fma(log(x), Float64(0.5 - x), x)) - Float64(z / Float64(x / Float64(0.0027777777777778 + Float64(z * Float64(-0.0007936500793651 - y)))))); elseif (z <= 3.05e+66) tmp = Float64(Float64(0.91893853320467 - fma(Float64(0.5 - x), log(x), x)) + Float64(fma(z, fma(Float64(y + 0.0007936500793651), z, -0.0027777777777778), 0.083333333333333) / x)); else tmp = Float64(Float64(0.91893853320467 - Float64(x + Float64(log(x) * Float64(0.5 - x)))) + Float64(z * Float64(z * Float64(Float64(y + 0.0007936500793651) / 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_] := If[LessEqual[z, -6e+15], N[(N[(0.91893853320467 - N[(N[Log[x], $MachinePrecision] * N[(0.5 - x), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision] - N[(z / N[(x / N[(0.0027777777777778 + N[(z * N[(-0.0007936500793651 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 3.05e+66], N[(N[(0.91893853320467 - N[(N[(0.5 - x), $MachinePrecision] * N[Log[x], $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision] + N[(N[(z * N[(N[(y + 0.0007936500793651), $MachinePrecision] * z + -0.0027777777777778), $MachinePrecision] + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(N[(0.91893853320467 - N[(x + N[(N[Log[x], $MachinePrecision] * N[(0.5 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(z * N[(z * N[(N[(y + 0.0007936500793651), $MachinePrecision] / x), $MachinePrecision]), $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}
\mathbf{if}\;z \leq -6 \cdot 10^{+15}:\\
\;\;\;\;\left(0.91893853320467 - \mathsf{fma}\left(\log x, 0.5 - x, x\right)\right) - \frac{z}{\frac{x}{0.0027777777777778 + z \cdot \left(-0.0007936500793651 - y\right)}}\\
\mathbf{elif}\;z \leq 3.05 \cdot 10^{+66}:\\
\;\;\;\;\left(0.91893853320467 - \mathsf{fma}\left(0.5 - x, \log x, x\right)\right) + \frac{\mathsf{fma}\left(z, \mathsf{fma}\left(y + 0.0007936500793651, z, -0.0027777777777778\right), 0.083333333333333\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;\left(0.91893853320467 - \left(x + \log x \cdot \left(0.5 - x\right)\right)\right) + z \cdot \left(z \cdot \frac{y + 0.0007936500793651}{x}\right)\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 5.9 |
|---|---|
| Target | 1.2 |
| Herbie | 0.9 |
if z < -6e15Initial program 21.9
Simplified21.9
Taylor expanded in z around inf 22.6
Simplified3.3
if -6e15 < z < 3.0500000000000001e66Initial program 0.6
Simplified0.6
Taylor expanded in x around 0 0.6
Simplified0.6
Applied egg-rr0.6
if 3.0500000000000001e66 < z Initial program 31.1
Simplified31.1
Taylor expanded in x around 0 31.1
Simplified31.1
Taylor expanded in z around inf 31.2
Simplified0.4
Final simplification0.9
herbie shell --seed 2022166
(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)))