I want to be able to define an operator
(a(x)d/dx+b(x))n
where d/dx is the derivative operator and a(x) and b(x) are known functions and n is a positive integer.
Related Query: How about defining
∏i=1,...,n(ai(x)d/dx+bi(x))
where ai(x) and bi(x) are known functions and n is a positive integer ?
Answer
This can be done with Nest
:
abderiv[n_] =
Function[f, Nest[(a[x] D[#, x] + b[x]) &, f, n]];
abderiv[0][f[x]]
(* ==> f[x] *)
abderiv[1][f[x]]
(* ==> b[x] + a[x] Derivative[1][f][x] *)
abderiv[2][f[x]]
(*
==> b[x] +
a[x] (Derivative[1][b][x] + Derivative[1][a][x] Derivative[1][f][x] +
a[x] (f^\[Prime]\[Prime])[x])
*)
Here the order n
is provided as the argument to a function that is itself a function acting on an arbitrary expression f
. The assumption in the question seems to be that the differentiation variable is always x
, so I don't specify this variable as an additional argument.
Comments
Post a Comment