\frac{\left(x - 2\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922227999964 + 78.6994924154000017\right) \cdot x + 137.51941641600001\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514000014\right) \cdot x + 263.50507472100003\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606000001}\begin{array}{l}
\mathbf{if}\;x \le -2.39582003059970368 \cdot 10^{49} \lor \neg \left(x \le 3.9187971556134169 \cdot 10^{49}\right):\\
\;\;\;\;\mathsf{fma}\left(x, 4.16438922227999964, \frac{y}{{x}^{2}} - 110.11392429848109\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x - 2}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right) \cdot x + 313.399215894, x, 47.066876606000001\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999964, 78.6994924154000017\right), x, 137.51941641600001\right), x, y\right), x, z\right)}}\\
\end{array}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 temp;
if (((x <= -2.3958200305997037e+49) || !(x <= 3.918797155613417e+49))) {
temp = fma(x, 4.16438922228, ((y / pow(x, 2.0)) - 110.1139242984811));
} else {
temp = ((x - 2.0) / (fma(((fma((x + 43.3400022514), x, 263.505074721) * x) + 313.399215894), x, 47.066876606) / fma(fma(fma(fma(x, 4.16438922228, 78.6994924154), x, 137.519416416), x, y), x, z)));
}
return temp;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 26.5 |
|---|---|
| Target | 0.5 |
| Herbie | 0.5 |
if x < -2.3958200305997037e+49 or 3.918797155613417e+49 < x Initial program 62.0
Simplified58.0
Taylor expanded around inf 0.4
Simplified0.4
if -2.3958200305997037e+49 < x < 3.918797155613417e+49Initial program 1.2
Simplified0.7
rmApplied *-un-lft-identity0.7
Applied add-sqr-sqrt0.8
Applied times-frac1.0
Applied associate-/r*0.9
Simplified0.9
rmApplied associate-/l/1.0
Simplified0.7
rmApplied fma-udef0.7
Final simplification0.5
herbie shell --seed 2020049 +o rules:numerics
(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) 1) (/ (+ (* (+ (* (+ (* (+ (* 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) (+ (* (+ (* (+ (* (+ (* x 4.16438922228) 78.6994924154) x) 137.519416416) x) y) x) z)) (+ (* (+ (* (+ (* (+ x 43.3400022514) x) 263.505074721) x) 313.399215894) x) 47.066876606)))