# Derivative in function form

I have a function in mathematica defined as

 b[n_, x_] := x^n/n!/\!$$\*UnderoverscriptBox[\(\[Sum]$$, $$k = n$$, $$\[Infinity]$$]\*FractionBox[$$x^k$$, $$k!$$]\)


which is the same as $$b(n,x)=\frac{\frac{x^n}{n!}}{e^x-1-x-...-\frac{x^{n-1}}{(n-1)!}}$$

I want to take the derivative of this differential expression with respect to $x$:

$$x^2b''(n,x)+\left[3x^2+(1-3n)x\right]b'(n,x)+\left[2x^2+(1-4n)x+2n^2\right]b(n,x)$$

So i write this into mathematica:

 a[n_, x_] := x^2*D[D[b[n, x], x], x] + (3 x^2 + (1 - 3 n) x)*D[b[n, x], x] + (2 x^2 + (1 - 4 n) x + 2 n^2)*b[n, x]

D[a[n, x], x]


from here, mathematica spits out the answer, but it gives the answer in terms of

 (1 - 3 n + 6 x) (-((E^(-2 x) x^(-1 + 2 n) Gamma[n])/( n! (Gamma[n] - Gamma[n, x])^2)) + (E^-x n x^(-1 + n) Gamma[n])/(
n! (Gamma[n] - Gamma[n, x])) - (E^-x x^n Gamma[n])/(n! (Gamma[n] - Gamma[n, x]))) + ...


I am hoping someone can help get the output to be in terms of a derivative instead of the gamma function factorization that is being generated when I take the derivative of $a(n,x)$. For example, the first few terms of the derivative are $$x^2b'''(n,x)+2xb''(n,x)+\left[3x^2+(1-3n)x\right]b''(n,x)+\left[6x+(1-3n)\right]b'(n,x)+...$$

Is there a way mathematica can do this as an output instead of the long string of factors comprised of the gamma function?

The problem is that the definition of b is being substituted (and some of the factorials are being converted to Gamma). You need to keep b from being evaluated. Without knowing how you wish to use the result, here is a possibility:

a[n_, x_] :=
Inactivate[
x^2*D[D[b[n, x], x], x] + (3 x^2 + (1 - 3 n) x) * D[b[n, x], x] +
(2 x^2 + (1 - 4 n) x + 2 n^2)*b[n, x],
b]

D[a[n, x], x]


If you don't like the derivatives of b being displayed as partial derivative, well, it's because you've declared b to the a function of two variable. Mathematica is just displaying which variable is being differentiated.

Here's a more roundabout way, but keeping your definition of a and avoid the V10 Inactive, which could have been used here instead of HoldForm:

a[n_, x_] :=
x^2*D[D[b[n, x], x], x] + (3 x^2 + (1 - 3 n) x) * D[b[n, x], x] +
(2 x^2 + (1 - 4 n) x + 2 n^2)*b[n, x]

Hold[D[a[n, x], x]] /. DownValues[a] /. b -> HoldForm[b] // ReleaseHold

• Your first result with the inactivate function is PERFECT!!! That is exactly what I am looking for... – Eleven-Eleven Nov 5 '14 at 2:14

This is just an extended comment.

If you use (Full)Simplify there is no long string of terms even with b[n,x] being evaluated.

Clear[a, b]

b[n_, x_] = (x^n/n!)/Sum[x^k/k!, {k, n, Infinity}] //
FullSimplify


Limit[x^2 D[b[n, x], {x, 2}] +
(3 x^2 + (1 - 3 n) x) D[b[n, x], x] +
(2 x^2 + (1 - 4 n) x + 2 n^2) b[n, x], x -> 0]


2*n^2

a[n_, x_] = Piecewise[{
{2 n^2, x == 0}},
x^2 D[b[n, x], {x, 2}] +
(3 x^2 + (1 - 3 n) x) D[b[n, x], x] +
(2 x^2 + (1 - 4 n) x + 2 n^2) b[n, x] //
Simplify]


D[a[n, x], x] // FullSimplify