Repository: sympy/sympy

Issue:
factorial(x) is not known to be real when x is a noninteger
I guess this is very much related to #8658.

When `x` is a noninteger real, `factorial(x)` is simply `gamma(x+1)`, which is gamma of a number which is not a nonpositive integer, hence it must be real. Thus, `factorial(x).is_real` should return `True` (but now it returns `None`).


Discussion:

Patch:
diff --git a/sympy/functions/combinatorial/factorials.py b/sympy/functions/combinatorial/factorials.py
index 280238d9df..dadf12d5c0 100644
--- a/sympy/functions/combinatorial/factorials.py
+++ b/sympy/functions/combinatorial/factorials.py
@@ -173,8 +173,8 @@ def _eval_is_positive(self):
             return True
 
     def _eval_is_real(self):
-        if ((self.args[0].is_negative and self.args[0].is_noninteger) or
-           self.args[0].is_nonnegative):
+        x = self.args[0]
+        if x.is_nonnegative or x.is_noninteger:
             return True
 
 


Test patch:
diff --git a/sympy/functions/combinatorial/tests/test_comb_factorials.py b/sympy/functions/combinatorial/tests/test_comb_factorials.py
index d00a55776e..355d89770a 100644
--- a/sympy/functions/combinatorial/tests/test_comb_factorials.py
+++ b/sympy/functions/combinatorial/tests/test_comb_factorials.py
@@ -88,8 +88,9 @@ def test_factorial():
     n = Symbol('n', integer=True)
     k = Symbol('k', integer=True, nonnegative=True)
     r = Symbol('r', integer=False)
-    s = Symbol('s', integer = False, negative = True)
+    s = Symbol('s', integer=False, negative=True)
     t = Symbol('t', nonnegative=True)
+    u = Symbol('u', noninteger=True)
 
     assert factorial(-2) == zoo
     assert factorial(0) == 1
@@ -110,6 +111,7 @@ def test_factorial():
     assert factorial(r).is_real is None
     assert factorial(s).is_real is True
     assert factorial(t).is_real is True
+    assert factorial(u).is_real is True
 
     assert factorial(oo) == oo