2
$\begingroup$

Let's say I have the function

f[x_]:=x^50

I want to take one derivative and multiply the result by x recursively. That is, I want to

x D[x D[f[x],x],x]

but with an arbitrary amount of iterations. How can I implement this more elegantly?

$\endgroup$

closed as off-topic by happy fish, Edmund, Bob Hanlon, march, MarcoB Mar 10 '17 at 22:39

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – happy fish, Edmund, Bob Hanlon, march, MarcoB
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Look at Nest. $\endgroup$ – MarcoB Mar 10 '17 at 22:38
8
$\begingroup$

The function you are looking for is Nest.

Nest[x D[#, x] &, f[x], 2]

gives the expression you want. Change the last argument to control the number of recursions.

$\endgroup$
6
$\begingroup$

Your process is equivalent to differentiating with respect to Log[x]. I gave a function, chainD for performing these kinds of derivatives in my answer to Higher-order partial derivatives w.r.t. variable raised to some power. If you use this function:

chainD[x^50, Log[x]]
chainD[x^50, {Log[x], 20}]

50 x^50

9536743164062500000000000000000000 x^50

I should mention that you can manually apply the idea behind chainD with:

D[Exp[50 y], {y, 20}] /. y->Log[x]

9536743164062500000000000000000000 x^50

$\endgroup$
5
$\begingroup$
dOp1[f_, n_Integer?NonNegative] :=
 Nest[x*D[#, x] &, f[x], n]

For an undefined function f

Table[dOp1[f, n], {n, 0, 5}] // Expand // Column

enter image description here

Compare the coefficients with

Table[StirlingS2[n, m], {n, 0, 5}, {m, 0, n}] // Grid

enter image description here

Consequently, an alternative definition is

dOp2[f_, n_Integer?NonNegative] :=
 Sum[StirlingS2[n, m] D[f[x], {x, m}] x^m, {m, 0, n}]

Testing equivalence

And @@ Table[dOp1[f, n] == dOp2[f, n] // Simplify, {n, 0, 15}]

(*  True  *)

You can use a proof by induction to verify this.

For your specific f

f[x_] = x^50;

dOp2[f, 20]

(*  9536743164062500000000000000000000 x^50 *)
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.