假设我有这样的事情:
from sympy.physics.quantum import *
from sympy import symbols, Function, Derivative, var
m = symbols('mu', positive=True)
var('x')
var('t')
f = Function('psi')
T = DifferentialOperator(-1 / (2 * m) * Derivative('psi(x,t)', x, x))
V = Operator('V(x)')
K = Operator('K(x)')
如何得到[T,K] u(x,t)= T(K(u)) - K(T(u))的表达式?这里,u是波函数,T应该将链规则应用于K(u)乘积。
答案 0 :(得分:1)
嗯,解决方法:
from sympy import symbols, Function, Derivative, var, init_printing
def T(y):
var('mu')
return -1 / (2 * mu) * Derivative(y, x, x)
def V(y):
var('x')
V = Function('V', commutative=True)(x)
return V * y
def comm(A, B):
def comm(y):
return A(B(y)) - B(A(y))
return comm
var('x')
var('t')
f = Function('psi', commutative=False)
comm(T, V)(f)