I am doing some exercises, and wanted to see how I could represent this expression using Sympy.
Say A = d/dx and B = x.
I need to evaluate [A,B].
Manually, this is what I do: say, I have some function f, this commutator acts on, then I have
[A,B] f = (AB - BA)(f) = (d/dx)(x)(f) - x(d/dx)(f)
= x * (df/dx) + f - x * (df/dx) = f.
How can I represent such an expression in Sympy, and also get f as the answer if I use .doit() to expand the expression.
I am documenting some of the use cases I have been playing with, so that I can consolidate and publish these exercises as a notebook document.
Thanks
-Guru