incorrect output when derivative respect to function, sometimes doit() give the corect answer, sometimes not

56 views
Skip to first unread message

chaowen guo

unread,
Oct 22, 2016, 6:04:27 PM10/22/16
to sympy
  Hi:

  source code:

  import sympy
  x=sympy.symbols('x')
  y=sympy.exp(x)
  f=sympy.symbols('f',cls=sympy.Function)(y)
  import IPython.display
  IPython.display.Math(sympy.latex(f.diff(x,2)).replace('e^{x}','{e^{x}}'))#corrcet#replace is to work arround the latex output of e^{x}

  IPython.display.Math(sympy.latex(f.diff(x,2).doit()).replace('e^{x}','{e^{x}}'))#not corrcet#where is the leading 2 come from in the first term?

  IPython.display.Math(sympy.latex(f.diff(x).diff(x)).replace('e^{x}','{e^{x}}'))#correct

  IPython.display.Math(sympy.latex(f.diff(x).diff(x).doit()).replace('e^{x}','{e^{x}}'))#not correct#where is the leading 2 come from in the first term?

  IPython.display.Math(sympy.latex(f.diff(x).doit()).replace('e^{x}','{e^{x}}'))#correct

  IPython.display.Math(sympy.latex(f.diff(x).doit().diff(x)).replace('e^{x}','{e^{x}}'))#not correct#the df(xi)/d(xi) should not exist

  IPython.display.Math(sympy.latex(f.diff(y,2)).replace('e^{x}','{e^{x}}'))#not correct##where is the leading 2 come from?

  IPython.display.Math(sympy.latex(f.diff(y).doit().diff(y).doit()).replace('e^{x}','{e^{x}}'))#correct

output:



  Fom out [1] to out[6] show all the doit give incorrect answer, out[7] and out[8] show that doit give the correct answer. I want o ask whether it is a sympy bug or sympy has a special interpretation about such behavior?
Auto Generated Inline Image 1

Aaron Meurer

unread,
Oct 22, 2016, 9:58:48 PM10/22/16
to sy...@googlegroups.com
This looks like a bug. It's at least https://github.com/sympy/sympy/issues/7027, but there may be another bug there too.

Aaron Meurer

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscribe@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/c2ead2a8-1a69-4ad2-aa2f-ff0624f47474%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Riccardo Rossi

unread,
Oct 24, 2016, 4:11:32 PM10/24/16
to sympy
Could this be the same as the problem I see here?

https://groups.google.com/forum/m/#!topic/sympy/ogz52F5Ol5c

Regards
Riccardo

Reply all
Reply to author
Forward
0 new messages