<s>[INST] Combined distribution of beta and uniform variables Given
$$X \sim \text{Beta}(\alpha,\beta)$$ (where $\alpha=\beta$, if that helps) and
$$\theta \sim \text{Uniform}(0, \pi/2).$$
I'm trying to find a formula for $P(Y)$ (or even the cdf) of
$$Y = X + (1-2X)\cos(\theta)$$
on the domain $(0,1)$.
I know from here that given $C = \cos(\theta),$ its PDF is
$$P(C) = \frac{2}{\pi\sqrt{1-C^2}}$$
and of course the pdf of a beta distribution is 
$$P(X) = \frac{X^{\alpha-1}(1-X)^{\beta-1}}{\mathrm{Beta}(\alpha, \beta)}.$$ 
But combining them is getting beyond my skills as an engineer.
EDIT: As it seems a closed form is not possible for this, could someone please show me how to formulate the integral to calculate this sort of PDF?  There may be some way I can reformulate the problem to be more solution-friendly if I could wrap my head around how compound distributions of this type are built mathematically.
 [/INST] There is no closed form for the density.  Its integral form can be obtained as follows.  If we condition on $X=x$ we have $Y = x + (1-2x) C$ where $C$ ranges over the unit interval.  The support under this condition is:
$$\text{supp}(Y|X=x) = \begin{cases}
[x,1-x] & & & \text{for } 0 \leqslant x < \tfrac{1}{2}, \\[6pt]
[1-x,x] & & & \text{for } \tfrac{1}{2} < x \leqslant 1. \\[6pt]
\end{cases}$$
(We can ignore the case where $x=\tfrac{1}{2}$ since this occurs with probability zero.)  Over this support we have the conditional density:
$$\begin{aligned}
p_{Y|X}(y|x) 
&= \frac{1}{|1-2x|} \cdot p_C \bigg( \frac{y-x}{1-2x} \bigg) \\[6pt]
&= \frac{1}{|1-2x|} \cdot \frac{2}{\pi} \bigg( 1 - \bigg( \frac{y-x}{1-2x} \bigg)^2  \bigg)^{-1/2} \\[6pt]
&= \frac{1}{|1-2x|} \cdot \frac{2}{\pi} \bigg( \frac{(1-2x)^2 - (y-x)^2}{(1-2x)^2} \bigg)^{-1/2} \\[6pt]
&= \frac{1}{|1-2x|} \cdot \frac{2}{\pi} \bigg( \frac{(1-4x+4x^2) - (y^2-2xy+x^2)}{(1-2x)^2} \bigg)^{-1/2} \\[6pt]
&= \frac{1}{|1-2x|} \cdot \frac{2}{\pi} \bigg( \frac{1 - 4x + 3x^2 + 2xy - y^2}{(1-2x)^2} \bigg)^{-1/2} \\[6pt]
&= \frac{1}{|1-2x|} \cdot \frac{2}{\pi} \cdot \frac{|1-2x|}{\sqrt{1 - 4x + 3x^2 + 2xy - y^2}} \\[6pt]
&= \frac{2}{\pi} \cdot \frac{1}{\sqrt{1 - 4x + 3x^2 + 2xy - y^2}}. \\[6pt]
\end{aligned}$$
Inverting the support we have $\text{supp}(X|Y=y) = 
[0,\min(y,1-y)] \cap [\max(y,1-y),1]$.  Thus, applying the law of total probability then gives you:
$$\begin{aligned}
p_Y(y) 
&= \int \limits_0^1 p_{Y|X}(y|x) p_X(x) \ dx \\[6pt]
&= \int \limits_0^{\min(y,1-y)} p_{Y|X}(y|x) p_X(x) \ dx 
+ \int \limits_{\max(y,1-y)}^1 p_{Y|X}(y|x) p_X(x) \ dx \\[6pt]
&= \frac{2}{\pi} \frac{\Gamma(\alpha+\beta)}{\Gamma(\alpha) \Gamma(\beta)} \Bigg[ \quad \int \limits_0^{\min(y,1-y)} \frac{x^{\alpha-1} (1-x)^{\beta-1}}{\sqrt{1 - 4x + 3x^2 + 2xy - y^2}} \ dx \\
&\quad \quad \quad \quad \quad \quad \quad \quad + \int \limits_{\max(y,1-y)}^1 \frac{x^{\alpha-1} (1-x)^{\beta-1}}{\sqrt{1 - 4x + 3x^2 + 2xy - y^2}} \ dx 
\Bigg]. \\[6pt]
\end{aligned}$$
There is no closed form for this integral so it must be evaluated using numerical methods.
</s>