# Convolution of square function with itself

I have the square function

$$f(x) = \begin{cases} 1, & 0 \leq x \leq 1 \\ 0, & \text{otherwise}\end{cases}$$

and I am trying to calculate the convolution $(f * f)(t)$ using the definition of convolution

$$(f*g)(t) = \int_{-\infty}^{\infty} f(\tau)g(t - \tau)d\tau$$

What I have so far is

$$(f*f)(t) = \int_{-\infty}^{\infty} f(\tau)f(t - \tau)d\tau$$ $$= \int_{-\infty}^{0} \underbrace{f(\tau)}_{\equiv 0}f(t - \tau)d\tau + \int_{0}^{1} f(\tau)f(t - \tau)d\tau + \int_{1}^{\infty} \underbrace{f(\tau)}_{\equiv 0}f(t - \tau)d\tau$$ $$= \int_{0}^{1} \underbrace{f(\tau)}_{\equiv 1}f(t - \tau)d\tau = \int_{0}^{1} f(t - \tau)d\tau$$

But now I don't understand how to go further, because the integrand is not continous. If you visualize the integral for diffent cases of $t$ one can see that the result must be $$(f*f) (t) = \begin{cases} 0, & t \lt 0 \\t, & 0\leq t \le 1\\ 2- t, & 1\lt t \leq 2\\ 0 , & t \gt 2\end{cases}$$ but I don't see how to get there analytically. Could anyone help?

Here's a "trick" for convolving piecewise constant functions.

Define $g:= f * f$. Note that $\dot g = f * \dot f$. Hence,

$$\dot g (t) = f (t) * (\delta (t) - \delta (t-1)) = f (t) - f (t-1)$$

where $\delta$ denotes the Dirac delta. Integrating,

$$g (t) = r (t) - 2 r (t-1) + r (t-2) = \begin{cases} t & \text{if } 0 \leq t \leq 1\\ 2 - t & \text{if } 1 \leq t \leq 2\\ 0 & \text{otherwise}\end{cases}$$

where

$$r (t) = \begin{cases} t & \text{if } t \geq 0 \\ 0 & \text{otherwise}\end{cases}$$

is the ramp function.

If $t<0, f(t−τ) = 0$ for all $\tau$ in the interval.

If $0\le t \le 1$ $f(t) = \int_0^1 f(t−τ)dτ = \int_0^t f(t−τ)dτ + \int_t^1 f(t−τ)dτ=t$

If $1\le t \le 2$

$f(t) =$ $\int_0^1 f(t−τ)dτ = \int_0^{t-1} f(t−τ)dτ + \int_{t-1}^1 f(t−τ)dτ\\ 1-(t-1) = 2-t$

If $2\le t, f(t−τ) = 0$ for all $\tau$ in the interval.