Maclaurin expansion of $y=\frac{1+x+x^2}{1-x+x^2}$ to $x^4$ 
Maclaurin expansion of $$\displaystyle y=\frac{1+x+x^2}{1-x+x^2}\,\,\text{to } x^4$$

I have tried by using Maclaurin expansion of $\frac1{1-x}=1+x+x^2+\cdots +x^n+o(x^n)$, but it seems not lead me to anything.
 A: Hint: notice that
$$y(x) = \frac{1+x}{1-x}\cdot\frac{1-x^3}{1+x^3}\tag{1}$$
and that:
$$ \frac{1+x}{1-x}=1+2x+2x^2+2x^3+\ldots,\tag{2}$$
from which:
$$ \frac{1-x^3}{1+x^3}=1-2x^3+2x^6-2x^9+2x^{12}-\ldots\tag{3}$$
Are you able to multiply $(2)$ and $(3)$ and prove that:
$$ y(x) = 1 + \left(2x+2x^2\right) - \left(2x^4+2x^5\right)+ \left(2x^7+2x^8\right)-\ldots \tag{4}$$
?
A: Hint: First multiply top and bottom by $1+x$. Then you can work with the series expansion of $\frac{1}{1+x^3}$, using $\frac{1}{1-t}=1+t+t^2+\cdots$. You will not need many terms!
A: Hint: Expand the fraction with $(x+1)$
$$y=\frac{(1+x+x^2)(x+1)}{(x+1)(1-x+x^2)}=\frac{(1+x+x^2)(x+1)}{1+x^3}$$
Now use the geometric series you wrote down for $$\frac{1}{1-(-x^3)}$$
$$y=(1+x+x^2)(x+1)(1+(-x^3)+O(x^6))$$
A: Observe $$(x+1)(x^2 - x + 1) = x^3 + 1,$$ so that $$f(x) = \frac{x^2+x+1}{x^2-x+1} = 1 + \frac{2x}{x^2-x+1} = 1 + \frac{2x(x+1)}{x^3+1}.$$  Then consider the geometric series expansion $$\frac{1}{1 - (-x^3)} = 1 + (-x^3) + (-x^3)^2 + (-x^3)^3 + \cdots = 1 - x^3 + x^6 - x^9 + \cdots, \quad |x| < 1.$$  The result is now straightforward.
A: The sortest way is division of numerator by the denominator along the increasing powers of $x$:

This division tell us that
\begin{align*}1+x+x^2&=(1-x+x^2)(1+2x+2x^2-2x^4)+x^5(-2+2x)\\
\text{so that}\quad\frac{1+x+x^2}{1-x+x^2}&=1+2x+2x^2-2x^4+\frac{x^5(-2+2x)}{1-x+x^2}\\&=1+2x+2x^2-2x^4+O(x^5).\end{align*}
