$\int \frac{\left(2x^3-4x^2-x-3\right)}{\left(x^2-2x-3\right)}dx$ confusion $$\int \frac{\left(2x^3-4x^2-x-3\right)}{\left(x^2-2x-3\right)}dx$$
=$$x^2+3\ln \left(x-3\right)+2\ln \left(x+1\right)+C$$
Where did the $x^2$ come from?
What I did: 
Partial fraction then integrate, got the answer without $x^2$ term.

Hint. It comes from the partial fraction decomposition, you have
$$
\frac{2x^3-4x^2-x-3}{x^2-2x-3}=2x+\frac2{x+1}-\frac3{x-3} \tag1
$$ giving
$$
\begin{align}
\int\frac{2x^3-4x^2-x-3}{x^2-2x-3}dx&=\int 2xdx+\int\frac2{x+1}dx-\int\frac3{x-3}dx\\\\
&=\color{red}{x^2}+\int\frac2{x+1}dx-\int\frac3{x-3}dx\\\\
&=\color{red}{x^2}+2 \ln|x+1|-3 \ln|x-3|+C.
\end{align}
$$
