(FPCore (x y z)
:precision binary64
(/
(*
(- x 2.0)
(+
(*
(+ (* (+ (* (+ (* x 4.16438922228) 78.6994924154) x) 137.519416416) x) y)
x)
z))
(+
(* (+ (* (+ (* (+ x 43.3400022514) x) 263.505074721) x) 313.399215894) x)
47.066876606)))(FPCore (x y z)
:precision binary64
(let* ((t_0
(+
(+ (/ 3655.1204654076414 x) (/ y (* x x)))
(+
(fma x 4.16438922228 -110.1139242984811)
(/ -130977.50649958357 (* x x)))))
(t_1
(+
(pow x 4.0)
(+
47.066876606
(+
(* 263.505074721 (pow x 2.0))
(+ (* 43.3400022514 (pow x 3.0)) (* x 313.399215894)))))))
(if (<= x -3.9e+71)
t_0
(if (<= x 3.6e+52)
(*
(+ x -2.0)
(+
(* 4.16438922228 (/ (pow x 4.0) t_1))
(+
(/ (* x y) t_1)
(+
(/ z t_1)
(+
(* 137.519416416 (/ (pow x 2.0) t_1))
(* 78.6994924154 (/ (pow x 3.0) t_1)))))))
t_0))))double code(double x, double y, double z) {
return ((x - 2.0) * ((((((((x * 4.16438922228) + 78.6994924154) * x) + 137.519416416) * x) + y) * x) + z)) / (((((((x + 43.3400022514) * x) + 263.505074721) * x) + 313.399215894) * x) + 47.066876606);
}
double code(double x, double y, double z) {
double t_0 = ((3655.1204654076414 / x) + (y / (x * x))) + (fma(x, 4.16438922228, -110.1139242984811) + (-130977.50649958357 / (x * x)));
double t_1 = pow(x, 4.0) + (47.066876606 + ((263.505074721 * pow(x, 2.0)) + ((43.3400022514 * pow(x, 3.0)) + (x * 313.399215894))));
double tmp;
if (x <= -3.9e+71) {
tmp = t_0;
} else if (x <= 3.6e+52) {
tmp = (x + -2.0) * ((4.16438922228 * (pow(x, 4.0) / t_1)) + (((x * y) / t_1) + ((z / t_1) + ((137.519416416 * (pow(x, 2.0) / t_1)) + (78.6994924154 * (pow(x, 3.0) / t_1))))));
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) return Float64(Float64(Float64(x - 2.0) * Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(x * 4.16438922228) + 78.6994924154) * x) + 137.519416416) * x) + y) * x) + z)) / Float64(Float64(Float64(Float64(Float64(Float64(Float64(x + 43.3400022514) * x) + 263.505074721) * x) + 313.399215894) * x) + 47.066876606)) end
function code(x, y, z) t_0 = Float64(Float64(Float64(3655.1204654076414 / x) + Float64(y / Float64(x * x))) + Float64(fma(x, 4.16438922228, -110.1139242984811) + Float64(-130977.50649958357 / Float64(x * x)))) t_1 = Float64((x ^ 4.0) + Float64(47.066876606 + Float64(Float64(263.505074721 * (x ^ 2.0)) + Float64(Float64(43.3400022514 * (x ^ 3.0)) + Float64(x * 313.399215894))))) tmp = 0.0 if (x <= -3.9e+71) tmp = t_0; elseif (x <= 3.6e+52) tmp = Float64(Float64(x + -2.0) * Float64(Float64(4.16438922228 * Float64((x ^ 4.0) / t_1)) + Float64(Float64(Float64(x * y) / t_1) + Float64(Float64(z / t_1) + Float64(Float64(137.519416416 * Float64((x ^ 2.0) / t_1)) + Float64(78.6994924154 * Float64((x ^ 3.0) / t_1))))))); else tmp = t_0; end return tmp end
code[x_, y_, z_] := N[(N[(N[(x - 2.0), $MachinePrecision] * N[(N[(N[(N[(N[(N[(N[(N[(x * 4.16438922228), $MachinePrecision] + 78.6994924154), $MachinePrecision] * x), $MachinePrecision] + 137.519416416), $MachinePrecision] * x), $MachinePrecision] + y), $MachinePrecision] * x), $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(N[(N[(N[(N[(x + 43.3400022514), $MachinePrecision] * x), $MachinePrecision] + 263.505074721), $MachinePrecision] * x), $MachinePrecision] + 313.399215894), $MachinePrecision] * x), $MachinePrecision] + 47.066876606), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(3655.1204654076414 / x), $MachinePrecision] + N[(y / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(x * 4.16438922228 + -110.1139242984811), $MachinePrecision] + N[(-130977.50649958357 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[x, 4.0], $MachinePrecision] + N[(47.066876606 + N[(N[(263.505074721 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision] + N[(N[(43.3400022514 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] + N[(x * 313.399215894), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -3.9e+71], t$95$0, If[LessEqual[x, 3.6e+52], N[(N[(x + -2.0), $MachinePrecision] * N[(N[(4.16438922228 * N[(N[Power[x, 4.0], $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(x * y), $MachinePrecision] / t$95$1), $MachinePrecision] + N[(N[(z / t$95$1), $MachinePrecision] + N[(N[(137.519416416 * N[(N[Power[x, 2.0], $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision] + N[(78.6994924154 * N[(N[Power[x, 3.0], $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\frac{\left(x - 2\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922228 + 78.6994924154\right) \cdot x + 137.519416416\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514\right) \cdot x + 263.505074721\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606}
\begin{array}{l}
t_0 := \left(\frac{3655.1204654076414}{x} + \frac{y}{x \cdot x}\right) + \left(\mathsf{fma}\left(x, 4.16438922228, -110.1139242984811\right) + \frac{-130977.50649958357}{x \cdot x}\right)\\
t_1 := {x}^{4} + \left(47.066876606 + \left(263.505074721 \cdot {x}^{2} + \left(43.3400022514 \cdot {x}^{3} + x \cdot 313.399215894\right)\right)\right)\\
\mathbf{if}\;x \leq -3.9 \cdot 10^{+71}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 3.6 \cdot 10^{+52}:\\
\;\;\;\;\left(x + -2\right) \cdot \left(4.16438922228 \cdot \frac{{x}^{4}}{t_1} + \left(\frac{x \cdot y}{t_1} + \left(\frac{z}{t_1} + \left(137.519416416 \cdot \frac{{x}^{2}}{t_1} + 78.6994924154 \cdot \frac{{x}^{3}}{t_1}\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 26.5 |
|---|---|
| Target | 0.7 |
| Herbie | 0.7 |
if x < -3.9000000000000001e71 or 3.6e52 < x Initial program 63.2
Simplified60.8
Taylor expanded in x around inf 0.8
Simplified0.8
if -3.9000000000000001e71 < x < 3.6e52Initial program 2.4
Simplified0.7
Taylor expanded in y around 0 0.7
Final simplification0.7
herbie shell --seed 2022162
(FPCore (x y z)
:name "Numeric.SpecFunctions:logGamma from math-functions-0.1.5.2, C"
:precision binary64
:herbie-target
(if (< x -3.326128725870005e+62) (- (+ (/ y (* x x)) (* 4.16438922228 x)) 110.1139242984811) (if (< x 9.429991714554673e+55) (* (/ (- x 2.0) 1.0) (/ (+ (* (+ (* (+ (* (+ (* x 4.16438922228) 78.6994924154) x) 137.519416416) x) y) x) z) (+ (* (+ (+ (* 263.505074721 x) (+ (* 43.3400022514 (* x x)) (* x (* x x)))) 313.399215894) x) 47.066876606))) (- (+ (/ y (* x x)) (* 4.16438922228 x)) 110.1139242984811)))
(/ (* (- x 2.0) (+ (* (+ (* (+ (* (+ (* x 4.16438922228) 78.6994924154) x) 137.519416416) x) y) x) z)) (+ (* (+ (* (+ (* (+ x 43.3400022514) x) 263.505074721) x) 313.399215894) x) 47.066876606)))