Differential Operator usable in Matrix form, in Python module Sympy
问题 We need two matrices of differential operators [B] and [C] such as: B = sympy.Matrix([[ D(x), D(y) ], [ D(y), D(x) ]]) C = sympy.Matrix([[ D(x), D(y) ]]) ans = B * sympy.Matrix([[x*y**2], [x**2*y]]) print ans [x**2 + y**2] [ 4*x*y] ans2 = ans * C print ans2 [2*x, 2*y] [4*y, 4*x] This could also be applied to calculate the curl of a vector field like: culr = sympy.Matrix([[ D(x), D(y), D(z) ]]) field = sympy.Matrix([[ x**2*y, x*y*z, -x**2*y**2 ]]) To solve this using Sympy the following Python