$\int \frac{x^3+2}{(x-1)^2}dx$ In order to integrate 
$$\int \frac{x^3+2}{(x-1)^2}dx$$ 
I did:
$$\frac{x^3+2}{(x-1)^2} = x+2+3\frac{x}{(x-1)^2}\implies$$
$$\int \frac{x^3+2}{(x-1)^2} dx= \int x+2+3\frac{x}{(x-1)^2}dx$$
But I'm having trouble integrating the last part:
$$\int \frac{x}{(x-1)^2}dx$$
Wolfram alpra said me that:
$$\frac{x}{(x-1)^2} = \frac{1}{(x-1)} + \frac{1}{(x-1)^2}$$
How to intuitively think about this partial fraction expansion? I've seen some examples but suddenly these conter intuitive examples opo out and I get confused. I can check that his is true but I couldn't find this expansion by myself
Then:
$$\int \frac{x}{(x-1)^2} dx = \int \frac{1}{(x-1)} + \frac{1}{(x-1)^2}dx = \ln (x-1) + (x-1)^{-1}$$
Then:
$$\int \frac{x^3+2}{(x-1)^2} dx= \int x+2+\frac{x}{(x-1)^2}dx = \frac{x^2}{2} + 2x + 3[\ln(x-1)+(x-1)^{-1}]$$ but wolfram alpha gives another answer. What I did wrong?
 A: First off, you should have gotten
$$\frac{x^3+2}{(x-1)^2}=x+2+\frac{\color{Red}{3}x}{(x-1)^2}.$$
How did you get this anyway? Did you have a process? There is a process for breaking down rational functions into summands of a certain type. You've done some of the work, but you need to go further because this is not the finished partial fraction expansion.
Secondly, the antiderivative of $(x-1)^{-2}$ is $\color{Red}{-}(x-1)^{-1}$.
Given any polynomial $f(x)$ and any complex number $a\in\Bbb C$ we can write $f$ as a polynomial in the variable $x-a$, that is $f(x)=g(x-a)$ for some polynomial $g$. Essentially, this changes the "base" of the polynomial from $x$ to $x-a$, much like we can convert a number from base $10$ to base $2$.
Now, if we start with a rational function $f(x)/(x-a)^n$ (with $\deg f<n$) we may write $f$ as a polynomial in the base $x-a$ as $g(x-a)=c_0+c_1(x-a)+\cdots+c_d(x-a)^d$ and so
$$\frac{f(x)}{(x-a)^n}=\frac{c_0}{(x-a)^n}+\frac{c_1}{(x-a)^{n-1}}+\cdots+\frac{c_d}{(x-a)^{n-d}}.$$
There are two things that can make the situation more complicated: (1) if you're not working over the complex numbers $\Bbb C$, there are going to be irreducible polynomials that are not linear - of the form $x-a$ for some scalar - and then (2) if the rational function you begin with has multiple different irreducible factors present in the full factorization of its denominator.

Let's talk about partial fraction decomposition over the complex numbers. Say we have $f(x)/g(x)$. Without loss of generality we may assume that $\deg f<\deg g$, since otherwise we can invoke polynomial long division. Factor $g(x)=(x-u_1)^{e_1}\cdots(x-u_d)^{e_d}$. Since we know we can expand
$$\frac{1}{(x-u)(x-v)}=\frac{1}{u-v}\left[\frac{1}{x-u}-\frac{1}{x-v}\right],$$
we could use this inductively until we eventually will obtain an expansion of the form 
$$a_1(x)/(x-u_1)^{e_1}+\cdots+a_d(x)/(x-u_d)^{e_d}$$
for some numerators $a_i(x)$. But note that $a_i(x)=b_i(x-u_i)$ for some polynomials $b_i$, so ultimately we should be able to write
$$\begin{array}{rl} \displaystyle\frac{f(x)}{g(x)} = & \displaystyle \frac{a_{1,1}}{x-u_1}+\frac{a_{1,2}}{(x-u_1)^2}+\cdots+\frac{a_{1,e_1}}{(x-u_1)^{e_1}}+\cdots\cdots \\ + & \displaystyle \frac{a_{d,1}}{x-u_d}+\frac{a_{d,2}}{(x-u_d)^2}+\cdots+\frac{a_{d,e_d}}{(x-u_d)^{e_d}} \end{array}$$
A priori one might believe we should also have a polynomial in $x$ in front of the expansion on the right, but this isn't possible because we know that $\deg f<\deg g$.
To find the coefficient of $(x-u_i)^{-k}$ (where $k\le e_i$) you can multiply the above equation by $(x-u_i)^{e_i}$, take the derivative $e_i-k$ times, evaluate at $x=u_i$. Another method is to add all of the terms above using the unknowns, equate numerators and then solve for the unknowns (as they will exist in a linear system of equations).

Here is the general spiel on how and why pfd works. Suppose we have a rational function of the form $f(x)/g(x)$ with $\deg f<\deg g$. Factor $g(x)=\pi_1(x)^{e_1}\cdots\pi_d(x)^{e_d}$. If we want to expand $f/g$ into the "initial" expansion $a_1(x)/\pi_1(x)^{e_1}+\cdots+a_d(x)/\pi_d(x)^{e_d}$ it suffices to be able to do it to $1/g(x)$, since once we do that we can multiply each $a_i(x)$ by $f(x)$.
To compute $a_i(x)$, set $f/g$ equal to this expansion, multiply both sides by $g(x)$, and then reduce "modulo $\pi_i(x)$" to obtain $f(x)\equiv a_i(x)\prod_{j\ne i}\pi_j(x)^{e_j}$ mod $\pi_i(x)$, which can be solved for in $a_i(x)$ since the other irreducible factors are all distinct from $\pi_i(x)$ and hence invertible mod $\pi_i(x)$. It might sound crazy at first that we can reduce polynomials "modulo" other polynomials, just like we do with numbers, but this is indeed possible because we still have Euclidean division.
Anyway, now we know an "initial" expansion of $f/g$ exists, to get the full partial fraction expansion we need to know how to decompose the rational functions of the form $a(x)/\pi(x)^e$ where $\pi$ is irreducible. We can't simply use the same "translation" thing as earlier. What we can do is use the Euclidean division property I just mentioned: write $a(x)=q_0(x)\pi(x)+r_0(x)$, where $q$ is the quotient and $r$ is the remainder (with $\deg r<\deg \pi$). One can continue this process on the $q_i$s, obtaining $a(x)=(q_1(x)\pi(x)+r_1(x))\pi(x)+r_0(x)$, etc. until finally we stop at the "expansion in base $\pi$" given by  $a(x)=r_k(x)\pi(x)^k+\cdots+r_1(x)\pi_1(x)+r_0(x)$. Thus,
$$\frac{a(x)}{\pi(x)^e}=\frac{r_k(x)}{\pi(x)^{e-k}}+\cdots+\frac{r_0(x)}{\pi(x)^e}.$$
A: Your mistake is the partial fraction expansion. It should be $$\frac{x^3+2}{(x-1)^2}=x+2+\frac{3}{x-1}+\frac{3}{(x-1)^2}$$ Then the integral becomes $$x^2/2+2x+3\ln (x-1)-3(x-1)^{-1}$$ 
A: change of variable gets you there faster. let $u = x - 1, x = 1 + u.$  then
$\begin{align}\int\dfrac{x^3 + 2}{(x-1)^2}\,dx  &= \int\frac{(1+u)^3+2}{u^2} \,du\\
&=\int\frac{3+3u+3u^2+u^3}{u^2}\,du\\
& = \int3u^{-2}+3u^{-1}+ 3+u \,du\\
&=-\frac{3}{u} + 3\ln u + 3u + \frac{u^2}{2} +C
\end{align}$
note that this substitution works on any rational function of the form $\dfrac{p(x)}{(ax+b)^k}$ where $p$ is polynomial in $x.$
A: First: search for:
$$
\dfrac{x}{(x-1)^2}=\dfrac{1}{(x-1)^2}+\dfrac{A}{x-1}
$$
and find: 
$$
x=1+Ax-A \iff x(1-A)=1-A
$$since this must be true $\forall x$ you must have $A-1=0$ and $A=1$.
Now integrates as you have done but be careful that you have a mistake in your work:
$$
\int \dfrac{1}{(x-1)^2} dx = - \dfrac{1}{x-1}
$$
A: You can write $\displaystyle\frac{x}{(x-1)^2}=\frac{A}{x-1}+\frac{B}{(x-1)^2}$; then multiply by $(x-1)^2$ to get $x=A(x-1)+B$.
Letting $x=1$ gives $B=1$, and comparing the coefficients of $x$ gives $A=1$.
(Notice that $\displaystyle\int\frac{1}{(x-1)^2}=-\frac{1}{x-1}+C$.)

You could also find $\displaystyle\int\frac{x}{(x-1)^2}$ by letting $u=x-1, x=u+1, dx=du$ to get 
$\hspace{.4 in}\displaystyle\int\frac{u+1}{u^2}du=\int\left(\frac{1}{u}+\frac{1}{u^2}\right) du$, 
or use integration by parts with $u=x, du=dx, dv=(x-1)^{-2}dx, v=-(x-1)^{-1}$ to get
$\;\;-x(x-1)^{-1}+\ln|x-1|+C$
A: Here's a way to find the partial fraction expansion:
\begin{align}
\frac{x}{(x-1)^2} &= \frac{A}{x-1} + \frac{B}{(x-1)^2}\\
(x-1)^2\frac{x}{(x-1)^2} &= (x-1)^2\frac{A}{x-1} + (x-1)^2\frac{B}{(x-1)^2}\\
x &= A(x-1) + B
\end{align}
You can turn this into two linear equations and solve, or you can do the following:


*

*plug in $x = 1$ to get $1 = B$. 

*Take derivatives on both sides to get 


$$
1 = A
$$


*Plug $x = 1$ into this equation (which does nothing, but it's part of a pattern) to get $1 = A$.


In general, you plug in $x = c$ for this kind of equation [polynomial over a power of $x-c$], and for each derivative, and doing so will give you the coefficients one after another. 
Is there an intuition for these partial fraction expansions? Yes, a slight one ...but it'll mostly come after you take Complex Analysis, alas. 

Also: in integrating $1/(x-1)^2$, you have a sign error. 
