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
add comment

3 Answers

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
add comment

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
add comment

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
add comment

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.