(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
(+
(pow x 4.0)
(+
47.066876606
(fma
(* x x)
263.505074721
(fma (pow x 3.0) 43.3400022514 (* x 313.399215894))))))
(t_1 (/ z t_0))
(t_2 (/ t_0 x))
(t_3 (/ y t_2)))
(if (<= x -7.441593577102361e+43)
(+
(fma x 4.16438922228 (/ 3655.1204654076414 x))
(+ (/ y (* x x)) (+ -110.1139242984811 (/ -130977.50649958357 (* x x)))))
(if (<= x 1.0463787894136359e+46)
(fma
(/ (pow x 4.0) t_0)
70.37071397084
(+
(fma 4.16438922228 (/ (pow x 5.0) t_0) (* x t_3))
(fma
t_1
x
(-
(* -2.0 (+ t_3 t_1))
(fma
(/ x t_2)
275.038832832
(* (pow x 3.0) (/ 19.8795684148 t_0)))))))
(*
(+ x -2.0)
(+
(+ (/ (/ 3451.550173699799 x) x) (/ y (pow x 3.0)))
(+
4.16438922228
(+
(/ -101.7851458539211 x)
(/ -124074.40615218398 (pow x 3.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 = pow(x, 4.0) + (47.066876606 + fma((x * x), 263.505074721, fma(pow(x, 3.0), 43.3400022514, (x * 313.399215894))));
double t_1 = z / t_0;
double t_2 = t_0 / x;
double t_3 = y / t_2;
double tmp;
if (x <= -7.441593577102361e+43) {
tmp = fma(x, 4.16438922228, (3655.1204654076414 / x)) + ((y / (x * x)) + (-110.1139242984811 + (-130977.50649958357 / (x * x))));
} else if (x <= 1.0463787894136359e+46) {
tmp = fma((pow(x, 4.0) / t_0), 70.37071397084, (fma(4.16438922228, (pow(x, 5.0) / t_0), (x * t_3)) + fma(t_1, x, ((-2.0 * (t_3 + t_1)) - fma((x / t_2), 275.038832832, (pow(x, 3.0) * (19.8795684148 / t_0)))))));
} else {
tmp = (x + -2.0) * ((((3451.550173699799 / x) / x) + (y / pow(x, 3.0))) + (4.16438922228 + ((-101.7851458539211 / x) + (-124074.40615218398 / pow(x, 3.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((x ^ 4.0) + Float64(47.066876606 + fma(Float64(x * x), 263.505074721, fma((x ^ 3.0), 43.3400022514, Float64(x * 313.399215894))))) t_1 = Float64(z / t_0) t_2 = Float64(t_0 / x) t_3 = Float64(y / t_2) tmp = 0.0 if (x <= -7.441593577102361e+43) tmp = Float64(fma(x, 4.16438922228, Float64(3655.1204654076414 / x)) + Float64(Float64(y / Float64(x * x)) + Float64(-110.1139242984811 + Float64(-130977.50649958357 / Float64(x * x))))); elseif (x <= 1.0463787894136359e+46) tmp = fma(Float64((x ^ 4.0) / t_0), 70.37071397084, Float64(fma(4.16438922228, Float64((x ^ 5.0) / t_0), Float64(x * t_3)) + fma(t_1, x, Float64(Float64(-2.0 * Float64(t_3 + t_1)) - fma(Float64(x / t_2), 275.038832832, Float64((x ^ 3.0) * Float64(19.8795684148 / t_0))))))); else tmp = Float64(Float64(x + -2.0) * Float64(Float64(Float64(Float64(3451.550173699799 / x) / x) + Float64(y / (x ^ 3.0))) + Float64(4.16438922228 + Float64(Float64(-101.7851458539211 / x) + Float64(-124074.40615218398 / (x ^ 3.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[Power[x, 4.0], $MachinePrecision] + N[(47.066876606 + N[(N[(x * x), $MachinePrecision] * 263.505074721 + N[(N[Power[x, 3.0], $MachinePrecision] * 43.3400022514 + N[(x * 313.399215894), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(z / t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 / x), $MachinePrecision]}, Block[{t$95$3 = N[(y / t$95$2), $MachinePrecision]}, If[LessEqual[x, -7.441593577102361e+43], N[(N[(x * 4.16438922228 + N[(3655.1204654076414 / x), $MachinePrecision]), $MachinePrecision] + N[(N[(y / N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(-110.1139242984811 + N[(-130977.50649958357 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0463787894136359e+46], N[(N[(N[Power[x, 4.0], $MachinePrecision] / t$95$0), $MachinePrecision] * 70.37071397084 + N[(N[(4.16438922228 * N[(N[Power[x, 5.0], $MachinePrecision] / t$95$0), $MachinePrecision] + N[(x * t$95$3), $MachinePrecision]), $MachinePrecision] + N[(t$95$1 * x + N[(N[(-2.0 * N[(t$95$3 + t$95$1), $MachinePrecision]), $MachinePrecision] - N[(N[(x / t$95$2), $MachinePrecision] * 275.038832832 + N[(N[Power[x, 3.0], $MachinePrecision] * N[(19.8795684148 / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x + -2.0), $MachinePrecision] * N[(N[(N[(N[(3451.550173699799 / x), $MachinePrecision] / x), $MachinePrecision] + N[(y / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(4.16438922228 + N[(N[(-101.7851458539211 / x), $MachinePrecision] + N[(-124074.40615218398 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\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 := {x}^{4} + \left(47.066876606 + \mathsf{fma}\left(x \cdot x, 263.505074721, \mathsf{fma}\left({x}^{3}, 43.3400022514, x \cdot 313.399215894\right)\right)\right)\\
t_1 := \frac{z}{t_0}\\
t_2 := \frac{t_0}{x}\\
t_3 := \frac{y}{t_2}\\
\mathbf{if}\;x \leq -7.441593577102361 \cdot 10^{+43}:\\
\;\;\;\;\mathsf{fma}\left(x, 4.16438922228, \frac{3655.1204654076414}{x}\right) + \left(\frac{y}{x \cdot x} + \left(-110.1139242984811 + \frac{-130977.50649958357}{x \cdot x}\right)\right)\\
\mathbf{elif}\;x \leq 1.0463787894136359 \cdot 10^{+46}:\\
\;\;\;\;\mathsf{fma}\left(\frac{{x}^{4}}{t_0}, 70.37071397084, \mathsf{fma}\left(4.16438922228, \frac{{x}^{5}}{t_0}, x \cdot t_3\right) + \mathsf{fma}\left(t_1, x, -2 \cdot \left(t_3 + t_1\right) - \mathsf{fma}\left(\frac{x}{t_2}, 275.038832832, {x}^{3} \cdot \frac{19.8795684148}{t_0}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x + -2\right) \cdot \left(\left(\frac{\frac{3451.550173699799}{x}}{x} + \frac{y}{{x}^{3}}\right) + \left(4.16438922228 + \left(\frac{-101.7851458539211}{x} + \frac{-124074.40615218398}{{x}^{3}}\right)\right)\right)\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 26.5 |
|---|---|
| Target | 0.8 |
| Herbie | 0.9 |
if x < -7.4415935771023612e43Initial program 60.1
Simplified56.5
Applied egg-rr56.5
Taylor expanded in x around inf 1.8
Simplified1.8
if -7.4415935771023612e43 < x < 1.0463787894136359e46Initial program 1.2
Simplified0.7
Taylor expanded in y around 0 1.2
Simplified0.3
if 1.0463787894136359e46 < x Initial program 60.7
Simplified57.1
Taylor expanded in x around inf 1.4
Simplified1.4
Final simplification0.9
herbie shell --seed 2022153
(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)))