Making an operator that works automatically always is not currently possible. To really work completely, you would need http://code.google.com/p/sympy/issues/detail?id=1941. See also https://github.com/sympy/sympy/wiki/Canonicalization (feel free to edit that page).
However, you could make a class that works most of the time using the ideas from that stackoverflow question, and for the cases it doesn't handle, write a simple function that goes through an expression and applies the operator where it hasn't been applied yet. By the way, one thing to consider with a differential operator as "multiplication" is that it's nonassociative. Namely, (D*f)*g = g*Df, whereas D*(f*g) = g*Df + f*Dg. So you need to be careful when you do stuff that it doesn't "eat" some part of an expression and not the whole thing. For example, D*2*x would give 0 because of this. SymPy everywhere assumes that multiplication is associative, so it's likely to do that incorrectly at some point. If that becomes an issue, I would recommend dumping the automatic application, and just working with a function that goes through and applies it (which as I noted above, you will need anyway). Aaron Meurer On Mar 18, 2013, at 6:57 AM, Saullo Castro <saullogiov...@gmail.com> wrote: Dear Mr. Zhang, we are using a differential operator as you need, please see more details on: http://stackoverflow.com/questions/15463412/matrix-of-differential-operators-in-python-module-sympy We could address it without changing the core classes in Sympy only when the differential operator is used on the left side. When it is used on the right side the method __mul__ in the core class Expr had to be changed. We are still looking for a Sympy native solution, though. Regards On Friday, January 25, 2013 11:49:43 PM UTC+1, ruoyu zhang wrote: > > >>> p = DifferentialOperator(t) > >>> a * p * f(t) > Derivative(f(t), t)*a > > p is a DifferentialOperator, when it multiply with some expression at > right side, it calculates the derivative of the expression. > -- 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+unsubscr...@googlegroups.com. To post to this group, send email to sympy@googlegroups.com. Visit this group at http://groups.google.com/group/sympy?hl=en. For more options, visit https://groups.google.com/groups/opt_out. -- 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+unsubscr...@googlegroups.com. To post to this group, send email to sympy@googlegroups.com. Visit this group at http://groups.google.com/group/sympy?hl=en. For more options, visit https://groups.google.com/groups/opt_out.