# Mathematica 9 and later behavior with derivative of a sum

Bug introduced in 9.0 or earlier and fixed in 11.0.0

In:

D[Sum[Sin[x],x],x]

D[Sum[f[x],x],x]

Out:

1/2 Cos[1/2 (-1 - Pi + 2 x)] Csc[1/2]

0


Function f is undefined, but Mathematica 9 counts it as constant?

Mathematica 8 returns

• It's because you take derivative with respect to the local parameter of the sum. Sum itself doesn't depend on x. But in the case of Sin[x] it simplifies it first to the expression dependent of x. So it's not a bug. Commented Dec 19, 2012 at 9:42
• @swish so it is good if undefined function is counted as zero? Commented Dec 19, 2012 at 9:49
• Even more, the sum of a defined function and undefined one also gives zero: D[Sum[f[x] + Sin[x], x], x] -> 0 Commented Dec 19, 2012 at 9:51
• @Anixx If sum can be simplified then Sum[f[x],x] is the same as Sum[f[y],{y,0,x-1}]. But without specifying the limits it's not a function, because x is an index variable not an upper limit. Commented Dec 19, 2012 at 10:12
• @swish No matter what you expect it to mean, you will have to agree that if D[Sum[Sin[x],x],x] has a nonzero value, then D[Sum[f[x],x],x] cannot be zero in general, since we might have f==Sin. Commented Dec 19, 2012 at 12:23

Probably this is just a bug. Especially since it "works" in 8. You could fix it by doing

SetOptions[D, NonConstants -> {Sum}]


first, or by putting this in your init.m file.

• Sorry, but I wouldn't do that. Even in version 8 you would expect D[Sum,x] == 0 to be True, wouldn't you?
– Jens
Commented Dec 19, 2012 at 22:02
• Well, we are supposed to use lower case letters for variables. Anyway, of course this is not a real fix, just a hack as a reminder that something is fishy in 9.0.0 (waiting for 9.0.1 anyway any day, aren't you, too?) Commented Dec 19, 2012 at 22:38
• Actually, I think I'm just waiting to get version 5.2 back one day...
– Jens
Commented Dec 19, 2012 at 22:42
• Sum[f[x],x] gave an error there ... Commented Dec 19, 2012 at 22:47
• Well, are things better now? Anyway, I'm only kidding about the good old times... they weren't that good, either, I guess.
– Jens
Commented Dec 19, 2012 at 22:52