Tricky integral? $\int_0^{\frac{\pi}{2}}\arccos(\sin x)dx$ My answer doesn’t match an online calculator

definite integralsintegrationtrigonometry

I tried to calculate this integral:
$$\int_0^{\frac{\pi}{2}}\arccos(\sin x)dx$$
My result was $\dfrac{{\pi}^2}{8}$, but actually, according to https://www.integral-calculator.com/, the answer is $-\dfrac{{\pi}^2}{8}$.

It doesn't make sense to me as the result of the integration is $$x\arccos\left(\sin x\right)+\dfrac{x^2}{2}+C$$
and after substituting $x$ with $\dfrac{{\pi}}{2}$ and $0$, the result is a positive number.

Can someone explain it? Thanks in advance!

Best Answer

Yes, your result is correct. For $x\in[-1,1]$, $$\arccos(x)=\frac{\pi}{2}-\arcsin(x).$$ Hence $$\int_0^{\pi/2}\arccos(\sin(x))dx= \int_0^{\pi/2}\left(\frac{\pi}{2}-x\right)dx=\int_0^{\pi/2}tdt=\left[\frac{t^2}{2}\right]_0^{\pi/2}=\frac{\pi^2}{8}.$$

P.S. WA gives the correct result. Moreover $t\to \arccos(t)$ is positive in $[-1,1)$ so the given integral has to be POSITIVE!