Solution (source code)

= Solution

Put $v=x+x^2$ in the <logarithmic series> $\ln(1+v)=v-v^2/2+v^3/3+O(v^4)$. Since $v^2=x^2+2x^3+O(x^4)$ and $v^3=x^3+O(x^4)$,
$$
\ln(1+x+x^2)=x+x^2-\frac12(x^2+2x^3)+\frac13x^3+O(x^4).
$$
Therefore
$$
\boxed{\ln(1+x+x^2)=x+\frac{x^2}{2}-\frac{2x^3}{3}+O(x^4).}
$$