Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 402
jscoot Avatar asked Nov 26 '11 12:11

jscoot


People also ask

What is derivative in basic calculus?

derivative, in mathematics, the rate of change of a function with respect to a variable. Derivatives are fundamental to the solution of problems in calculus and differential equations.


2 Answers

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]
*) 
like image 188
Daniel Lichtblau Avatar answered Oct 05 '22 16:10

Daniel Lichtblau


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]
*)
like image 42
Dr. belisarius Avatar answered Oct 05 '22 16:10

Dr. belisarius