The cdf of a uniform random variable is:

Thus by computing the derivative we have the density of
the uniform random variable to be:

The box shape we already knew!

Example 2:

The square of a random variable:

We start by computing the cdf by

We obtain the density by just deriving this cdf:

Example 3:

The sum of two uniform random variables:

We obtain the density by just deriving this cdf:

This the triangle shaped density that we found by simulation.