How to find a function's rth derivative when r is symbolic in Mathematica?

回眸只為那壹抹淺笑 提交于 2019-12-02 22:00:50
f = FindSequenceFunction[Table[D[2/(2 - t), {t, n}], {n, 1, 5}], r]

(*
-> -((2 (2 - t)^-r Pochhammer[1, r])/(-2 + t))
*)
g[r_, t_] := f
FullSimplify@FindSequenceFunction[Table[g[r, t], {r, 1, 5}] /. t -> 0]

 (*
 -> 2^-#1 Pochhammer[1, #1] &
 *)

Edit

Or just

FindSequenceFunction[Table[D[2/(2 - t), {t, n}], {n, 1, 5}], r] /. t -> 0
(*
-> 2^-r Pochhammer[1, r]
*)

*Edit *

Note: While FindSequenceFunction[] works in this simple situation, don't bet on it in more general cases.

Edit

To get the result expressed in terms of the factorial function, just do:

FunctionExpand@FindSequenceFunction[Table[D[2/(2-t),{t, n}],{n,1,5}], r] /.t->0
(*
-> 2^-r Gamma[1 + r]
*)
Daniel Lichtblau

For analytic functions you can use SeriesCoefficient.

nthDeriv[f_, x_, n_] := n!*SeriesCoefficient[f[x], {x, x, n}]

Your example:

f[t_] := 2/(t - 2)

nthDeriv[f, t, n]
(*
-> Out[39]= n!*Piecewise[{{-2*(2 - t)^(-1 - n), n >= 0}}, 0]
*) 

There is another approach that sometimes works better (gives closed-form expressions rather than recurrence relations):

In[1]:= InverseFourierTransform[(-I k)^n FourierTransform[1/(1 + x^2)^Log[2], x, k] , k, x]
Out[1]= (2^(-1 + n - 1/2 Log[1/x^2])
      Abs[x]^-Log[2] ((-I)^
      n ((1 + n) x Gamma[(1 + n)/2] Gamma[
      n/2 + Log[2]] Hypergeometric2F1[(1 + n)/2, n/2 + Log[2], 1/
      2, -x^2] (n + Log[4]) - 
    2 I Gamma[1 + n/2] Gamma[
      1/2 (1 + n + Log[4])] ((1 + x^2) Hypergeometric2F1[(2 + n)/
         2, 1/2 (1 + n + Log[4]), -(1/2), -x^2] - 
       Hypergeometric2F1[(2 + n)/2, 1/2 (1 + n + Log[4]), 1/
         2, -x^2] (1 + x^2 (3 + 2 n + Log[4])))) + 
 I^n ((1 + n) x Gamma[(1 + n)/2] Gamma[
      n/2 + Log[2]] Hypergeometric2F1[(1 + n)/2, n/2 + Log[2], 1/
      2, -x^2] (n + Log[4]) + 
    2 I Gamma[1 + n/2] Gamma[
      1/2 (1 + n + Log[4])] ((1 + x^2) Hypergeometric2F1[(2 + n)/
         2, 1/2 (1 + n + Log[4]), -(1/2), -x^2] - 
       Hypergeometric2F1[(2 + n)/2, 1/2 (1 + n + Log[4]), 1/
         2, -x^2] (1 + x^2 (3 + 2 n + Log[4]))))))/((1 + n) 
       Sqrt[Pi] x Gamma[Log[2]] (n + Log[4]))

It also can be used to find repeated anti-derivatives.

The other answers make me wonder if I'm not understanding underlying question, but I think you should look at Derivative instead of D for this kind of thing.

In[1]:= Remove[f, fD]
f = 2/(2 - #) &;
fD[r_Integer, EvaluatedAt_] := Derivative[r][f][#] &[EvaluatedAt]

Now we have a function that can easily be evaluated for any r and value.

In[4]:= fD[#, 0] & /@ {1, 2, 3, 4, 5, 6}

Out[4]= {1/2, 1/2, 3/4, 3/2, 15/4, 45/4}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!