Search code examples
wolfram-mathematicasymbolic-math

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


I have a function f(t)=2/(2-t). It is not so hard to get the rth derivative at t=0 (i.e. 2^(-r)*r!) without using Mathematica. In the case of Mathematica calculation, I can get the r-th derivative when r=4 like this: D[2/(2-t), {t, 4}]. But how can I get the rth derivative at t=0 in Mathematica when r is ANY integer? I tried to use this expression, but it didn't work as expected:

Simplify[D[2/(2 - t), {t, r}], Assumptions -> Element[r, Integers]]  /. {t->0}

Is it possible to do the above math symbolically in Mathematica just as we humans do?


Solution

  • 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]
    *)