I need help to evaluate the integral of $$\int \frac{x^2}{{(a + bx)}^2} \, \mathrm{d}x$$ Here is my approach so far:
Let $x = \frac{a}{b}\sin(t)$ so $\mathrm{d}x = \frac{a}{b}\cos(t) \, \mathrm{d}t$
Therefore, $$ \int \frac{x^2}{{(a + bx)}^2} \, \mathrm{d}x =\frac{a}{b^3}\int \frac{\sin^2 t}{(1+\sin t)^2} \, \mathrm{d}t$$ Let $u = \sin t$ so $\mathrm{d}u = \cos t \, \mathrm{d}t$ and $$\begin{align*} &\frac{a}{b^3}\int \frac{\sin^2 t}{(1+\sin t)^2} \, \mathrm{d}t\\ &=\frac{a}{b^3}\int \frac{u^2}{(1+u)^2} \, \mathrm{d}u\\ &=\frac{a}{b^3}\left(-2\log|u+1| - \frac{1}{1+u} + u\right)\\ &=\frac{a}{b^3}\left(-2\log|\sin t+1| - \frac{1}{1+\sin t} + \sin t\right)\\ &=\frac{a}{b^3}\left(-2\log\left|1+\frac{bx}{a}\right| - \frac{a}{a+bx} + \frac{bx}{a}\right)\\ &=\frac{a}{b^3}\left(-2\log\left|\frac{a+bx}{a}\right| - \frac{a}{a+bx} + \frac{bx}{a} \right) \end{align*}$$ But $$\frac{1}{b^3} \left[(a+bx) - 2a\log(a+bx) - \frac{a^2}{a+bx} \right] $$ is the given answer.
Can you show me where I made a mistake? If you can, show a different, faster way of solving this integral. Thank you for your help.
One mistake arises here: $$\newcommand{\dd}{\mathrm{d}} \int \frac{x^2}{{(a + bx)}^2} \, \dd x =\frac{a}{b^3}\int \frac{\sin^2 t}{(1+\sin t)^2} \, \dd t$$ Do this calculation more carefully: $$ \int \frac{ \frac{a^2}{b^2} \sin^2 t}{\left( a + b \frac a b \sin t\right)^2 } \, \frac a b \cos t \, \dd t $$ Notice that you forgot the $\cos(t)$ tied to the differential. Factoring out carefully, we get $$ \int \frac{ \frac{a^2}{b^2} \sin^2 t}{\left( a + b \frac a b \sin t\right)^2 } \, \frac a b \cos t \,\dd t = \frac{a^2}{b^2} \frac a b \frac{1}{a^2} \int \frac{ \sin^2 t \cos t}{\left( 1 + \sin t\right)^2 } \,\dd t = \frac{a}{b^3} \int \frac{ \sin^2 t \cos t}{\left( 1 + \sin t\right)^2 } \, \dd t $$ Later on, you end up doing a substitution that yields $\cos(t) \, \dd t = \dd u$, which happens to negate your mistake, but this is purely dumb luck in this case. Be more mindful of replacing the differential in the future.
Technically speaking you should also include a constant of integration, this being an indefinite integral, but this is a minor oversight.
Your answer is ultimately equivalent to the claimed answer: any two "correct answers" to an indefinite integral will differ by a constant value, as per the mean value theorem. You can see this in their Desmos graphs:
Your solution in red has the added benefit of being slightly more general and correct, even, since the logarithm should be in absolute values.
To see the equivalence, first notice: $$\begin{align*} &\frac{1}{b^3} \left[(a+bx) - 2a\log(a+bx) - \frac{a^2}{a+bx} \right] \\ &= \frac{a}{b^3} \left[ 1+\frac b a x - 2\log(a+bx) - \frac{a}{a+bx} \right]\\ &= \frac{a}{b^3} \left[ \frac b a x - 2\log(a+bx) - \frac{a}{a+bx} \right] + \frac{a}{b^3}\\ &= \frac{a}{b^3} \left[ \frac b a x - 2 \left( \log(a+bx) - \log(a) \right) - \frac{a}{a+bx} \right] + \frac{a}{b^3} - \frac{2a}{b^3} \log(a) \\ &= \frac{a}{b^3} \left[ \frac b a x - 2 \log \left( \frac{a+bx}{a} \right) - \frac{a}{a+bx} \right] + \underbrace{\frac{a}{b^3} - \frac{2a}{b^3} \log(a)}_{\text{constant!}} \end{align*} $$ The key steps involved are:
Once one actually accounts for the absolute values, you thus see an entirely-equivalent answer.
To elaborate on another comment: notice that the composition of your substitutions ultimately amounts to letting $$ x = \frac a b w $$ Notice that that's what happens if you apply your substitutions in sequence: $$ x \xrightarrow{x = \frac a b \sin t} \frac a b \sin t \xrightarrow{u = \sin t} \frac a b u $$ Doing this at the outset would give you $$ \frac{a}{b^3} \int \frac{u^2}{ \left( 1 + u \right)^2} \, \dd u $$ with comparatively minimal effort.