386. A random variable $X$ is uniformly distributed in the interval $(0,2 \pi)$. Find the density function $g(y)$ of the random variable $Y=\cos X$.
Solution. Let's find the density function $f(x)$ of the random variable $X$: in the interval $(0, 2\pi)$ we have

$$
f(x)=1/(2\pi-0)=1/2\pi
$$

outside this interval, $f(x)=0$.

From the equation $y=\cos x$, let's find the inverse function $x=\psi(y)$. Since the function $y=\cos x$ is not monotonic in the interval $(0, 2\pi)$, we will divide this interval into intervals $(0, \pi)$ and $(\pi, 2\pi)$, in which this function is monotonic (see Fig. 8). In the interval $(0, \pi)$, the inverse function is $\psi_{1}(y)=\arccos y$; in the interval $(\pi, 2\pi)$, the inverse function is $\psi_{2}(y)=-\arccos y$. The desired density function can be found from the equation

$$
g(y)=f\left[\psi_{1}(y)\right] \cdot\left|\psi_{1}^{\prime}(y)\right|+f\left[\psi_{2}(y)\right] \cdot\left|\psi_{2}^{\prime}(y)\right|
$$

Let's find the derivatives of the inverse functions:

$\psi_{1}^{\prime}(y)=(\arccos y)^{\prime}=-1 / \sqrt{1-y^{2}}, \psi_{2}^{\prime}(y)=(-\arccos y)^{\prime}=1 / \sqrt{1-y^{2}}$.

Let's find the absolute values of the derivatives:

$$
\left|\psi_{1}^{\prime}(y)\right|=1 / \sqrt{1-y^{2}}, \quad\left|\psi_{2}^{\prime}(y)\right|=1 / \sqrt{1-y^{2}}.
$$

Considering that $f(x)=1 / 2\pi$, we get

$$
f\left[\psi_{1}(y)\right]=1 / 2\pi, \quad f\left[\psi_{2}(y)\right]=1 / 2\pi
$$

Substituting (**) and (***) into (*), we have

$$
g(y)=\frac{1}{2\pi \sqrt{1-y^{2}}}+\frac{1}{2\pi \sqrt{1-y^{2}}}=\frac{1}{\pi \sqrt{1-y^{2}}}
$$

Since $y=\cos x$, and $0<x<2\pi$, then $-1<y<1$. Thus, in the interval $(-1, 1)$, the desired density function $g(y)=1 / (\pi \sqrt{1-y^{2}})$; outside this interval, $g(y)=0$.

Control:

$$
\begin{gathered}
\int_{-1}^{1} g(y) \mathrm{d} y=\frac{1}{\pi} \int_{-1}^{1} \frac{\mathrm{d} y}{\sqrt{1-y^{2}}}=\frac{2}{\pi} \int_{0}^{1} \frac{\mathrm{d} y}{\sqrt{1-y^{2}}}=\frac{2}{\pi} \arcsin 1= \\
=2 / \pi \cdot \pi / 2=1
\end{gathered}
$$