Having fun integral $\int_0^{\pi/4} \cos x \arctan(\cos x)\, dx$

Integrate by parts $$\int\cos x\arctan(\cos x)dx$$

$$=\arctan(\cos x)\int\cos x\ dx-\int\left(\frac{d[\arctan(\cos x)]}{dx}\int\cos x\ dx\right)dx$$

$$=\arctan(\cos x)\sin x-\int\left(\frac{-\sin x}{1+\cos^2x}\cdot\sin x\right)dx$$

Now, $$\int\frac{\sin^2x}{1+\cos^2x}dx=\int\frac{2-(1+\cos^2x)}{1+\cos^2x}dx$$

$$=2\int\frac{dx}{1+\cos^2x}-\int dx$$

$$=2\int\frac{\sec^2x\ dx}{2+\tan^2x}-x$$


Integrate by parts: $$\int cos(x)arctan(cos(x))dx=sin(x)arctan(cos(x))+\int\frac{sin^2(x)}{1+cos^2(x)}dx$$

Rewrite: $$\int cos(x)arctan(cos(x))dx=sin(x)arctan(cos(x))+\int\frac{2}{1+cos^2(x)}dx-x$$

To obtain this integral, we differentiate $arctan(\alpha tan(x))$, which results in $\frac{\alpha}{cos^2(x)+(\alpha sin(x))^2}$.

So we get: $$\int \frac{\frac{1}{2}\sqrt{2}}{cos^2(x)+\frac{1}{2}sin^2(x)}dx=arctan\left(\frac{1}{2}\sqrt{2}tan(x)\right)$$

Indefinite integral: $$\int cos(x)arctan(cos(x))dx=sin(x)arctan(cos(x))+\sqrt{2}arctan(\frac{1}{2}\sqrt{2}tan(x))-x$$

Plugging in the boundaries is left as an exercise to the reader.