This question has been asked quite a lot on math SE, however, please before you mark this as a duplicate carry on reading, I will try to highlight my doubts and concerns as clear as possible.
First in class we had the following theorem:
Let $(a_n)_{n \in \mathbb{N}}$ be a sequence in $\mathbb{R}$. Let $R > 0$ such that $f(x)=\sum_{n=0}^{+ \infty} a_nx^n$ converges absolutely for $|x|< R$, then $f(x)$ is differentiable and $\forall x \in ]-R,R[$ the derivative is $f'(x)=\sum_{n=1}^{+ \infty} na_nx^{n-1}$
I do understand the meaning of this theorem, however, when it comes to applying it I seem to end up at horrible wrong results. What puzzles me the most is (and I won't link the specific cases in here) that I have seen many answers on math SE and other online resources where people differentiate the sum without raising the initial value from $n=0$ to $n=1$ and neither shift the index, however they always seem to succeed to show what they want with this approach.
Example (No Problem here, works perfect):
Without thinking much about it and just using and intuitive understanding of the theorem given above I differentiate the following: $$ \cos'(x)= \left(\sum_{n=0}^{+ \infty} \frac{(-1)^n x^{2n}}{(2n)!} \right)'=\sum_{n=1}^{+ \infty} \frac{(-1)^n2nx^{2n-1}}{(2n)!}=\sum_{n=1}^{+ \infty} \frac{(-1)^nx^{2n-1}}{(2n-1)!}$$ notice the index which I am about to shift now (using $i=n-1$ and replacing it in my mind) $$ \implies \cos '(x)= \sum_{n=0}^{+ \infty} \frac{(-1)^{n+1}x^{2n+1}}{(2n+1)!}=-\sum_{n=0}^{+ \infty} \frac{(-1)^nx^{2n+1}}{(2n+1)!}=-\sin(x)$$ things work out perfectly here obviously but when it comes to the same exercise with $\sin$ however I seem to fail
Example 2 (Here I struggle) $$\sin'(x)= \left(\sum_{n=0}^{+ \infty} \frac{(-1)^n x^{2n+1}}{(2n+1)!} \right)'=\sum_{n=1}^{+ \infty} \frac{(-1)^n(2n+1)x^{2n}}{(2n+1)!}=\sum_{n=1}^{+ \infty} \frac{(-1)^nx^{2n}}{(2n)!}$$ Things look seemingly good so far, but I yet still have to shift the index, I did this above with luck so why not here? $$ \implies \sin'(x)=\sum_{n=0}^{+ \infty} \frac{(-1)^{n+1}x^{2n+2}}{(2n+2)!}=-\sum_{n=0}^{+ \infty} \frac{(-1)^nx^{2n+2}}{(2n+2)!}\neq \cos(x)$$
Questions:
$\bullet$Where is my mistake in the second example? Was my approach in example one only a lucky goal? $\bullet$Why are there so many people not increasing the index when they differentiate a sum? Is this a correct approach and when yes, for which cases?
$\bullet$ What would be the correct, mathematical rigorous approach to solve this problems? Do I always have to define $a_n$ first? i.e. for the second example define $$a_n:=\frac{(-1)^nx^{n+1}}{(2n+1)!}$$ I have tried this method and my result was even worse then before.
In the theorem you have $x^n$, but in the series you have $x^{2n}$ and $x^{2n+1}$. In the theorem you drop the $n=0$ term because that's the constant term (whose derivative is zero); in the case of cosine, the $n=0$ term is again the constant term, so it works out; but in the case of sine it's the $x^1$ term. To apply the theorem very carefully for cosine: let $$ a_n = \begin{cases} (-1)^{n/2}/n! &\text{if $n$ even,} \\ 0 &\text{if $n$ odd.} \end{cases} $$ Then $$ \cos'(x) = \left(\sum_{n=0}^\infty a_n x^n\right)' = \sum_{n=1}^\infty na_n x^{n-1} = \sum_{n=0}^\infty (n+1)a_{n+1} x^n $$ and then note that $$ (n+1)a_{n+1} = \begin{cases} (-1)^{(n+1)/2}/n! &\text{if $n$ odd,} \\ 0 &\text{if $n$ even.} \end{cases} $$