I'm asked to find a geometric series for $f(x) = \frac{1}{(1 + x)^2}$, I integrate it first and I get $F(x) = \int{\frac{1}{(1 + x)^2}dx} = \frac{1}{-2(1 - (-x))}$
Since $\frac1{1-x} = \sum_{n=0}^\infty x^n$, $F(x) = \frac{-1}2\sum_{n=0}^\infty (-x)^n = \sum_{n=0}^\infty \frac{(-1)^{n+1}}{2}x^n$
If I derive that, $f(x) = \sum_{n=0}^\infty\frac{(-1)^{n+1} n x^{n-1}}{2} = \sum_{n=1}^\infty\frac{(-1)^n (n + 1) x^n}{2}$
But my textbook says that $f(x) = \sum_{n=0}^\infty (-1)^n (n + 1) x^n$
Obviously those 2 things are pretty different (notice the index). What did I get wrong?
Original question:
As you wrote, $$\frac{1}{1-y} = \displaystyle\sum_{n=0}^\infty y^n$$
Substituting $y=-x^2$, we have
$$f(x)= \frac{1}{1+x^2} = \displaystyle\sum_{n=0}^\infty (-1)^n x^{2n}$$
Edited question:
Recall that $$(1+x)^2 = 1+2x+x^2$$
As you wrote, $$\frac{1}{1-y} = \displaystyle\sum_{n=0}^\infty y^n$$
Substituting $y=-2x-x^2$, we have
$$g(x)= \frac{1}{\left(1+x\right)^2}=\frac{1}{1-\left(-2x-x^2\right)} = \displaystyle\sum_{n=0}^\infty (-1)^n \left(2x+x^2\right)^n$$