# Double tophat convolved with a gaussian

I need some help calculating the analytically expression of this convolution.

The functions in question are:

1) a gaussian ($g(x)$)

2) a "double tophat function" (in lack of a better name). i.e. $$f(x)= \begin{cases} a\quad&\text{if } |x|<x_0,\\ b &\text{if } |x|<x_1,\\ 0&\text{otherwise}, \end{cases}$$ where $a>b$ and $x_1>x_0$.

I've tried various analytically tools but none of them has given me a useful answer.

Can someone please help me. I have no interest in the numerical solution. The reason I need it is that I want to analyze the behavior of the convolution for different $a$'s, $b$'s $x_0$'s and $x_1$'s of ($(g*f)(x)$)

-
The answer will be expressed in terms of the error function, defined here: mathworld.wolfram.com/Erf.html. Is that acceptable? – Ron Gordon Jan 7 '13 at 8:25
Yes and no. I want to compare some data to a few different models (different parameters of a and b). Erf is not very usefull by itself, but the tailor expansion of it will do unless the expression becomes too complicated. In other words. I do not need the exact expression, but any analytic approximation will do – Mikkel Jan 7 '13 at 8:32
Erf is pretty much the simplest expression you can expect, it has lovely analytic properties, and you can compute it quite easily. (See, for example, Numerical Recipes in C, Section 6.2, apps.nrbook.com/c/index.html). – Ron Gordon Jan 7 '13 at 8:51
Sure, and Erf() is good enough. I can do the expansion myself, but I still don't know what the convolution looks like. That's the part I'm having trouble with – Mikkel Jan 7 '13 at 8:55
In mathematics, unlike computer science, case distinctions are usually disjoint and not interpreted according to any order. That is, while in computer science your case distinction might be interpreted as "if $|x|\lt x_0$ then $f=a$ else if $|x|\lt x_1$ ...", the "else" is not implied in mathematical convention, so these two cases contradict each other. The second condition should read $x_0\le|x|\lt x_1$ instead. – joriki Jan 7 '13 at 10:07

## 1 Answer

As an example:

$$\int_{x_0/2}^{x_1/2} dx' \: \exp{\left (-\frac{(x-x')^2}{w^2} \right ) = } \frac{1}{2} \sqrt{\pi } w \left(\text{erf}\left(\frac{x-\frac{x_0}{2}}{w}\right)-\text{erf}\left(\frac{x-\frac{x_1}{2}}{w}\right)\right)$$

-
Could you please explain the left side of the equation? How does ∫f(x)g(x-t)dx translate into that? – Mikkel Jan 7 '13 at 10:13
g is a gaussian term, while f is a piece of the top hat that you described. Your result will be a combination of terms like these on the right hand side. – Ron Gordon Jan 7 '13 at 11:18
got it. Sort of. Let's divide $f$ up in three pieces. $f = f_1 + f_2 + f_3$ where $f_2$ is center part of the tophat function with the value $a$. $f_1$ and $f_3$ are the pieces with the value $b$ on the left and right side of $a$. The expression you have written is $g$ convoluted with any of these $f_1$, $f_2$ or $f_3$ ? If so, I'm not really sure how to understand the limits on your integral – Mikkel Jan 7 '13 at 11:43
Yes, that's pretty much how I pictured it. It helps to draw a figure and see what's happening. – Ron Gordon Jan 7 '13 at 13:20