<s>[INST] how to solve $\int\frac{x^2}{x^2+1}dx$ by using series I want to solve $\int\frac{x^2}{x^2+1}dx$ by using series, but I did something wrong.
Correct solution:
\begin{align*}
\int\frac{x^2}{x^2+1}dx &= \int\frac{(x^2+1)-1}{x^2+1}dx \\
&= \int\left(1-\frac{1}{x^2+1}\right)dx\\
&= x-\arctan(x)+C\\
&= x-\left(x-\frac{x^3}{3}+\frac{x^5}{5}-\frac{x^7}{7}+\frac{x^9}{9}-\frac{x^{12}}{12}+\cdots\right)+C\\
&= C+\frac{x^3}{3}-\frac{x^5}{5}+\frac{x^7}{7}-\frac{x^9}{9}+\frac{x^{12}}{12}-\cdots
\end{align*}
My wrong solution:
\begin{align*}
\int\frac{x^2}{x^2+1}dx &= \int\frac{1}{1+(\frac{1}{x^2})}dx\\
&= \int\frac{1}{1+u}dx\text{ ; }u=\frac{1}{x^2}\\
&= \int\left(1-u+u^2-u^3+u^4-\cdots\right)dx\text{ ; }\frac{1}{x+1}=1-x+x^2-x^3+x^4-\cdots\\
&= \int\left(1-\frac{1}{x^2}+\frac{1}{x^4}-\frac{1}{x^6}+\frac{1}{x^8}-\cdots\right)dx\\
&= C+x+\frac{1}{x}-\frac{1}{3x^3}+\frac{1}{5x^5}-\frac{1}{7x^7}+\cdots\\
\end{align*}
What did I do wrong?
Why didn't I get the correct answer?
 [/INST] Both series are good, but for different domains, Note that when we use this form of binomial expansion:
$$(1+y)^{-1}$$
we require $|y|<1$ and so in the first series it is valid for the domain of the arctan series, whilst the second one is valid for $|x|>1$ which is why there is a difference.

One thing to note is when you integrate make sure it is wrt the correct variable. if you make a substitution $u=f(x)$ you must calculate $du$
</s>