So, essentially, I want to start with a summation:

$$s = \sum\_{k=a}^b{ f(k,x) }$$

and differentiate with respect to $x$, inside the summation. My question is: When does the following equality hold:

$$\frac{ds}{dx} = \sum\_{k=a}^b{ \left( f(k,x) \frac{d}{dx} \right) }$$

**IMPORTANT NOTE**

*I am especially interested in the case of infinite sums. Any information on differentiation inside infinite sums will be extremely helpful.*

This question is similar to [this one](https://math.stackexchange.com/questions/12909/will-moving-differentiation-from-inside-to-outside-an-integral-change-the-resu).

**EXAMPLE**

For example, Suppose I have the following sum:

$$s = \sum\_{k=a}^b{ \cos(k x) }$$

If I now differentiate with respect to $x$ inside the summation, I get, on the right-hand side:

$$\sum\_{k=a}^b{ -k \sin(k x) }$$

I'm wondering when I'm allowed to take the derivative, with respect to $x$, on the left-hand side, to get the same result.

*Please note: This is just one example. I'm wondering when I can do this in general, for any $f(k,x)$.*