Thanks for your replies.
as_coeff_exponent(...) does the right thing for the (similar) Integral operation on f(x), so I'm not sure big changes are needed to fix this little glitch. I think this traces back to something slightly strange in sympy.collect (...) which is used by as_coeff_exponent. The behaviour for the fourth line of input below seems odd. I'll dig a little more and see what I find. Cheers, andy >>> Integral(f(x),x).as_coeff_exponent(f(x)) #This is OK (Integral(f(x), x), 0) >>> Derivative(f(x),x).as_coeff_exponent(f(x)) #This is what I first posted >>> about, seems very odd. (1, 1) >>> collect(Integral(f(x),x),f(x),evaluate=False) #This seems OK. {1: Integral(f(x), x)} >>> collect(Derivative(f(x),x),f(x),evaluate=False) #This looks odd to me - >>> collect has lost track of the derivative. {f(x): 1} also: >>> collect(Derivative(2*f(x),x,x),f(x),evaluate=False) #Probably OK... {1: D(2*f(x), x, x)} >>> collect(2*Derivative(f(x),x,x),f(x),evaluate=False) #Weird result again - >>> collect loses derivative operation again. {f(x): 2} On Oct 22, 10:47 pm, Ondrej Certik <ond...@certik.cz> wrote: > On Thu, Oct 22, 2009 at 3:43 PM, Ronan Lamy <ronan.l...@gmail.com> wrote: > > > Le jeudi 22 octobre 2009 à 14:42 -0700, Ondrej Certik a écrit : > >> On Thu, Oct 22, 2009 at 2:34 PM, andy2O <and...@hotmail.com> wrote: > > >> > Hi all, > > >> > as_coeff_exponent(...) seems to ignore derivatives, as shown below > > >> > Is this behaviour intended? If so I can report it as an issue - but > >> > last time recorded an issue it turned out I just misunderstood atoms > >> > (), so I thought I'd check first here! :) > > >> Sure. :) > > >> > Thanks, > >> > andy > > >> >>>> ================================ RESTART > >> >>>> ================================ > >> >>>> from sympy import * > >> >>>> var('x') > >> > x > >> >>>> f=Function('f') > >> >>>> d=diff(f(x),x) > >> >>>> d > >> > D(f(x), x) > >> >>>> d.as_coeff_exponent(f(x)) > >> > (1, 1) > > >> What do you suggest to be a correct answer? I never used > >> as_coeff_exponent inside a derivative. > > >> Ondrej > > > The correct answer is clearly (D(f(x), x), 0), by analogy with > > cos(x).as_coeff_exponent(sin(x)) == (cos(x), 0). So, yes, Andy, you've > > uncovered a real issue. > > > I think that the fundamental problem here is that there is no object > > representing the derivative of a function (the current Derivative is an > > operation applying to expressions, not functions). > > Yes, I think the Derivative should be improved to be able to represent > a general derivative of a function f(x). > > Ondrej --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@googlegroups.com To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sympy?hl=en -~----------~----~----~----~------~----~------~--~---