(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 (- 0.91893853320467 (fma (log x) (- 0.5 x) x)))
(t_1 (* z (* z (/ (+ y 0.0007936500793651) x))))
(t_2 (* z (+ (* (+ y 0.0007936500793651) z) -0.0027777777777778)))
(t_3 (log (/ 1.0 x))))
(if (<= t_2 -3.802629011133731e+174)
(+ (- 0.91893853320467 (+ (+ x (* x t_3)) (* t_3 -0.5))) t_1)
(if (<= t_2 1.4441499038557408e+173)
(+
t_0
(pow
(*
x
(/
1.0
(fma
z
(fma z (+ y 0.0007936500793651) -0.0027777777777778)
0.083333333333333)))
-1.0))
(+ t_1 t_0)))))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 = 0.91893853320467 - fma(log(x), (0.5 - x), x);
double t_1 = z * (z * ((y + 0.0007936500793651) / x));
double t_2 = z * (((y + 0.0007936500793651) * z) + -0.0027777777777778);
double t_3 = log((1.0 / x));
double tmp;
if (t_2 <= -3.802629011133731e+174) {
tmp = (0.91893853320467 - ((x + (x * t_3)) + (t_3 * -0.5))) + t_1;
} else if (t_2 <= 1.4441499038557408e+173) {
tmp = t_0 + pow((x * (1.0 / fma(z, fma(z, (y + 0.0007936500793651), -0.0027777777777778), 0.083333333333333))), -1.0);
} else {
tmp = t_1 + t_0;
}
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(0.91893853320467 - fma(log(x), Float64(0.5 - x), x)) t_1 = Float64(z * Float64(z * Float64(Float64(y + 0.0007936500793651) / x))) t_2 = Float64(z * Float64(Float64(Float64(y + 0.0007936500793651) * z) + -0.0027777777777778)) t_3 = log(Float64(1.0 / x)) tmp = 0.0 if (t_2 <= -3.802629011133731e+174) tmp = Float64(Float64(0.91893853320467 - Float64(Float64(x + Float64(x * t_3)) + Float64(t_3 * -0.5))) + t_1); elseif (t_2 <= 1.4441499038557408e+173) tmp = Float64(t_0 + (Float64(x * Float64(1.0 / fma(z, fma(z, Float64(y + 0.0007936500793651), -0.0027777777777778), 0.083333333333333))) ^ -1.0)); else tmp = Float64(t_1 + t_0); 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[(0.91893853320467 - N[(N[Log[x], $MachinePrecision] * N[(0.5 - x), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(z * N[(z * N[(N[(y + 0.0007936500793651), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(z * N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] + -0.0027777777777778), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Log[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$2, -3.802629011133731e+174], N[(N[(0.91893853320467 - N[(N[(x + N[(x * t$95$3), $MachinePrecision]), $MachinePrecision] + N[(t$95$3 * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision], If[LessEqual[t$95$2, 1.4441499038557408e+173], N[(t$95$0 + N[Power[N[(x * N[(1.0 / N[(z * N[(z * N[(y + 0.0007936500793651), $MachinePrecision] + -0.0027777777777778), $MachinePrecision] + 0.083333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision], N[(t$95$1 + t$95$0), $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 := 0.91893853320467 - \mathsf{fma}\left(\log x, 0.5 - x, x\right)\\
t_1 := z \cdot \left(z \cdot \frac{y + 0.0007936500793651}{x}\right)\\
t_2 := z \cdot \left(\left(y + 0.0007936500793651\right) \cdot z + -0.0027777777777778\right)\\
t_3 := \log \left(\frac{1}{x}\right)\\
\mathbf{if}\;t_2 \leq -3.802629011133731 \cdot 10^{+174}:\\
\;\;\;\;\left(0.91893853320467 - \left(\left(x + x \cdot t_3\right) + t_3 \cdot -0.5\right)\right) + t_1\\
\mathbf{elif}\;t_2 \leq 1.4441499038557408 \cdot 10^{+173}:\\
\;\;\;\;t_0 + {\left(x \cdot \frac{1}{\mathsf{fma}\left(z, \mathsf{fma}\left(z, y + 0.0007936500793651, -0.0027777777777778\right), 0.083333333333333\right)}\right)}^{-1}\\
\mathbf{else}:\\
\;\;\;\;t_1 + t_0\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 6.6 |
|---|---|
| Target | 1.3 |
| Herbie | 0.4 |
if (*.f64 (-.f64 (*.f64 (+.f64 y 7936500793651/10000000000000000) z) 13888888888889/5000000000000000) z) < -3.8026290111337312e174Initial program 32.0
Simplified32.0
Taylor expanded in x around inf 32.0
Taylor expanded in z around inf 32.0
Simplified1.9
if -3.8026290111337312e174 < (*.f64 (-.f64 (*.f64 (+.f64 y 7936500793651/10000000000000000) z) 13888888888889/5000000000000000) z) < 1.4441499038557408e173Initial program 0.4
Simplified0.3
Applied egg-rr0.3
Applied egg-rr0.3
if 1.4441499038557408e173 < (*.f64 (-.f64 (*.f64 (+.f64 y 7936500793651/10000000000000000) z) 13888888888889/5000000000000000) z) Initial program 33.8
Simplified33.8
Taylor expanded in z around inf 34.3
Simplified0.6
Final simplification0.4
herbie shell --seed 2022150
(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)))