<s>[INST] 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?
 [/INST] $$
\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*}
$$
</s>