Computing the convolution of $f(x)=\gamma1_{(\alpha,\alpha+\beta)}(x)$ If I have a top hat function 
$$
f(x)=\begin{cases}
    \gamma       & \quad \text{if } \alpha<x<\alpha+\beta\\
    0  & \quad \text{otherwise } 
  \end{cases}
$$
and I convolute it with itself:
$$
f*f(x)=\int^{\alpha+\beta}_{\alpha}\gamma f(x-t)\ dt
$$
I know the solution is a triangle function but how do I solve this integral?

Answer:
$$f*f(x)=\begin{cases}
    \gamma^2(\beta- |x-2\alpha-\beta|)      & \quad \text{if } |x-2\alpha-\beta|< \beta\\
    0  & \quad \text{if } |x-2\alpha-\beta|\ge \beta
  \end{cases}$$
see the details below
-----------------------------------------------------------------------------

Let $x\in \Bbb R$ for $t\in (\alpha,\alpha+\beta)$ we have
  $$x-t\in [\alpha,\alpha+\beta]\Longleftrightarrow t\in [x-\alpha-\beta,x-\alpha]$$
  
  
  Therefore, we have
  $$t, x-t\in [\alpha,\alpha+\beta]\Longleftrightarrow \color{red}{t\in[\max(\alpha,x-\alpha-\beta), \min(x-\alpha,\alpha+\beta)] \\\Longleftrightarrow |x-2\alpha-\beta|< \beta } $$

In fact, observes that 
$$ \min(x-\alpha,\alpha+\beta) =\min(x,2\alpha+\beta)-\alpha~~~~$$and$$~~~\max(\alpha,x-\alpha-\beta)=\max(x, 2\alpha+\beta)-\alpha-\beta$$

Hence, if $x\in \Bbb R$ is such that $$\max(\alpha,x-\alpha-\beta)< \min(x-\alpha,\alpha+\beta) \\\Longleftrightarrow \max(x, 2\alpha+\beta)-\beta< \min(x, 2\alpha+\beta) \\\Longleftrightarrow |x-2\alpha-\beta|=\max(x, 2\alpha+\beta)-\min(x, 2\alpha+\beta)< \beta \\\Longleftrightarrow |x-2\alpha-\beta|< \beta $$

then $$f*f(x)=\int_{\Bbb R} f(t)f(x-t)\ dt =\int^{\alpha+\beta}_{\alpha}\gamma f(x-t)\ dt \\=\int^{\min(x-\alpha,\alpha+\beta)}_{\max(\alpha,x-\alpha-\beta)}\gamma f(x-t)\ dt \\=\int^{\min(x-\alpha,\alpha+\beta)}_{\max(\alpha,x-\alpha-\beta)}\gamma^2 dt \\=\color{red}{\gamma^2 \min(x-\alpha,\alpha+\beta) -\gamma^2 \max(\alpha,x-\alpha-\beta)\\=\gamma^2(\beta- \max(x, 2\alpha+\beta)+\min(x, 2\alpha+\beta)) \\=\gamma^2(\beta- |x-2\alpha-\beta|)}$$
otherwise  if $x\in \Bbb R$ is such that $$\max(\alpha,x-\alpha-\beta)\ge\min(x-\alpha,\alpha+\beta)$$ then $$f*f(x) =0$$
