# How to find the nth derivative?

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

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]

• 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 '14 at 18:25
• @skan You may ask a question instead of repeating comments all over – Dr. belisarius Dec 14 '14 at 18:42

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

• 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 '14 at 18:26
• @skan You may ask a question instead of repeating comments all over – Dr. belisarius Dec 14 '14 at 18:41

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.