# Computing convolution of two characteristic function over a 1D Cartesian mesh

I am trying to compute the convolution of two characteristic functions over a Cartesian mesh. First, I define my Cartesian mesh of the interval $$[0,1]$$ as follows

$$x_{i} = i \Delta x, i = 0, 1, 2\\ \Delta x = \frac{1}{N},$$ with $$N$$ being the number of grid points. Secondly, we can compute the convolution of two characteristic functions analytically, which gives

$$f(x) = \mathcal{X}_{(-1/2,1/2)}(x) \star \mathcal{X}_{(-1/2,1/2)}(x) = \begin{cases} 0 & x > 1/2\;\text{or}\;x < 1/2 \\ x + 1 & x \in [-1/2,0] \\ 1-x & x \in [0,1/2] \end{cases}$$

When computing $$f(x)$$ over a mesh, would I calculate the characteristic function like this? $$f(x_{i}) = \mathcal{X}_{(-1/2,1/2)}(x_{i}) \star \mathcal{X}_{(-1/2,1/2)}(x_{i}) = \begin{cases} 0 & x_{i} > 1/2\;\text{or}\;x_{i} < 1/2 \\ x_{i} + 1 & x_{i} \in [-1/2,0] \\ 1-x_{i} & x_{i} \in [0,1/2] \end{cases}$$

As a side note, I know that the convolution of these two functions provide a B-Spline.

• Your formula looks correct -- it is just the evaluation of the previous one at a particular point $x_i$. As a side note, it's not useful to write $f(x)=g(x)\ast h(x)$ because on the right hand side, the $\ast$ is a non-local operation. In other words, it is not an operation that somehow operates at $g$ evaluated at $x$ and $h$ evaluated at $x$. It is better to write it as $f(x)=(g\ast h)(x)$, i.e., you are evaluating the convolution of the two functions at $x$. Dec 29, 2019 at 16:42