(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?

  • $\begingroup$ Welcome to the MSE. $\endgroup$
    – Sebastiano
    Jan 21, 2021 at 21:53
  • 6
    $\begingroup$ Upvoted because excellent use of MathJax for a first-time user, and lots of effort has gone into answering the question. Other first-time users- take note! $\endgroup$ Jan 21, 2021 at 21:57
  • $\begingroup$ @AdamRubinson Approved also by me :-)..I am an user of TeX.SE. $\endgroup$
    – Sebastiano
    Jan 21, 2021 at 22:00

3 Answers 3


$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.

  • $\begingroup$ I am very much concise :-( +1. $\endgroup$
    – Sebastiano
    Jan 21, 2021 at 22:08
  • 1
    $\begingroup$ Your answer was first and is more concise, but that doesn't automatically make it the best answer... Let the OP decide... $\endgroup$ Jan 21, 2021 at 22:10
  • $\begingroup$ Naturally but I am not interesting to have the upvotes :-) but upvoted the other users. Thus I am happy. $\endgroup$
    – Sebastiano
    Jan 21, 2021 at 22:12
  • 4
    $\begingroup$ I am selfish and want the upvotes. At least you can say I am honest about it though ;) $\endgroup$ Jan 21, 2021 at 22:17
  • 1
    $\begingroup$ Ha thanks! Much appreciated $\endgroup$ Jan 21, 2021 at 22:25

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$$


After the substitution $u = \sqrt{x}$, the integral becomes $2\int u^2 \sin(u) \ du$ as Adam Rubinson has said. We can proceed using tabular integration:

$$\begin{array}{c|c} u^2 & \sin(u) \\ \hline 2u & -\cos(u) \\ \hline \ 2 & -\sin(u) \\ \hline \ 0 & \cos(u)\end{array}$$

where we differentiate on the left and integrate on the right, and multiply the terms diagonally (the signs alternate).

Hence $2\int u^2 \sin(u) \ du = 2 \left(-u^2 \cos(u) - -2u \sin(u) + 2\cos(u) \right) + C$, which is:

$$2 \left( -x \cos( \sqrt x )+2\sqrt x \sin(\sqrt x) + 2\cos(\sqrt x)\right)+C = 4 \sqrt{x} \sin(\sqrt x) - 2(x-2)\cos (\sqrt x) +C$$


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.