Consider the continuous distribution with density function $$ p(x) = \frac{1}{2}\cos(x) \;, \quad -\frac{\pi}{2} < x < \frac{\pi}{2}. $$
I want to derive the cumulative distribution function for this density function. In other examples I've seen, this is usually done by taking the anti-derivate of the density function which (in the examples that I've seen) leads to a valid CDF.
However, it seems that following the same approach for this example yields an invalid CDF, $$ \begin{cases} \: -0.5 , \quad \quad x \leq \frac{-\pi}{2} \\ \frac{1}{2}\sin(x), \: \: -\frac{\pi}{2} < x < \frac{\pi}{2} \\ \: \: \: 0.5, \quad \quad x \geq \frac{\pi}{2} \end{cases} $$ and that it somehow needs rescaling. What am I doing wrong here, and how does one go about finding the CDF for this density function?