Finding pdf of $X$ when $(X,Y)$ is jointly uniform over $\{(x,y)\in\mathbb R^2 :0\leq x\leq1\,,0\leq y\leq\min(x,1−x)\}$ Suppose that a point with co-ordinates $(X, Y)$ is chosen uniformly at random from the triangle $\{(x,y)\in\mathbb R^2 :0\leq x\leq1\,,0\leq y\leq\min(x,1−x)\}$. Find the density of the distribution of $X$.
I am struggling for when $x>1/2$.
 A: Observe that the shape of the sample space (the triangle on $\Bbb R^2$) is symmetric about $x = \dfrac12$, so as the marginal density function of $X$ is
$$
f_X(x) = \begin{cases} 4x & \text{if } x \in [0,\frac12] \\ 4(1-x) & \text{if } x \in [\frac12,1]. \end{cases}
$$

Verifty that $\int_0^1 f_X(x)\,dx = 1$.
\begin{align}
& \int_0^1 f_X(x) \,dx \\
=& \int_0^{1/2} 4x \,dx + \int_{1/2}^1 4(1-x) \,dx \\
=& 2(\frac12)^2 + 2(1-\frac12)^2 \\
=& 1
\end{align}
A: $\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,}
 \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
 \newcommand{\dd}{\mathrm{d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
 \newcommand{\ic}{\mathrm{i}}
 \newcommand{\mc}[1]{\mathcal{#1}}
 \newcommand{\mrm}[1]{\mathrm{#1}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
 \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$

Note that
  $\ds{\min\braces{x,1 - x} = {1 \over 2} - \verts{x - {1 \over 2}}}$

The triangle area is given by:
\begin{align}
&\bbox[10px,#ffd]{\ds{\int_{-\infty}^{\infty}\int_{-\infty}^{\infty}\bracks{0 \leq x \leq 1}
\bracks{0 \leq y \leq \min\braces{x,1 - x}}\dd x\,\dd y}}
\\[5mm] = &\
\int_{0}^{\infty}\int_{0}^{1}
\bracks{0 \leq y \leq {1 \over 2} - \verts{x - {1 \over 2}}}\dd x\,\dd y =
\int_{0}^{\infty}\int_{-1/2}^{1/2}
\bracks{0 \leq y \leq {1 \over 2} - \verts{x}}\dd x\,\dd y
\\[5mm] = &\
2\int_{0}^{\infty}\int_{0}^{1/2}
\bracks{0 \leq y \leq {1 \over 2} - x}\dd x\,\dd y =
2\int_{0}^{\infty}\int_{0}^{1/2}\bracks{x \geq y}\dd x\,\dd y
\\[5mm] = &\
2\int_{0}^{\infty}\braces{%
\bracks{y < {1 \over 2}}\int_{y}^{1/2}\dd x}\,\dd y =
2\int_{0}^{1/2}\pars{{1 \over 2} - y}\,\dd y = \color{red}{1 \over 4}
\end{align}

Then,
\begin{align}
&\bbox[10px,#ffd]{\ds{\int_{-\infty}^{\infty}{1 \over \color{red}{1/4}}
\bracks{0 \leq x \leq 1}
\bracks{0 \leq y \leq \min\braces{x,1 - x}}\dd y}}
\\[5mm] = &\
4\bracks{0 \leq x \leq 1}\int_{0}^{\infty}
\bracks{0 \leq y \leq {1 \over 2} - \verts{x - {1 \over 2}}}\dd y
\\[5mm] = &\
4\bracks{0 \leq x \leq 1}
\bracks{0 \leq {1 \over 2} - \verts{x - {1 \over 2}}}
\int_{0}^{1/2 - \verts{x - 1/2}}\dd y
\\[5mm] = &\
4\bracks{0 \leq x \leq 1}
\pars{{1 \over 2} - \verts{x - {1 \over 2}}} =
\bbx{\left\{\begin{array}{lcl}
\ds{4x} & \mbox{if} & \ds{0 \leq x \leq {1 \over 2}}
\\[1mm]
\ds{4\pars{1 - x}} & \mbox{if} & \ds{{1 \over 2} \leq x \leq 1}
\\[1mm]
\ds{0}&&\mbox{otherwise}
\end{array}\right.}
\end{align}
