2

I writing a bit of code, but the problem is found here:

[IN>] from sympy import*

[IN>] t= Symbol('t')
      x1 = Function('x1')(t)
      x2 = Function('x2')(t)
      y1 = Function('y1')(t)
      y2 = Function('y2')(t)

I define my expression:

[IN>] f = (x1.diff(t)*y2.diff(t)- x2.diff(t)*y1.diff(t))

Then, when differentiating the expresion f wrt. the factors of the first summand I get the unexpected output:

[IN>] f.diff(y2.diff(t))

[OUT>] Subs(Derivative(x1(t), t), (_xi_2,), (Derivative(y2(t), t),))

but if I differentiate wrt. the second summand factors

[IN>] f.diff(y1.diff(t))

[OUT>] -Derivative(x2(t), t)

I get the desired and expected result. I'm totally baffled by this. Still more, if I change the order of the summands, I get the same result:

[IN>] (-x2.diff(t)*y1.diff(t)+x1.diff(t)*y2.diff(t) ).diff(y2.diff(t))

[OUT>] Subs(Derivative(x1(t), t), (_xi_2,), (Derivative(y2(t), t),))

[IN>] (-x2.diff(t)*y1.diff(t)+x1.diff(t)*y2.diff(t) ).diff(y1.diff(t))

[OUT>] -Derivative(x2(t), t)

But if I exchange the minus `-``sign, the propeblem is now in the other pair of functions:

[IN>] (+x2.diff(t)*y1.diff(t)-x1.diff(t)*y2.diff(t) ).diff(y1.diff(t))

[OUT>] Subs(Derivative(x2(t), t), (_xi_2,), (Derivative(y1(t), t),))
asmeurer
  • 86,894
  • 26
  • 169
  • 240
iiqof
  • 157
  • 10
  • @Mitch: I had a problem with my connection, and submited the question to early. – iiqof Aug 01 '16 at 15:41
  • `doit` is your answer, but I would consider this to be a bug in SymPy. See https://github.com/sympy/sympy/issues/11467. – asmeurer Aug 03 '16 at 18:54
  • @asmeurer I thought that that might be a problem. Thanks for putting it forward! – iiqof Aug 04 '16 at 16:50

1 Answers1

0

Ok, to get the desired result I only had to ad .doit(), as it was returning my the Subs() function.

(+x2.diff(t)*y1.diff(t)-x1.diff(t)*y2.diff(t) ).diff(y1.diff(t)).doit()

Derivative(x2(t), t)
iiqof
  • 157
  • 10