# On the integral $\int\sqrt{1+\cos x}\text{d} x$

I've been wondering about the following integral recently: $$I = \int\sqrt{1+\cos x}\,\text{d}x$$ The way I integrated it is I used the identity $\sqrt{1+\cos x} = \sqrt2\cos\frac x2$, and so $$I = 2\sqrt2\sin\frac x2 + C$$

the problem is that $\sqrt{1+\cos x}$ is actually integrable over the entire real line, but the derivative of $2\sqrt2\sin\frac x2$ is only equal to $\sqrt{1+\cos x}$ in certain intervals. This is because the actual identity is $\sqrt{1+\cos x} = \sqrt2\left|\cos\frac x2\right|$. Now, I wasn't exactly sure how to integrate the absolute value, so I thought I would "fix" the function after integration.

The first fix we can do is making sure that the sign of the result of integration is correct: $$I = 2\sqrt2\sin\frac x2\text{sgn}\cos\frac x2 + C$$ The problem with just $\sin\frac x2$ was that sometimes it was "flipped", on certain intervals it was actually the antiderivative of the $-\sqrt{1+\cos x}$ (this is because we dropped the absolute value signs).

There is one further problem with this, however. The above function is not continuous, meaning it's not continuously differentiable with derivative equal to $\sqrt{1+\cos x}$ everywhere. Namely, it is discontinuous at $x=(4n\pm1)\pi$ where $n\in\mathbb{Z}$.

I noticed, however, that the limit of the derivative on either side of $x=(4n\pm1)\pi$ existed and was equal to each other. Hence, I figured that I could somehow "stitch" these continuous sections end to end and get a continuous result whose derivative was $\sqrt{1+\cos x}$ everywhere. The resulting function I got was $$I = 2\sqrt2\sin\frac x2\text{sgn}\cos\frac x2 + 4\sqrt2\left\lfloor\frac1{2\pi}x+\frac12\right\rfloor + C$$

Now, I was wondering, is there any way to arrive at this result just by integrating $\sqrt{1+\cos x}$ using the usual techniques? The method I used can be boiled down to "integrating" then "fixing", but I'm just wondering if you can arrive at a result that is continuous and differentiable on the entire real line by doing just the "integrating" part.

Any help would be appreciated. Thanks!

Edit: To be clear, I'm not looking for exactly the function above, but rather simply any function that is "nice", continuous and differentiable on $\mathbb{R}$, and has derivative equal to $\sqrt{1+\cos x}$ everywhere, and which is attainable through "simple" integration methods.

• not at that particular result, but probably similar things – Simply Beautiful Art Jan 27 '17 at 23:26
• @SimplyBeautifulArt True, I'll update the question. I'm not looking for my specific result, but simply any "nice" result that satisfies the requirements. – user3002473 Jan 27 '17 at 23:26
• NB: $\sqrt{1+\cos x}\ne\sqrt2\cos\frac x2$; rather, $\sqrt{1+\cos x}=\sqrt2\left|\cos\frac x2\right|$. For example, if $x=\frac{4\pi}3$, $\sqrt{1+\cos x}=\frac1{\sqrt2}$ whereas $\sqrt2\cos\frac x2=-\frac1{\sqrt2}$. – George Law Jan 27 '17 at 23:36
• @GeorgeLaw Read the whole post please – Simply Beautiful Art Jan 27 '17 at 23:37
• My two cents: Equation $\sqrt{1+\cos x} = \sqrt2\left|\cos\frac x2\right|$ is NOT CORRECT for complex numbers, and should be banned from use. – GEdgar Jan 28 '17 at 0:01

The function to be integrated is $$\sqrt{1+\cos x}=\sqrt{2}\left|\cos\frac{x}{2}\right|$$ so we can as well consider the simpler $$\int\lvert\cos t\rvert\,dt$$ or, with $t=u+\pi/2$, the even simpler $$\int|\sin u|\,du$$ One antiderivative is $$\int_0^u\lvert\sin v\rvert\,dv$$ Note that the function has period $\pi$, so let $u=k\pi+u_0$, with $0\le u_0<\pi$. Then $$\int_0^u\lvert\sin v\rvert\,dv= \int_0^{k\pi}\lvert\sin v\rvert\,dv+ \int_{k\pi}^{k\pi+u_0}\lvert\sin v\rvert\,dv \\=2k+\int_0^{u_0}\sin v\,dv= 2k+1-\cos(u-k\pi)$$ Now do the back substitution; write $k=u\bmod\pi$, if you prefer.
Probably not what you intended, but it follows geometrically due to the period of $\cos$ that
$$\int_0^x\sqrt{1+\cos(t)}\ dt=(x\text{ mod }2\pi)\int_0^{2\pi}\sqrt{1+\cos(t)}\ dt+\int_0^{(x\text{ mod }2\pi)}\sqrt{1+\cos(t)}\ dt$$
That is, we really only need to take the integral for $x\in[0,2\pi)$ and we're set. To do this, let $t=\arccos(u)$ with $x\in[0,2\pi)$.
\begin{align}\int_0^x\sqrt{1+\cos(t)}\ dt&=-\int_1^{\cos(x)}\sqrt{\frac{1+u}{1-u^2}}\ du\\&=\int_{\arccos(x)}^1\frac1{\sqrt{1-u}}\ du\\&=\left.-2\sqrt{1-u}\vphantom{\frac11}\right|_{\cos(x)}^1\\&=2\sqrt{1-\cos(x)}\end{align}
which reduces to yours via trig identities. The extension to $x\ge2\pi$ via modular operations is also continuous, and the derivative is always $\sqrt{1+\cos(t)}$.