4. Calculate $\int \frac{\sin 2 x-\operatorname{tg}^{2} x}{e^{\operatorname{tg} x}+\sin ^{2} x} d x, x \in\left(\frac{\pi}{24}, \frac{\pi}{3}\right)$.

Narcis Gabriel Turcu, Brăila
Solution.

$$
\begin{aligned}
& f:\left(\frac{\pi}{24}, \frac{\pi}{3}\right) \rightarrow \mathbb{R}, f(x)=e^{\tan x}+\sin ^{2} x \\
& f^{\prime}(x)=\frac{e^{\tan x}}{\cos ^{2} x}+\sin 2 x \\
& f^{\prime}(x)-\frac{f(x)}{\cos ^{2} x}=\sin 2 x-\tan ^{2} x \\
& \int \frac{\sin 2 x-\tan ^{2} x}{e^{\tan x}+\sin ^{2} x} d x=\int \frac{f^{\prime}(x)-\frac{f(x)}{\cos ^{2} x}}{f(x)} d x=\int\left(\frac{f^{\prime}(x)}{f(x)}-\frac{1}{\cos ^{2} x}\right) d x=\ln \left(e^{\tan x}+\sin ^{2} x\right)-\tan x+C
\end{aligned}
$$