Search code examples
pythonsympysymbolic-mathmaxima

Differential operator in Sympy or in Wxmaxima


Is it possible to generate linear differential operator with open source softwares such as sympy or wxmaxima and apply it to a function. For example, let differential operator L be:

L = d^2/dx^2 + d^2/dy^2 +d/dx

and

f = x^2*y^3

For example I want to apply L/3 + L^2/3^2 +L^3/3^3 to f. In mathematica this can be done as in following link: https://mathematica.stackexchange.com/questions/72433/polynomial-expansion-of-operator


Solution

  • As suggested, but you might consider a recursive definition:

    >>> def L(n, f):
    ...     if n==1:
    ...         return diff(f, x) + diff(f, x, 2) # for example
    ...     return L(n-1, L(1,f))
    >>> L(2, x**2+y/x)
    2 + 2*y/x**3 + 6*y*(-1 + 4/x)/x**4 - 6*y/x**4