# How to symbolically differentiate an infinite series without evaluating the series itself

I'm dealing with finite sums of infinite series. Each of the infinite series possesses a different starting index, i.e. each of the series begins at n = 0, n = 1, or n = 2. As a result, it's important to keep track of the indices for each of the series.

In addition, Mathematica cannot evaluate the series, because it's too complicated and undesirable for what's to be accomplished. I've only written the series in this manner to allow for efficient symbolic manipulation.

The problem is that Mathematica takes a long time "trying" to evaluate each of the series. I've tried Hold, HoldAll, Unevaluated, and HoldForm. HoldForm seems like the correct choice, but there's a problem. Although I don't want to evaluate the series themselves, I'd still like to be able to perform operations on the series, such as differentiation.

So, does anyone know of a way to differentiate a series without evaluating the series itself?

I'm new to Mathematica, so the answer might be simple. Thanks for your time.

• Could you provide an example of two of the series you wish to look at? – rcollyer Jul 4 '12 at 20:22
• I'm only concerned with series of the general form... \begin{equation} \sum _{n=0}^N f_n(x,y,z) \end{equation} In my problem, however, $f_n$ takes the form: \begin{equation} – Rob Jul 4 '12 at 20:26
• Are you using Series or Sum? – rcollyer Jul 4 '12 at 20:30
• Incidentally, math mode is invokable only using $ for inline formulas and $$ for . – rcollyer Jul 4 '12 at 20:32 • I'm using Sum. As I attempted to write before, the function$f_n$is a product of other functions of (x,y,z), some of which are specified (i.e. by a specified function, I mean something like$x^2$) and some of which are left unspecified (i.e. by which I mean something like$g_n(y)\$). – Rob Jul 4 '12 at 20:37

## 2 Answers

You could define your own sum, and add rules to integrate it with various operators such as differentiation. This may be a lot of work however, since many built-in rules exist which inter-related Sum with other operations.

Below is an attempt to take another route and piggyback on the system:

ClearAll[withInertSum];
SetAttributes[withInertSum, HoldAll];
withInertSum[code_] :=
Block[{Sum}, Block[{sum = Sum}, code] /. Sum -> sum];


If you now define your own inert head sum with no rules attached to it, then you can, e.g., do the following:

mySum = sum[(x + y + z)^n/n!, {n, 0, m}]
withInertSum[D[mySum,{x,2}]]

(*   sum[((-1+n) n (x+y+z)^(-2+n))/n!,{n,0,m}]   *)


What happens is that sum becomes Sum temporarily, inside withInertSum, but only after all direct rules for Sum have been temporarily switched off. Then, we try to compute things, and finally, replace Sum with sum once again. At least for the simple example above, this works, because apparently at least some of the rules relating Sum and D were attached to D rather than to Sum.

• very sneaky... :) – sebhofer Jul 5 '12 at 8:25

Starting in M10, another possibility quite similar to @Leonid's answer is to use Inactive. For example:

Simplify @ D[Inactive[Sum][(x+y+z)^n/n!, {n,0,m}], {x,2}]


Inactive[Sum][((-1 + n) n (x + y + z)^(-2 + n))/n!, {n, 0, m}]