Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This question is not the same as my last one. How do you find the $n$-th derivative where $n$ is a variable?

For example, you can find the nth derivative for a specific $n = 3$

D[Log[1 + x], {x, 3}]

but how do you get Mathematica to show the $n$-th derivative for $n$ as a general variable?

For example, from Wolfram Alpha

share|improve this question
2  
Asked on StackOverflow: stackoverflow.com/q/8278367/618728 –  Mr.Wizard Aug 18 '12 at 18:10

3 Answers 3

up vote 9 down vote accepted

Copying Daniel's method from this StackOverflow question:

For analytic functions you can use SeriesCoefficient.

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

nthDeriv[f, t, n]
n! Piecewise[{{1/((-t)^n*t), n >= 0}}, 0]
share|improve this answer
    
In an exam in my first university course I had to solve the nth derivative of Exp[x^3]. I wasn't able to get it. Later I found the answer in a handbook without any explanation. I've tried to solve it with Mathematica but it seems not able to do it, neither with the nthDeriv method nor with the FindSequenceFunction one. How can I get it? Maybe using recursive matrixes or applying the Leibniz rule? –  skan Dec 14 at 18:25
1  
@skan You may ask a question instead of repeating comments all over –  belisarius Dec 14 at 18:42

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.

share|improve this answer

Also, sometimes you are just lucky:

t = Table[D[Log[1 + x], {x, n}], {n, 10}]
FindSequenceFunction[t, n]
(*
-> -(-(1/(1 + x)))^n Pochhammer[1, -1 + n]
*)

testing

(FindSequenceFunction[t, n] /. n -> 20) == D[Log[1 + x], {x, 20}]
(* True *)
share|improve this answer
    
In an exam in my first university course I had to solve the nth derivative of Exp[x^3]. I wasn't able to get it. Later I found the answer in a handbook without any explanation. I've tried to solve it with Mathematica but it seems not able to do it, neither with the nthDeriv method nor with the FindSequenceFunction one. How can I get it? Maybe using recursive matrixes or applying the Leibniz rule? –  skan Dec 14 at 18:26
    
@skan You may ask a question instead of repeating comments all over –  belisarius Dec 14 at 18:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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