Define
f[x_, i_] := Piecewise[{{1/n,
0 < x < (i - 1)/n}, {(i/n - x), (i - 1)/n < x < i/n} , {0,
i/n < x}} ];
I would like to compute
Integrate[f[x,i]*f[y,i]*f[x,j]*f[y,j],{x,0,1},{y,0,1}],
assuming that $n$, $i$ and $j$ are natural numbers and $1\leq j\leq i\leq n$. So far, I have try to use ExpandPiecewise[f[xPiecewiseExpand[f[x,i]*f[y,i]*f[x,j]*f[y,j]]
and split the integral in different ways. However, it takes forever the computation of the double integral. Do you have any advice to proceed?