- The question is the top integral ,I did substitution of 1+cos ,x+sin2x,sin,cos all of these not works, and I separate them out into two pieces and I am stuck in a new antiderivative :x /(1+cosx)²

\begin{align*} \newcommand{\dx}{\; \mathrm{d}x} \int \frac{x+\sin^2x}{(1+\cos x)^2} \dx &=\int \frac{x+(1-\cos^2x)}{(1+\cos x)^2} \dx \\ &=\int \frac{x}{(1+\cos x)^2} \dx + \int \frac{1-\cos^2x}{(1+\cos x)^2} \dx \\ &=\int \frac{x}{(1+\cos x)^2} \dx + \int \frac{(1-\cos x)(1+\cos x)}{(1+\cos x)^2} \dx \end{align*}
Using integration by parts gives $$ \int \dfrac{x}{(1 + \cos x)^2}dx = xv - \int v dx + C $$ where $v$ is an anti-derivative of $\displaystyle\int \dfrac{1}{(1 + \cos x)^2}dx$ and $C$ is a constant
Notice that, $1 + \cos x = 2\cos^2\left(\dfrac{x}{2}\right)$. Hence $$ \int \dfrac{1}{(1 + \cos x)^2}dx = \int \dfrac{dx}{4\cos^4 \frac{x}{2}} = \dfrac{1}{4}\int \left[1 + \tan^2 \left(\dfrac{x}{2}\right)\right]^2 dx $$ From here, let $t = \tan\left(\dfrac{x}{2}\right)$ and you'll be able to find $v$