Can't figure out what's wrong with my solution to an indefinite integral I tried integrating $\int{\frac{xdx}{(Ax + B)^n}}$, and my solution was
$$
\int{\frac{xdx}{(Ax + B)^n}} = \frac{1}{A^2}\left[\frac{(Ax + B)^{-n}}{-n} - B\frac{(Ax + B)^{-n + 1}}{-n + 1}\right] + c
$$
which I got by substituting $u = Ax + B$ and then integrating $\frac{1}{A^2}\int{\frac{u-B}{u^n}du} = 1/A^2(\int{\frac{du}{u^{n-1}}} - B\int{\frac{du}{u^n}})$. WolframAlpha gives me a different answer, and I can't determine if the two answers are equivalent (which it doesn't look like they are). Is my answer the same as WolframAlpha's answer? And what algorithm or procedure might WolframAlpha have used to get a solution to this integral?
EDIT: Okay maybe I should post my solution, so that people get an idea of my thought process.
$$
\begin{align}
\int{\frac{xdx}{(Ax + B)^n}} & = \int{\frac{1/A(u - B)}{u^n}\cdot\frac{1}{A}du}, \ u = Ax + B \\
& = \frac{1}{A^2}\left(\int{\frac{udu}{u^n}} - B\int{\frac{du}{u^n}}\right) \\
& = \frac{1}{A^2}\left(\int{\frac{du}{u^{n-1}}} - B\int{\frac{du}{u^n}}\right) \\
& = \frac{1}{A^2}\left(\frac{u^{-n}}{-n} - B\frac{u^{-n+1}}{-n+1}\right) + c \\
& = \frac{1}{A^2}\left(\frac{(Ax + B)^{-n}}{-n} - B\frac{(Ax + B)^{-n+1}}{-n+1}\right) + c
\end{align}
$$
It seems alright to me, but I don't see how
$$
\frac{1}{A^2}\left(\frac{(Ax + B)^{-n}}{-n} - B\frac{(Ax + B)^{-n+1}}{-n+1}\right) = -\frac{(Ax + B)^{-n+1}(A(n-1)x+B)}{A^2(n-2)(n-1)}
$$
where the right hand side is what WolframAlpha is giving. So are the two expressions equivalent?
 A: The step between the two following lines is wrong:
$$\frac{1}{A^2}\left(\int{\frac{du}{u^{n-1}}} - B\int{\frac{du}{u^n}}\right)$$
$$\frac{1}{A^2}\left(\frac{u^{-n}}{-n} - B\frac{u^{-n+1}}{-n+1}\right) + c$$
Actually, $\displaystyle{\frac{1}{u^{n-1}}=u^{-n+1}}$, so when you integrate, you get $\displaystyle{\frac{u^{-n+2}}{-n+2}}$, not $\displaystyle{\frac{u^{-n}}{-n}}$.
A: $$
\begin{align*}
&\frac{1}{A^2}\left(\frac{(Ax+B)^{-n}}{-n}-B\frac{(Ax+B)^{-n+1}}{-n+1}\right)\\
&=\frac{1}{A^2}\left(\frac{(Ax+B)^{-n+1}}{-n(Ax + B)}-B\frac{(Ax+B)^{-n+1}}{-n+1}\right)\\
&=\frac{(Ax+B)^{-n+1}}{A^2}\left(\frac{1}{-n(Ax + B)}-\frac{B}{-n+1}\right)\\
&=-\frac{(Ax+B)^{-n+1}}{A^2}\left(\frac{1}{n(Ax + B)}-\frac{B}{n-1}\right)\\
&=-\frac{(Ax+B)^{-n+1}}{A^2}\frac{n-1-Bn(Ax+B)}{n(n-1)(Ax + B)}\\
&=-\frac{(Ax+B)^{-n}}{A^2}\frac{n-1-Bn(Ax+B)}{n(n-1))}\\
&\neq-\frac{(Ax + B)^{-n+1}(A(n-1)x+B)}{A^2(n-2)(n-1)}
\end{align*}
$$
A: $$\int \frac{x}{(ax+b)^n}dx=\\\frac{1}{a}\int \frac{ax}{(ax+b)^n}dx =\\\frac{1}{a}\int \frac{ax+b-b}{(ax+b)^n}dx =\\\frac{1}{a}\int (\frac{ax+b}{(ax+b)^n}dx +\frac{-b}{(ax+b)^n}dx)=\\\frac{1}{a}\int (\frac{1}{(ax+b)^{n-1}}dx +\frac{-b}{(ax+b)^n}dx)=\\\frac{1}{a}\int ((ax+b)^{-(n-1)}dx -b(ax+b)^{-n}dx)=\\\frac{1}{a}(\frac{(ax+b)^{-(n-1)+1}}{(-(n-1)+1)a}  -b \frac{(ax+b)^{-(n)+1}}{(-(n)+1)a})=\\\frac{1}{a}(\frac{(ax+b)^{-(n-1)+1}}{(-(n-1)+1)a}  -ab \frac{(ax+b)^{-(n)+1}}{(-(n)+1)a^2})=\\now\\factor\\\frac{1}{a^2}\\\frac{1}{a^2}(\frac{(ax+b)^{-(n-1)+1}}{(-(n-1)+1)}  -ab \frac{(ax+b)^{-(n)+1}}{(-(n)+1)})
$$
