Question: How to apply the D operator to an indefinite sum?

I have an indefinite sum, for instance:

> E := Sum(f@g@@k, k=0..n);

If I use D(E), I just get: D(Sum(f@g@@k),k = 0 .. n)

> D(f@g@@k) gives the expected result: D(f)@g@@k * D(g@@k)

Doing this works:

> F := Sum(D(op(E)[1]), op(E)[2]);

   F := Sum(D(f)@g@@k * D(g@@k), k=0..n)

However I want to apply it to complex expressions containing Sums and Products. And I can't check if E is of type indefinite sum. The hasfun(E, Sum) searches recursively, it doesn't tell if the top level function is Sum.

Is there any way around this?

 

*Edit: maybe my question isn't clear enough. I want a way to transform

> E:=Sum(function, k=0..n);

into:

> E:=Sum(D(function), k=0..n);

But only when E is of type indefinite sum.

Please Wait...