2
$\begingroup$

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.

$\endgroup$
1

2 Answers 2

2
$\begingroup$

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]  *)
$\endgroup$
0
$\begingroup$

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]
$\endgroup$
5
  • 1
    $\begingroup$ What if x is not a symbol? $\endgroup$
    – uranix
    Commented Oct 5, 2016 at 19:30
  • $\begingroup$ Give an exemple $\endgroup$ Commented Oct 5, 2016 at 19:44
  • $\begingroup$ Example F[s^2][1] $\endgroup$
    – uranix
    Commented Oct 5, 2016 at 19:46
  • $\begingroup$ I dont understand: should one make the integration on s ? If it is the case, the formula works in the same way F[s_][0] := Sin[s^2] F[s_][n_] := F[s^2][n] = D[F[s^2][n - 1], s] $\endgroup$ Commented Oct 5, 2016 at 19:54
  • $\begingroup$ Of cvourse I should have written derivation in place of integration $\endgroup$ Commented Oct 5, 2016 at 20:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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