Question
$$\int \frac{1}{1 + \sec(x/2)} \mathop{dx} $$
I'm not sure how to go about this. I've tried to integrate it, and differentiating to check the answer, but I'm not sure if I've messed up the integration or the differentiation. And using CAS hasn't helped much, as perhaps they're giving it in a different form.
Working
Let $u = x/2,$ then $2 \cdot \mathop{du} = \mathop{dx} $ giving $2 \cdot \int \frac{1}{1 + \sec(u)} \mathop{dx}$.
Rearrange into terms of $\cos$ rather than $\sec$. Then multiply through by $\frac{1 - \cos(u)}{1 - \cos(u)}$.
This gives
\begin{equation*} \begin{aligned} 2 \cdot \int \frac{\cos(u) - \cos^2(u)}{1 - \cos^2(u)} \mathop{du} &= 2 \cdot \int \frac{\cos(u) - \cos^2(u)}{\sin^2 u} \mathop{du} \\ &= 2 \cdot \int \frac{\cos(u) }{\sin^2 u} \mathop{du} + 2 \cdot \int \frac{- \cos^2(u)}{\sin^2 u} \mathop{du} \\ &= 2 \cdot \int \frac{\cos(u) }{\sin^2 u} \mathop{du} + 2 \cdot \int - \cot^2 u \mathop{du} \\ &= 2 \cdot \int \frac{\cos(u) }{\sin^2 u} \mathop{du} + 2 \cdot \int (1 - \csc^2 u) \mathop{du} \\ &= 2 \cdot \int \frac{\cos(u) }{\sin^2 u} \mathop{du} + 2 \cdot \int \mathop{du} + 2 \cdot \int - \csc^2 u \mathop{du} \end{aligned} \end{equation*}
Looking at $2 \cdot \int \frac{\cos(u) }{\sin^2 u} \mathop{du}$, let $k = \sin u$ then $\frac{dk}{\cos u } = du$ and this gives
\begin{equation*} \begin{aligned} 2 \cdot \int \frac{\cos(u) }{\sin^2 u} \mathop{du} &= 2 \cdot \int \frac{\cos(u) }{k^2} \cdot \frac{1}{\cos u} \mathop{dk} \\ &= 2 \cdot \int \frac{ 1}{k^2} \mathop{dk} \\ &= 2 \cdot \int \frac{ 1}{k^2} \mathop{dk} \\ &= - 2 k^{-1} + C_1 \end{aligned} \end{equation*}
The other integrals are standard, giving
\begin{equation*} \begin{aligned} \int \frac{1}{1 + \sec(x/2)} \mathop{dx} &= 2 \cdot \int \frac{\cos(u) }{\sin^2 u} \mathop{du} + 2 \cdot \int \mathop{du} + 2 \cdot \int - \csc^2 u \mathop{du} \\ &= -2k^{-1} + 2 u - 2 \cdot \int \csc^2 u \mathop{du} \\ &= -2k^{-1} + 2 u - 2 \cot(u) + C_2 \end{aligned} \end{equation*}
Then subbing back in for $k,u$
\begin{equation*} \begin{aligned} -2k^{-1} + 2 u - 2 \cot(u) + C_2 &= -(\sin u)^{-1} + 2 u - 2 \cot(u) + C_2 \\ &= -(\sin (x/2))^{-1} + 2 (x/2) - 2 \cot((x/2)) + C_2 \end{aligned} \end{equation*}