I try to calculate $$\sum_{k=0}^n(-1)^kx^{(2k)}.$$
I know that the sum of $q^i$ from $i=0$ to n equals $(q^{(n+1)} -1)/(q-1)$. I think this should help with my problem. From mathematica i know that my sum should equal $(1+(-1)^n x^{(2+2n)})$ divided by $(1+x^2)$ but I don't get there with my calculation.
$$\sum_{k=0}^n(-1)^kx^{(2k)}=\sum_{k=0}^n(-x^2)^k=\frac{1-\left(-x^2\right)^{n+1}}{x^2+1}=\frac{1-\left((-1)^{n+1}x^{2(n+1)} \right)}{x^2+1}=\frac{1+(-1)^n x^{2(n+1)}}{x^2+1}$$