Failing a basic integration exercise; where did I go wrong?

(This is a basic calculus exercise gone wrong where I need some feedback to get forward.)

I've attempted to calculate an integral by first integrating it by parts and then by substituting. The result I got is not correct though. Can I get a hint about where started to make mistakes?

Here are my steps:

$$\int \sqrt{x}\cdot\sin\sqrt{x}\,dx$$

  1. Applying integration by parts formula

    $$\int uv' \, dx = uv - \int u'v \, dx$$

    where $u=\sqrt{x}$, $v'=\sin\sqrt{x}$, $u'=\frac{1}{2\sqrt{x}}$ and $v=-\cos\sqrt{x}$, resulting in:

    $$\int \sqrt{x}\cdot\sin\sqrt{x}\,dx = \sqrt{x} \cdot -\cos\sqrt{x} - \int \frac{1}{2\sqrt{x}} \cdot -\cos\sqrt{x} \, dx$$

  2. Next, I tried substituting $x$ with $g(t)=t^2$ in the remaining integral, i. e. replacing each $x$ in the integral with $t^2$ and the ending $dx$ with $g'(t)=2t\,dt$. I would later bring back the $x$ by substituting $t=\sqrt{x}$ after integration. Continuing from where we left by substituting:

    $$\sqrt{x} \cdot -\cos\sqrt{x} - \int \frac{1}{2\sqrt{x}} \cdot -\cos\sqrt{x} \, dx$$ $$\Longrightarrow \sqrt{x} \cdot -\cos\sqrt{x} - \int \frac{1}{2\sqrt{t^2}} \cdot -\cos\sqrt{t^2}\cdot2t \, dt$$

  3. Then I pulled out the constant multipliers from the integral:

    $$\sqrt{x} \cdot -\cos\sqrt{x} - \frac{1}{2} \cdot -1 \cdot 2 \int \frac{1}{\sqrt{t^2}} \cdot \cos\sqrt{t^2}\cdot t \, dt$$

    which turned out to eliminate each other (resulting in just $\cdot1$), so we end up with:

    $$\sqrt{x} \cdot -\cos\sqrt{x} \cdot \int \frac{1}{\sqrt{t^2}} \cdot \cos\sqrt{t^2}\cdot t \, dt$$

  4. Reducing the integrand by reducing $\frac{1}{\sqrt{t^2}}\Rightarrow\frac{1}{t}$, which again is eliminated by multiplying with the integrand's $t$, and reducing $\cos\sqrt{t^2}\Rightarrow\cos t$. Therefore resulting in:

    $$\sqrt{x} \cdot -\cos\sqrt{x} \cdot \int \cos t \, dt$$

    where the integral can be solved as $\int \cos t \, dt = \sin t + C$. So now we are at:

    $$\sqrt{x} \cdot -\cos\sqrt{x} \cdot \sin t + C$$

The correct answer however is $$\int \sqrt{x} \sin\sqrt{x} \, dx = 4 \sqrt{x} \sin\sqrt{x} - 2 (x - 2) \cos\sqrt{x} + C$$

So something somewhere in my process went horribly wrong. What?


Solution 1:

$v'=\sin\sqrt{x}\ $ does not imply $\ v=-\cos\sqrt{x}$.

By the chain rule, $\frac{d}{dx}(-\cos(x^\frac{1}{2})) = \frac12x^{-\frac12} \times \sin\left(x^\frac12\right) \neq \sin\sqrt{x}$.

In fact, to find $v$, which equals $\int \sin\sqrt{x}\ dx$, you have to use a substitution like $u^2 = x.$ Then by integrating by parts, you should get that $v = 2\sin(\sqrt{x}) - 2\sqrt{x}\cos(\sqrt{x}).$

You can continue down this path, but it is a bit ugly, so let's see if there's a simpler overall approach. The original integral is $\int \sqrt{x}\cdot\sin\sqrt{x}\,dx$. It's best to just start with the substitution $u=\sqrt{x}\quad (^*)$.

Then the integral becomes $2\int u^2 \sin(u) du$, which is much nicer to work with. I think you solve this by integrating by parts twice.

$(^*)$ I originally used the substitution $\ x = u^2\ $ but I think this is inaccurate because $\sqrt{u^2} = |u|,\ $ so the integral would actually become $\ 2 \large{\int}$ $u\ |u| \sin(|u|)\ du,\ $ which I'm not sure is correct. Basically the substitution $\ x = u^2\ $ doesn't tell us if $u=\sqrt{x}\ $ or $\ u=-\sqrt{x}.\ $ Using the substitution $\ u=\sqrt{x}\ $ leaves no room for ambiguity.

Solution 2:

The mistake is $$v'=\sin\sqrt{x}\,dx \to v=\int \sin\sqrt{x}\,dx\neq -\cos\sqrt{x}+k, \quad k\in \Bbb R$$

$$\int \sin\sqrt{x}\,dx=2\left(-\sqrt{x}\cos \left(\sqrt{x}\right)+\sin \left(\sqrt{x}\right)\right)+k',\quad k'\in \Bbb R$$