Sum $1+(1+x)^2+(1+x+x^2)^2+\cdots+(1+x+x^2+\cdots+x^{N-2})^2 $ Is there a way to find the sum the following series:
$$1+(1+x)^2+(1+x+x^2)^2+\cdots+(1+x+x^2+\cdots+x^{N-2})^2 \text{ ?}$$
Any ideas ? Perhaps someone knows already the result..
Thank you in advance for your time.
 A: $$
1+(1+x)^2+(1+x+x^2)^2+\cdots+(1+x+x^2+...+x^{N-2})^2 = \sum_{i=0}^{N-2}(1+x+\cdots + x^i)^2$$
Let $x<1$, though same can be repeated for $x>1$ - we do not consider $x=1$ since the answer is straightforward in this case
$$\sum_{i=0}^{N-2}(1+x+\cdots + x^i)^2 = \sum_{i=0}^{N-2}\left(\frac{1-x^{i+1}}{1-x}\right)^2 = \frac{1}{(1-x)^2}\sum_{i=0}^{N-2}(1+(x^{i+1})^2-2x^{i+1}).$$
Thus, we have 
$$\sum_{i=0}^{N-2}(1+x+\cdots + x^i)^2 =  \frac{1}{(1-x)^2}(N-1+\sum_{i=0}^{N-2}(x^{i+1})^2-2\sum_{i=0}^{N-2}x^{i+1}).$$
Thus, the answer is 
$$\frac{1}{(1-x)^2}\left(N-1+\frac{1-x^{(2(N-1)})}{1-x^2}-2\frac{1-x^{N-1}}{1-x}\right)$$
For $x=1$, this is sum of $i^2$ from 1 to $N-1$, which is $(N-1)(N)(2N-1)/6$.
For $x>1$, it will be the same expression as for $x<1$.
A: Hint: Let $S$ be your series, and consider $(1-x)^2 S$. What happens to each term when you distribute and simplify?
A: Expanding on @AndréNicolas and @Vaneet, with little computation:
For convenience, we consider the sum until $n-1$ instead of $n-2$, and observe that we have a sum of squares of the partial sums of a geometric progression.
The denominators are all the same and we factor them out. The numerators are the differences $1-x^k$. By squaring, we will get terms $1$, $-2x^k$ and $x^{2k}$ for which the sums are easy.
Then the total is
$$\frac1{(1-x)^2}\left(n-2\frac{1-x^n}{1-x}+\frac{1-x^{2n}}{1-x^2}\right).$$
