2

I need to define a sequence of functions $$ F_0(x), F_1(x), \dots $$ where each function $F_{k+1}(x)$ is defined using $F_k'(x)$. For simplicity let's assume that $$ F_{k+1}(x) = F_k'(x). $$

I'm using the following (not working) Mathematica code:

F[0, x_] = Sin[x]
F[kp1_, x_] := F[kp1_, x_] = With[{k = kp1 - 1},
  Derivative[0, 1][F][k, x]
]
F[1, s^2]

The code gives $RecursionLimit::reclim due to

Derivative[0, 1][F][0, x]

is not evaluating and I have no idea how to fix that.

Actually I can introduce dummy variable and use D instead of Derivative

F[0, x_] = Sin[x]
F[kp1_, x_] := F[kp1_, x_] = With[{k = kp1 - 1},
  D[F[k, y], y] /. y -> x
]
F[1, s^2]

This code works flawlessly, but in my actual problem there's a lot of variables and introducing new variables will make a huge mess, so I would like to stick with Derivative operator.

uranix
  • 537
  • 3
  • 14

2 Answers2

2

Your second method can be done with an "anonymous" substitute for y, namely, Slot[1]:

ClearAll[F];
F[0, x_] = Sin[x];
F[kp1_, x_] := F[kp1, x] = With[{k = kp1 - 1}, Evaluate[D[F[k, #], #]] &@x]

F[1, s^2]
(*  Cos[s^2]  *)
Michael E2
  • 235,386
  • 17
  • 334
  • 747
0

Try this --- I suppose that the initial function is Sin[x]

F[x_][0] := Sin[x]
F[x_][n_] := F[x][n] = D[F[x][n - 1], x]
march
  • 23,399
  • 2
  • 44
  • 100
cyrille.piatecki
  • 4,582
  • 13
  • 26