Ah I forgot to mention something that might be relevant...
DifferentialOperator subclasses Operator, which is a subclass of QExpr and
thus Expr.

On Wed, Jul 6, 2011 at 1:45 PM, Tomo Lazovich <lazov...@fas.harvard.edu>wrote:

> Hi sympy folk,
>
> I've been writing a new class, DifferentialOperator, in
> sympy.physics.quantum. It takes a symbol (or string to sympify) as an
> argument, and it is non-commutative (this is all you really need to know for
> this discussion).
>
> At some point when doing representations of momentum operators in a
> position basis, we produce an expression like
> DiracDelta(x-x_1)*DiracDelta(x_1-x_2)*DifferentialOperator(x_1), where x,
> x_1, and x_2 are all symbols. When I try to integrate this over x_1, I get
> the output:
>
> >>>
> integrate(DiracDelta(x-x_1)*DiracDelta(x_1-x_2)*DifferentialOperator(x_1),
> (x_1, -oo, oo))
> DiracDelta(x - x_2) * DifferentialOperator(oo)
>
> when we expect instead DiracDelta(x - x_2) * DifferentialOperator(x).
>
> After some hunting in the code, I think I've isolated this to the behavior
> of as_independent, which is called in the process of integration. If you run
>
> >>> f = DiracDelta(x-x_1)*DiracDelta(x_1-x_2)*DifferentialOperator(x_1)
> >>> f.as_independent(x_1)
> (DifferentialOperator(x_1), DiracDelta(x - x_1)â‹…DiracDelta(x_1 - x_2))
>
> So, even though DifferentialOperator(x_1) depends on x_1 (x_1 appears in
> its free_symbols, and has(x_1) returns True) it still gets separated out as
> independent
> and is thus treated as a coefficient in the integral.
>
> Does someone who is more familiar with this code know what's going on? Is
> this desired behavior because the DifferentialOperator is non-commutative,
> or is there a bug in as_independent?
>
> Thanks for your help!
>
> Tomo
>
>

-- 
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.

Reply via email to