7

Question:

Find the following integral: $\int{\sqrt{1+\cos(x)}}dx$

My attempt:

$$\int{\sqrt{1+\cos(x)}}dx$$

$$=\int{\sqrt{2\cos^{2}\frac{x}{2}}}dx$$

$$=\int{\sqrt{2}\ \left|\cos\frac{x}{2}\right|}dx$$

$$=\sqrt{2}\int{\left|\cos\frac{x}{2}\right|}dx\tag4$$

$$=\sqrt{2}\int{\pm\cos\frac{x}{2}}dx$$

$$=\pm\sqrt{2}\int{\cos\frac{x}{2}}dx$$

$$=\pm2\sqrt{2}\sin\frac{x}{2}+C$$

My book's attempt:

$$\int{\sqrt{1+\cos(x)}}dx$$

$$=\int{\sqrt{2\cos^{2}\frac{x}{2}}}dx$$

$$=\int{\sqrt{2}\cos\frac{x}{2}}dx$$

$$=\sqrt{2}\int{\cos\frac{x}{2}}dx$$

$$=2\sqrt{2}\sin\frac{x}{2}+C$$

Basically, my book didn't put $\pm$ sign, while I did. My book did this essentially: $\sqrt{x^2}=x$, while I did this: $\sqrt{x^2}=|x|$. Is my process more correct?

ryang
  • 38,879
  • 14
  • 81
  • 179
  • 5
    You can’t make the simplification $|x|=\pm x$. To see why, plug in $x=1$ to get $1=\pm1$. – David H Jan 24 '22 at 15:37
  • 2
    @trying I removed "evaluation" from the title because to evaluate means to find a numerical expression/ value. – ryang Jan 24 '22 at 16:11
  • 4
    Both are incorrect and so is Wolfram Alpha (https://www.wolframalpha.com/input/?i=antiderivative+of+sqrt%281%2Bcos%28x%29%29 ). The book solution is correct on $[−\pi,\pi]$. Wolfram Alpha is correct on any interval of the form $[(2k−1)\pi,(2k+1)\pi]$ but not across those boundaries. Yours would match Wolfram Alpha if only you can specify where it is $+$ and where it is $-$, depending on $x$. Now, the correct antiderivative will need a lot of care to do correctly for all intervals of $\mathbb R$. If your book doesn't care, perhaps you are not expected to care either. –  Jan 24 '22 at 16:14
  • 1
    I updated my answer to give a solution. If anything is not clear, feel free to ask questions in the comments for clarifications. – Maximal Ideal Jan 24 '22 at 18:13
  • @StinkingBishop "Yours would match Wolfram Alpha if only you can specify where it is + and where it is −, depending on x":

    $$\sqrt{2}\int{|\cos\frac{x}{2}|dx}=\begin{cases} 2\sqrt{2}\sin\frac{x}{2}+C,\ \cos\frac{x}{2}\ge 0 \\ -2\sqrt{2}\sin\frac{x}{2}+C,\ \cos\frac{x}{2}<0 \end{cases}$$

    sir do you mean writing like this?

    – tryingtobeastoic Jan 25 '22 at 05:25
  • 1
    @tryingtobeastoic Yes, that sort of thing, that is what I meant. I think (from a glance, didn't really have a very thorough look) that with $C=0$ all along you get the same (discontinuous) thing as Wolfram Alpha, but by setting a different constant on every interval $[(2k-1)\pi, (2k+1)\pi]$ you may make a continuous antiderivative. –  Jan 25 '22 at 07:36

4 Answers4

6
  1. $(y=|x|)$ is universally equivalent not to $(y=\pm x),$ but to $(y=\pm x \;\;\text{and}\;\; y\ge0),$ so $|x|$ and $\pm x$ are not mutually substitutable.
  2. $$\int_0^{2\pi}{\left|\cos\frac{x}{2}\right|}\,\mathrm dx = 4,$$ but $$\pm\int_0^{2\pi}{\cos\frac{x}{2}}\,\mathrm dx=0= \int_0^{2\pi}{\cos\frac{x}{2}}\,\mathrm dx.$$

The correct way to continue from line $(4)$ is to split up the integral such that each of the integrand's $x$-intercepts is a limit of integration.

ryang
  • 38,879
  • 14
  • 81
  • 179
4

Your solution goes further than the book's solution in terms of correctness. You have two issues. The first is that changing $\left|\cos\frac{x}{2}\right|$ to $\pm\cos\frac{x}{2}$ only creates a loss of information. Moreover, the $\pm$ sign itself depends on that value of $\cos\frac{x}{2}$, so it makes no sense to pull out the $\pm$ sign here, even if you did have it.

Integrating over absolute value signs is tricky. I'll use the definite integral to give an answer to the indefinite integral.

$$ \sqrt{2}\int{\left|\cos\frac{x}{2}\right|}dx = \sqrt{2}\int_{0}^{x}{\left|\cos\frac{u}{2}\right|}du + C $$

In the case of a definite integral, you have to split your domain into intervals on a case by case basis.

Case 1: $x>\pi$. In this case, we have \begin{align} \sqrt{2}\int_{0}^{x}{\left|\cos\frac{u}{2}\right|}du + C &= \sqrt{2}\int_{0}^{\pi} \left|\cos\frac{u}{2}\right| du \\ & \quad+ \left( \sqrt{2}\int_{\pi}^{\pi+2\pi} \left|\cos\frac{u}{2}\right| du + \cdots + \sqrt{2}\int_{\pi+(n-1)2\pi}^{\pi+n2\pi} \left|\cos\frac{u}{2}\right| du \right) \\ & \quad+ \sqrt{2}\int_{\pi+n2\pi}^{x} \left|\cos\frac{u}{2}\right| du + C \qquad\qquad \end{align} where $n = \left\lfloor \dfrac{x-\pi}{2\pi}\right\rfloor$.

We look at the various definite integrals separately. First, note that $\cos\frac{u}{2}$ is nonnegative for all $u\in (0, \pi)$. This means we have $\left|\cos\frac{u}{2}\right| = \cos\frac{u}{2}$ on that interval. Hence $$ \sqrt{2}\int_{0}^{\pi} \left|\cos\frac{u}{2}\right| du = \sqrt{2}\int_{0}^{\pi} \cos\frac{u}{2} du = 2\sqrt{2}. $$

Next, using periodicity of cosine, we can deduce that $$ \sqrt{2}\int_{\pi+(k-1)2\pi}^{\pi+k2\pi} \left|\cos\frac{u}{2}\right| du = \sqrt{2}\int_{-\pi}^{\pi} \cos\frac{u}{2} du = 4\sqrt{2} $$ for each integer $k$.

Lastly, we need to do the last integral, which is going to give us a function of $x$. Again, using properties of cosine, we can deduce that \begin{align} \sqrt{2}\int_{\pi+n2\pi}^{x} \left|\cos\frac{u}{2}\right| du &= \sqrt{2}\int_{-\pi}^{x - 2(n+1)\pi} \cos\frac{u}{2} du = \sqrt{2}\cdot 2\sin\left(\frac{u}{2}\right) \Big|_{-\pi}^{x-(n+1)2\pi} \\ &= 2\sqrt{2} \left[ \sin\left(\frac{x-(n+1)2\pi}{2}\right) - \sin\left(-\frac{\pi}{2}\right) \right] \\ &= 2\sqrt{2} \left[ \sin\left(\frac{x}{2}-(n+1)\pi\right) - (-1) \right] \\ &= 2\sqrt{2} \left[ \sin\left(\frac{x}{2}\right)\cos(-(n+1)\pi) + \sin(-(n+1)\pi)\cos\left(\frac{x}{2}\right) + 1 \right] \\ &= 2\sqrt{2} \left[ \sin\left(\frac{x}{2}\right)(-1)^{n+1} + 0 + 1 \right] \\ &= 2\sqrt{2} \left[ 1 + (-1)^{n+1}\sin\left(\frac{x}{2}\right) \right] \end{align}

Going all the way back to the beginning of Case 1, and putting this all together, we have \begin{align} \sqrt{2}\int_{0}^{x}{\left|\cos\frac{u}{2}\right|}du + C &= 2\sqrt{2} + \underbrace{(4\sqrt{2} + \cdots + 4\sqrt{2})}_{n\text{ terms}} + 2\sqrt{2}[1 + (-1)^{n+1}\sin\left(\frac{x}{2}\right)] + C \\[1.2ex] &= 2\sqrt{2} + n(4\sqrt{2}) + 2\sqrt{2} + 2\sqrt{2}(-1)^{n+1}\sin\left(\frac{x}{2}\right) + C \\[1.6ex] &= (n+1)\cdot 4\sqrt{2} + 2\sqrt{2}(-1)^{n+1}\sin\left(\frac{x}{2}\right) + C \end{align} Thus, for $x > \pi$ we have $$ \sqrt{2}\int{\left|\cos\frac{x}{2}\right|}dx = 4\sqrt{2}(n+1) + 2\sqrt{2}(-1)^{n+1}\sin\left(\frac{x}{2}\right) + C $$ where $n = \left\lfloor \dfrac{x-\pi}{2\pi}\right\rfloor$.

The solution might look weird, but when I graph it in desmos for $C=0$ I get a continuous function.

Cases for $0\le x\le \pi$, $-\pi\le x<0$, and $x<-\pi$ are similar. I'll leave these other cases to you :)

The reason why we have all these cases and the reason why we need to split our definite integral over various intervals is because the absolute value function is actually a piecewise function that is itself handled by cases.

  • Sir, if I wrote the integral like this:

    $$\sqrt{2}\int{|\cos\frac{x}{2}|dx}=\begin{cases} 2\sqrt{2}\sin\frac{x}{2}+C,\ \cos\frac{x}{2}\ge 0 \\ -2\sqrt{2}\sin\frac{x}{2}+C,\ \cos\frac{x}{2}<0 \end{cases}$$

    will it be correct?

    – tryingtobeastoic Jan 25 '22 at 05:23
  • @tryingtobeastoic The right-hand side would be discontinuous for a fixed $C$, so this would not be correct. – Maximal Ideal Jan 25 '22 at 05:28
1

Before a radical sign imho...

the non inclusion of $\pm$ in the last step is a convention. It is assumed that it is understood by implication , so not so necessary even to mention.

This practice is annoying when integral evaluations are done..

Omission of sign in differential equation is a misleading step that needs to be altogether avoided.

Your procedure is more correct.If you graph them they are seen as reflections on either side of x-axis, each in its own right, so to say.

Narasimham
  • 40,495
0

Note that $\sqrt{t^2}=\text{sgn}(t)\cdot t$. Then, piecewise integrate

\begin{align} \int\sqrt{1+\cos x}\>dx= &\>\sqrt2\int\sqrt{\cos^2\frac x2}\>dx =\>\sqrt2 \>\text{sgn}(\cos \frac x2)\int\cos \frac x2 \>dx\\ = &\>2\frac{ \sqrt{2\cos^2\frac x2}}{\cos \frac x2}\sin \frac x2 =\>2\sqrt{1+\cos x}\>\tan \frac x2 \end{align} A global ante-derivative can be concatenated as $$ \int\sqrt{1+\cos x}\>dx= 2\sqrt{1+\cos x}\>\tan \frac x2 +4\sqrt2\lfloor \frac {x+\pi}{2\pi}\rfloor $$

Quanto
  • 97,352
  • Isnt $\text{sgn}(\cos\frac x2)$ a function of $x$? How did you pull it out of the integral? – DatBoi Jan 24 '22 at 16:45
  • Interesting solution. There's a $+C$ missing. Moreover, I'm not sure how to make sense of the fact that this solution is discontinuous at $\pm\pi, \pm 3\pi, \pm 5\pi, \ldots$. – Maximal Ideal Jan 24 '22 at 16:47
  • @MaximalIdeal even WA gives the same answer, but its incorrect as noted by StinkingBishop in the comments – DatBoi Jan 24 '22 at 16:49
  • @DatBoi Right. I suspect that you need to add some sort of step function term to fix this solution (basically the way my answer would have after simplifying). – Maximal Ideal Jan 24 '22 at 16:58
  • 1
    @DatBoi - $\text{sgn}(\cos \frac x2)$ is a constant within each subdomain, so it can be pulled out. – Quanto Jan 24 '22 at 17:00
  • Right, thats exactly why you can pull it out only in certain domains as StinkingBishop noted so that it yields the ccrrect answer. You cannot simply pull it out of an indefinite integral, can you? – DatBoi Jan 24 '22 at 17:13
  • @DatBoi - the integrand $\sqrt{1+\cos x}$ is only continuous within each of its subdomains and thus integrated accordingly. – Quanto Jan 24 '22 at 17:21
  • @Quanto "the integrand √(1+cosx) is only continuous within each of its subdomains and thus integrated accordingly." No, no, it is continuous everywhere on $\mathbb{R}$. It might not be differentiable, but that's besides the point. There's only one domain, which is the entire real line. – Maximal Ideal Jan 24 '22 at 17:27
  • @MaximalIdeal - I meant differentiable, misused continuous – Quanto Jan 24 '22 at 17:32
  • Differentiability is not a problem; the domain of your integrand is still all of $\mathbb{R}$. See my solution + my graph of the solution that adjusts for continuity correctly. – Maximal Ideal Jan 24 '22 at 18:09
  • @MaximalIdeal I actually fail to see the problem, since the discontinuities are removable. The answer is correct. – Angel Jan 24 '22 at 20:16
  • @Angel If I said that the indefinite integral of $x^{2}$ is $$\int x^{2} , dx = \begin{cases} x^{3}/3 + 10 + C &\text{ if }x>0, \ x^{3}/3 - 10 + C &\text{ if } x\le 0. \end{cases} $$ The answer would be incorrect. It's the same deal with this answer. – Maximal Ideal Jan 24 '22 at 20:29
  • @MaximalIdeal I have no clue what makes you think that is analogous in any way to the answer we are replying to. It is not. – Angel Jan 24 '22 at 20:32
  • 1
    @Angel Sorry, I didn't read your initial comment carefully enough. That was dumb of me. Nonetheless, the discontinuities are not removable! See any plot of Quanto's solution in desmos or wolframalpha. You are mistaken in that regard. – Maximal Ideal Jan 24 '22 at 20:36
  • 1
    @MaximalIdeal Yes, that is correct, I made a mistake as well. – Angel Jan 24 '22 at 20:49