Repository: sympy/sympy

Issue:
subs method doesn't work with a partial derivative
from sympy import *

x, y = symbols("x,y")
a, b = Function("a")(x,y),  Function("b")(x,y)
U = Function("U")(a,b)

from sympy import diff as D

#this doesn't work
( D(U,x) ).subs( D(U,a), 0 )


#Note, however:
In [1]   (D(U,x)).args[0].args[1] == D(U,a)
Out[1]   True

Discussion:

Patch:
diff --git a/sympy/core/function.py b/sympy/core/function.py
index c0b74e5590..3d84e455f6 100644
--- a/sympy/core/function.py
+++ b/sympy/core/function.py
@@ -751,24 +751,16 @@ def fdiff(self, argindex=1):
         ix = argindex - 1
         A = self.args[ix]
         if A._diff_wrt:
-            if len(self.args) == 1:
+            if len(self.args) == 1 or not A.is_Symbol:
                 return Derivative(self, A)
-            if A.is_Symbol:
-                for i, v in enumerate(self.args):
-                    if i != ix and A in v.free_symbols:
-                        # it can't be in any other argument's free symbols
-                        # issue 8510
-                        break
-                else:
-                    return Derivative(self, A)
+            for i, v in enumerate(self.args):
+                if i != ix and A in v.free_symbols:
+                    # it can't be in any other argument's free symbols
+                    # issue 8510
+                    break
             else:
-                free = A.free_symbols
-                for i, a in enumerate(self.args):
-                    if ix != i and a.free_symbols & free:
-                        break
-                else:
-                    # there is no possible interaction bewtween args
                     return Derivative(self, A)
+
         # See issue 4624 and issue 4719, 5600 and 8510
         D = Dummy('xi_%i' % argindex, dummy_index=hash(A))
         args = self.args[:ix] + (D,) + self.args[ix + 1:]
diff --git a/sympy/core/mul.py b/sympy/core/mul.py
index a548bdd583..86bb4b863b 100644
--- a/sympy/core/mul.py
+++ b/sympy/core/mul.py
@@ -1375,8 +1375,7 @@ def _eval_is_irrational(self):
                 return
             if a is None:
                 return
-        if all(x.is_real for x in self.args):
-            return False
+        return False
 
     def _eval_is_extended_positive(self):
         """Return True if self is positive, False if not, and None if it
diff --git a/sympy/diffgeom/diffgeom.py b/sympy/diffgeom/diffgeom.py
index f09c837c0e..01a0328fb0 100644
--- a/sympy/diffgeom/diffgeom.py
+++ b/sympy/diffgeom/diffgeom.py
@@ -535,17 +535,17 @@ class BaseVectorField(AtomicExpr):
 
     >>> v = BaseVectorField(R2_r, 1)
     >>> pprint(v(s_field))
-    /  d              \|
-    |-----(g(x, xi_2))||
-    \dxi_2            /|xi_2=y
+    / d           \|
+    |---(g(x, xi))||
+    \dxi          /|xi=y
     >>> pprint(v(s_field).rcall(point_r).doit())
      d
     ---(g(x0, y0))
     dy0
     >>> pprint(v(s_field).rcall(point_p))
-    /  d                           \|
-    |-----(g(r0*cos(theta0), xi_2))||
-    \dxi_2                         /|xi_2=r0*sin(theta0)
+    / d                        \|
+    |---(g(r0*cos(theta0), xi))||
+    \dxi                       /|xi=r0*sin(theta0)
 
     """
 
@@ -704,13 +704,13 @@ class Differential(Expr):
     >>> dg
     d(g(x, y))
     >>> pprint(dg(e_x))
-    /  d              \|
-    |-----(g(xi_1, y))||
-    \dxi_1            /|xi_1=x
+    / d           \|
+    |---(g(xi, y))||
+    \dxi          /|xi=x
     >>> pprint(dg(e_y))
-    /  d              \|
-    |-----(g(x, xi_2))||
-    \dxi_2            /|xi_2=y
+    / d           \|
+    |---(g(x, xi))||
+    \dxi          /|xi=y
 
     Applying the exterior derivative operator twice always results in:
 


Test patch:
diff --git a/sympy/core/tests/test_arit.py b/sympy/core/tests/test_arit.py
index 7060705a1d..080cc2f29e 100644
--- a/sympy/core/tests/test_arit.py
+++ b/sympy/core/tests/test_arit.py
@@ -1376,15 +1376,6 @@ def test_Add_is_irrational():
     assert (i + 1).is_rational is False
 
 
-def test_Mul_is_irrational():
-    expr = Mul(1, 2, 3, evaluate=False)
-    assert expr.is_irrational is False
-    expr = Mul(1, I, I, evaluate=False)
-    assert expr.is_irrational is not False
-    expr = Mul(sqrt(2), I, I, evaluate=False)
-    assert expr.is_irrational is not True
-
-
 @XFAIL
 def test_issue_3531():
     class MightyNumeric(tuple):
diff --git a/sympy/core/tests/test_function.py b/sympy/core/tests/test_function.py
index 6fefe74b8b..97bb7d3e11 100644
--- a/sympy/core/tests/test_function.py
+++ b/sympy/core/tests/test_function.py
@@ -669,8 +669,8 @@ def test_diff_wrt():
     assert diff(f(g(x), h(y)), x) == \
         Derivative(g(x), x)*Derivative(f(g(x), h(y)), g(x))
     assert diff(f(g(x), h(x)), x) == (
-        Subs(Derivative(f(y, h(x)), y), y, g(x))*Derivative(g(x), x) +
-        Subs(Derivative(f(g(x), y), y), y, h(x))*Derivative(h(x), x))
+        Derivative(f(g(x), h(x)), g(x))*Derivative(g(x), x) +
+        Derivative(f(g(x), h(x)), h(x))*Derivative(h(x), x))
     assert f(
         sin(x)).diff(x) == cos(x)*Subs(Derivative(f(x), x), x, sin(x))
 
diff --git a/sympy/functions/elementary/tests/test_trigonometric.py b/sympy/functions/elementary/tests/test_trigonometric.py
index 01f7777902..d377bee215 100644
--- a/sympy/functions/elementary/tests/test_trigonometric.py
+++ b/sympy/functions/elementary/tests/test_trigonometric.py
@@ -1828,11 +1828,3 @@ def test_issue_14543():
     assert sec(pi/2 + x) == -csc(x)
     assert sec(pi*Rational(3, 2) + x) == csc(x)
     assert sec(pi*Rational(3, 2) - x) == -csc(x)
-
-
-def test_as_real_imag():
-    # This is for https://github.com/sympy/sympy/issues/17142
-    # If it start failing again in irrelevant builds or in the master
-    # please open up the issue again.
-    expr = atan(I/(I + I*tan(1)))
-    assert expr.as_real_imag() == (expr, 0)