I am new to Mathematica, I am trying to generate the polynomial function of a operator. So for example, the operator $L $ is $\frac{\partial f}{\partial x}+\frac{\partial f}{\partial y} $, and I want to generate the polynomial $ \sum_{n=0}^{n=k} (L/2)^n$ and apply that polynomial operator to a function. I was trying to use Nest, any help??
Answer
Define
L = (1/2) (D[#, x] + D[#, y]) &
We see that L
works as desired. For instance:
Simplify[Nest[L, f[x, y], 3]]
(* (Derivative[0, 3][f][x, y] + 3*Derivative[1, 2][f][x, y] + 3*Derivative[2, 1][f][x, y] +
Derivative[3, 0][f][x, y])/8 *)
And the Sum
can be constructed in a similar manner. For instance:
Simplify[Sum[Nest[L, f[x, y], n], {n, 0, 3}]]
(* (8*f[x, y] + 4*Derivative[0, 1][f][x, y] + 2*Derivative[0, 2][f][x, y] +
Derivative[0, 3][f][x, y] + 4*Derivative[1, 0][f][x, y] +
4*Derivative[1, 1][f][x, y] + 3*Derivative[1, 2][f][x, y] + 2*Derivative[2, 0][f][x, y] +
3*Derivative[2, 1][f][x, y] + Derivative[3, 0][f][x, y])/8 *)
Update
As kindly pointed out by @b.gatessucks in the Comment below, computation of the final result can be simplified with NestList
. (Thanks!)
Simplify[Total[NestList[L, f[x, y], 3]]]
Comments
Post a Comment