1 | initial version |
Here is a way to apply a polynomial P
in a differential operator D
to a function f
.
def polydop(P,D,f):
ff = f
g(t) = 0
for c in P.coeffs():
g = (g + c * ff).expand()
ff = D(ff).expand()
return g
To illustrate it on your example, define
the differential operator:
sage: def D(f):
....: return t*f.derivative(t)
the polynomial (in a suitable polynomial ring):
sage: R = PolynomialRing(QQ,'x')
sage: x = R.gen()
sage: P = prod(x-n for n in xrange(1,6))
and the function:
sage: f(t,z) = z*t*exp(t/z)
and get the following result:
sage: g = polydop(P,D,f)
sage: g
(t, z) |--> t^6*e^(t/z)/z^4