Computing the Convolution of Two Pulses: Graphical vs Analytical

Recently, a user on Math.SE presented a problem of computing the convolution of two pulses: a triangular pulse (impulse response)

$$h(t) = \begin{cases} t & 0 \lt t \lt 2 T \\ 0 & t \lt 0 \cup t \gt 2 T\end{cases} $$

and a rectangular pulse (input)

$$x(t) = \begin{cases} 1 & 0 \lt t \lt T \\ 0 & t \lt 0 \cup t \gt T \end{cases} $$

The solution that the user quoted used graphical analysis. However, the user was dissatisfied with this method because (s)he felt it was “error prone.” The user asked if there was a purely analytical method that required no,…,uhhh…, artistry (?)

The following is a lesson in being careful for what you wish. The answer to the user’s question is of course there is such an analytical method. Unfortunately, it requires one to really know what the hell they are doing, and at the end of the day is far more tortuous than simply drawing a series of pictures.


To do this at the level of an undergrad signals class, you really need to draw a picture. But while it may be error-prone, there are checks along the way to see that you are doing it correctly.

The convolution integral is given by

$$x*h(t) = \int_{-\infty}^{\infty} dt’ \, x(t-t’) h(t’) $$

The key here is to figure out what $x(t-t’)$ is. I will let you figure out why

$$x(t-t’) = \begin{cases} 1 & t-T \lt t’ \lt t \\ 0& (t’ \lt t-T) \cup(t’\gt t) \end{cases} $$

Now we may resolve the integral graphically as the area of intersection of the rectangle $x$ and the triangle $h$. You should see that $x*h(t)=0$ when $t \lt 0$. Next, note that, as we increase $t$, the region of intersection is a right triangle and the convolution integral is

$$\int_0^t dt’ \, 1 \cdot t’ = 1/2 t^2$$

This is true until $t=T$, when the left side of the rectangle crosses the axis. When $t \gt T$, the integral is now

$$\int_{t-T}^t dt’ \, 1 \cdot t’ = T \left (t-\frac{T}{2} \right )$$

When $t \gt 2 T$, the right side of the rectangle extends out past the triangle, so the convolution integral is now

$$\int_{t-T}^{2 T} dt’ \, 1 \cdot t’ = \frac12 (3 T^2+2 T t-t^2)$$

When $t \gt 3T$, the convolution is zero.

Please observe this by drawing the graphs. It may take several drawings, but you will see this.

To summarize, we have

$$x*h(t) = \begin{cases} 0 & t \lt 0 \\\frac12 t^2 & 0 \lt t \lt T \\T \left (t-\frac{T}{2} \right ) & T \lt t \lt 2 T \\ \frac12 (3 T^2+2 T t-t^2) & 2 T \lt t \lt 3 T\\ 0 & t \gt 3 T \end{cases} $$

Here’s a plot for $T=2$:



Here we may use the convolution theorem for Fourier transforms:

$$\int_{-\infty}^{\infty} dt’ \, h(t’) x(t-t’) = \frac1{2 \pi} \int_{-\infty}^{\infty} d\omega \, H(\omega) X(\omega) \, e^{-i \omega t} $$

where $H$ and $X$ are the respective Fourier transforms of $h$ and $x$. In this case:

$$X(\omega) = \int_0^T dt \, e^{i \omega t} = \frac{e^{i T \omega}-1}{i \omega} $$
$$H(\omega) = \int_0^{2 T} dt \, t \, e^{i \omega t} = \left (\frac1{\omega^2} – \frac{i 2 T}{\omega} \right ) e^{i 2 \omega T} – \frac1{\omega^2} $$

Thus, after some algebra, we find the convolution integral to be

$$\frac1{i 2 \pi} \int_{-\infty}^{\infty} d\omega \, \left [e^{i (3 T-t) \omega} \left (\frac1{\omega^3} – \frac{i 2 T}{\omega^2} \right ) – e^{i (2 T-t) \omega} \left (\frac1{\omega^3} – \frac{i 2 T}{\omega^2} \right ) – \frac1{\omega^3} e^{i (T-t) \omega} + \frac1{\omega^3} e^{-i t \omega} \right ] $$

This looks like a heck of an integral to do out. One way we can attack it is to use contour integration in the complex plane. (I warned you.)

So let’s first consider

$$PV \int_{-\infty}^{\infty} d\omega \, e^{i (3 T-t) \omega} \left (\frac1{\omega^3} – \frac{i 2 T}{\omega^2} \right ) $$

Note that, when we break the integral apart, each piece on its own does not converge. So we consider the Cauchy principal value of the integral, knowing that when we put everything back together, the singular pieces should drop out and we will have our nice convolution integral again.

So now consider the contour integral

$$\oint_C dz \, e^{i (3 T-t) z} \left (\frac1{z^3} – \frac{i 2 T}{z^2} \right ) $$

where $C$ is a semicircular contour of radius $R$ in the upper half plane with a small semicircular detour of radius $\epsilon$ about the origin into the contour when $t \lt 3 T$ and $C$ is a semicircular contour of radius $R$ in the lower half plane with a small semicircular detour of radius $\epsilon$ about the origin into the contour when $t \gt 3 T$.

(If you need to understand why the contours need to be in the upper or lower half-planes like this, there are lots of resources on M.SE which address this very point. I will not do it here as it takes away from the discussion at hand.)

When $R \to \infty$ and for small $\epsilon$, we evaluate the contour integral in each case and apply Cauchy’s theorem, i.e., the contour integral is zero. In this example, I will write everything out – here, let’s use the upper contour:

$$PV \int_{-\infty}^{\infty} d\omega \, e^{i (3 T-t) \omega} \left (\frac1{\omega^3} – \frac{i 2 T}{\omega^2} \right ) + i \epsilon \int_{\pi}^0 d\phi \, e^{i \phi} \, e^{i (3 T-t) \epsilon e^{i \phi}} \left (\frac1{\epsilon^3 e^{i 3 \phi}} – \frac{i 2 T}{\epsilon^2 e^{i 2 \phi}} \right ) =0$$

Now, we expand out the exponential, collect like terms in $\epsilon$, and integrate. The result is, for small epsilon and $t \lt 3T$

$$\frac1{i 2 \pi} PV \int_{-\infty}^{\infty} d\omega \, e^{i (3 T-t) \omega} \left (\frac1{\omega^3} – \frac{i 2 T}{\omega^2} \right ) + \frac1{\pi} (t-T) \frac1{\epsilon} +\frac14 (t^2-2 T t-3 T^2) = 0$$

For $t \gt 3 T$, we now integrate over the detour from $\pi$ to $2 \pi$ instead, and the result is

$$\frac1{i 2 \pi} PV \int_{-\infty}^{\infty} d\omega \, e^{i (3 T-t) \omega} \left (\frac1{\omega^3} – \frac{i 2 T}{\omega^2} \right ) + \frac1{\pi} (t-T) \frac1{\epsilon} -\frac14 (t^2-2 T t-3 T^2) = 0$$

OK, you may have also noticed that we have a term in $1/\epsilon$, which becomes singular as $\epsilon \to 0$. That’s OK, because we have other pieces of the integral which will also have singular pieces, and we expect the singular parts to cancel prior to taking the limit as $\epsilon \to 0$.

The other integrals I will just state and allow the interested reader to work out for him/her/themself:

$$t \lt 2 T\\
-\frac1{i 2 \pi}PV \int_{-\infty}^{\infty} d\omega \, e^{i (2 T-t) \omega} \left (\frac1{\omega^3} – \frac{i 2 T}{\omega^2} \right ) – \frac{t}{\pi} \frac1{\epsilon} – \frac1{4} (t^2-4 T^2) = 0 \\$$

$$t \gt 2 T\\
-\frac1{i 2 \pi}PV \int_{-\infty}^{\infty} d\omega \, e^{i (2 T-t) \omega} \left (\frac1{\omega^3} – \frac{i 2 T}{\omega^2} \right ) – \frac{t}{\pi} \frac1{\epsilon} + \frac1{4} (t^2-4 T^2) = 0 \\$$

$$t \lt T\\
-\frac1{i 2 \pi}PV \int_{-\infty}^{\infty} d\omega \, e^{i (T-t) \omega} \frac1{\omega^3} – \frac{t-T}{\pi} \frac1{\epsilon} – \frac1{4} (T-t)^2 = 0 \\$$

$$t \gt T\\
-\frac1{i 2 \pi}PV \int_{-\infty}^{\infty} d\omega \, e^{i (T-t) \omega} \frac1{\omega^3} – \frac{t-T}{\pi} \frac1{\epsilon} + \frac1{4} (T-t)^2 = 0 \\$$

$$t \lt 0\\
\frac1{i 2 \pi}PV \int_{-\infty}^{\infty} d\omega \, e^{-i t \omega} \frac1{\omega^3} + \frac{t}{\pi} \frac1{\epsilon} + \frac1{4} t^2 = 0 \\$$

$$t \gt 0\\
\frac1{i 2 \pi}PV \int_{-\infty}^{\infty} d\omega \, e^{-i t \omega} \frac1{\omega^3} + \frac{t}{\pi} \frac1{\epsilon} – \frac1{4} t^2 = 0 \\$$

Now, we have to combine the above results to form the final convolution integral. It is worth laying out exactly how we are going to combine these results. I will illustrate with the following array:

$$\begin{array}\\ & 0 & T & 2 T & 3 T \\ t < 0 & < & < & < & < \\ 0< t < T & > & < & < & < \\ T \lt t \lt 2 T & > & > & < & < \\ 2 T \lt t \lt 3 T & > & > & > & < \\ t \gt 3 T & > & > & > & > \end{array} $$

The $\lt$ or $\gt$ denotes which of the results (e.g., $t \gt 3 T$ or $t \lt 3 T$) we are using for the value of $t$ in the respective row. Note that, no matter how we combine the results, the singular $1/\epsilon$ terms will cancel.

So, for example, for $t \lt 0$, we combine all of the “less than” results above. And, fortunately, we find that everything cancels and the result is zero, as we expect. In fact, I leave it as an exercise for the reader to verify that, by combining the results as specified in the above matrix, that we reproduce the results obtained by computing the integral graphically.

Still want to do the convolution integrals analytically?

Integral with two branch cuts II

The problem here is to compute $$\int_0^\infty \log(1+tx)t^{-p-1}dt$$ where $p\in(0,1)$ and $x>0$. This is a great problem for contour integration. Just tricky enough to be really interesting. What makes it interesting is that there are two functions in the integrand needing their own separate branch cuts. One must keep in mind that each function only […]

Integral with two branch cuts

The problem is to evaluate the following integral: $$\int_{-1}^1 dx \frac{\log{(x+a)}}{(x+b) \sqrt{1-x^2}} $$ where $a \gt 1$ and $|b| \lt 1$. It should be obvious to those who spend time around these integrals that this integral does not converge as stated. However, we only have a simple pole at $x=-b$ so that we can compute […]

Fascinating Fourier Transform

Sometimes I come across a Fourier integral that I have no idea how to attack. And then I find that I can convert it to another, more familiar integral using complex analysis. So here’s an example of such a satisfying situation. The problem is to evaluate $$\int_{-\infty}^{\infty} dx \, (1+i a^2 x)^{-1/2} (1+i b^2 x)^{-1/2} […]

Cauchy Principal Value

On Math.SE, we frequently get integrals that simply do not exist in the usual sense because the integration path intersects a pole of the integrand. Occasionally, we come across such integrals in the course of evaluating integrals of functions with removable singularities using complex methods. However, sometimes such integrals are interesting in their own right. […]

Inverse Laplace Transforms and Delta Functions

Problem: find the inverse Laplace transform of $$F(s) = \frac{s}{s-1}$$ Solution: Well, this one should be easy and one wonders why we are even bothering.  Just split $F$ up as follows: $$F(s) = \frac1{s-1} + 1$$ The ILT of $1/(s-1)$ is simply $e^t$, and the ILT of $1$ is $\delta(t)$.  Done. Or are we?  Why […]

Adventures in integration, University Edition

I got a request from an old friend whom I didn’t even know existed. He is the son of my grand-advisor, if that makes any sense. He teaches, among others, a course in Real Analysis at a university in Australia. I know I must like this guy because he says stuff like this: Currently, within the School […]

Inverse Laplace Transform with a coinciding pole and branch point

Recently, the following Laplace transform was asked to be inverted: $$F(s) = s^{-a-1} e^{-s^a} $$ where $a \in (0,1)$. This is a tough problem for two reasons. One is that there is very little chance of there being an analytical result for arbitrary values of $a$. The other, however, is more subtle: there is a […]

The art of using the Residue Theorem in evaluating definite integrals

As many of you know, using the Residue Theorem to evaluate a definite integral involves not only choosing a contour over which to integrate a function, but also choosing a function as the integrand. Many times, this is an easy task when integrating, say, rational functions over the real line. Sometimes there are less trivial […]

A Tale of Two Integrals

Two integrals look almost the same, and even to those fairly well-versed in the art, are the same. But alas, as we shall see. Consider the integral $$I_1 = \int_0^{\pi} dx \frac{x \sin{x}}{1+\cos^2{x}} $$ This may be evaluated by subbing $x \mapsto \pi-x$ as follows: $$\begin{align} I_1 &= \int_0^{\pi} dx \frac{(\pi-x) \sin{x}}{1+\cos^2{x}} \\&= \pi \int_0^{\pi} […]

Weird integral whose simplicity is only apparent in the complex plane

Every so often we come across an integral that seems absolutely impossible on its face, but is easily attacked – in fact, is custom designed – for the residue theorem. I wonder why a first year complex analysis class doesn’t show off this case as Exhibit A in why the residue theorem is so useful. […]

Expansions of $e^x$

A very basic question was asked recently: What is a better approximation to $e^x$, the usual Taylor approximation, or a similar approximation involving $1/e^{-x}$? More precisely, given an integer $m$, which is a better approximation to $e^x$: $$f_1(x) = \sum_{k=0}^m \frac{x^k}{k!} $$ or $$f_2(x) = \frac1{\displaystyle \sum_{k=0}^m \frac{(-1)^k x^k}{k!}} $$ The answer is amazingly simple: […]

Real evaluation of an improper log integral

The problem posed in M.SE concerns real methods of evaluating $$\int_0^{\infty} dx\frac{\log(x)}{\cosh(x) \sec(x)- \tan(x)} $$ The place I started is the nifty result, proven here, that $$\frac{\sin{x}}{\cosh{t} – \cos{x}} = 2 \sum_{k=1}^{\infty} e^{-k t} \sin{k x} $$ Of course, the integral actually looks like $$\int_0^{\infty} dx \frac{\cos{x}}{\cosh{x} – \sin{x}} \log{x} $$ so we need to […]

Generalizing an already tough integral

I did the case $p=1$ here. The generalization to higher $p$ may involve higher-order derivatives as follows: $$\begin{align}K_p &= \int_0^{\pi/2} dx \frac{x^{2 p}}{1+\cos^2{x}} = \frac1{2^{4 p-1}} \int_{-\pi}^{\pi} dy \frac{y^{2 p}}{3+\cos{y}} \end{align}$$ So define, as before, $$J(a) = \int_{-\pi}^{\pi} dy \frac{e^{i a y}}{3+\cos{y}} $$ Then $$K_p = \frac{(-1)^p}{2^{4 p-1}} \left [\frac{d^{2 p}}{da^{2 p}} J(a) \right ]_{a=0}$$ […]

Mathematica v9.0.1 states that this integral does not converge.

The problem is to evaluate the following integral: $$\int_0^{\infty} dx \frac{\log(1+x)}{\left(1+x^2\right)\,\left(1+x^3\right)}$$ This one turned out to be messy but straightforward. What did surprise is the way in which I would need to employ the residue theorem. Clearly, the integral is more amenable to real methods than a contour integration. What happens, though, is that the […]

An unusually alternating sum

Problem: evaluate the following sum… $$\sum_{k=0}^{\infty}\dfrac{(-1)^{\frac{k(k+1)}{2}}}{(2k+1)^2}$$ This is unusual because the $-1$ is raised to the $k (k+1)/2$ power, rather than the usual $k$th power. On the surface, this problem may look hopeless, but really, it is all about determining the pattern of odd and even numbers from the sequence $k (k+1)/2$, which turns out […]

Algebraically difficult integral

Well, some integrals are not all that hard to evaluate in principle. The one I am posting here should be an open and shut application of the residue theorem, using the unit circle as a contour. The form of the integrand, however, should give a little pause. It turns out that actually computing residues on […]

An integral involving a quadratic phase

This one was first posted on the site Integrals and Series and was brought to my attention on M.SE by Cody. My solution involves a contour integration, although the approach is far from trivial. Yet again, the solution boils down to finding a contour and a function to integrate over the contour. The problem involves […]

An integral that illustrates the beauty of contour integration methods

I attack many of the integrals in this blog using contour integration methods, some of which are obvious and some of which take a little more imagination. Here is one that illustrates the beauty an power of such methods as much as any other integral here. The problem is to derive the integral representation $$\sin […]

Funky triple integral

Note: There was a sign error in the original solution, which I have since fixed. Problem: Evaluate $$ \int _0 ^{\infty}\int _0 ^{\infty}\int _0 ^{\infty} \log(x)\log(y)\log(z)\cos(x^2+y^2+z^2)dzdydx$$ Solution: One way to attack this is to exploit the symmetry of the integral. Start by expanding the cosine term into individual pieces, i.e., $$\begin{align}\cos{(x^2+y^2+z^2)} &= \cos{x^2} \cos{(y^2+z^2)} – […]

An odd-looking integral of a square root of trig functions

The integral to evaluate is $$\int_0^{\pi/3} \big((\sqrt{3}\cos x-\sin x)\sin x\big)^{1/2}\cos x \,dx $$ A cursory glance at this specimen leads to exasperation, as the $\pi/3$ in the limit seems arbitrary, and the integrand seems devoid of an antiderivative. It turns out, however, that one way to attack this integral is to transform it into a […]

Integral of function with deceptive triple pole

One integral posted came from Hermite’s integral representation of the Hurwitz zeta function. The integral is not the most difficult that I have ever evaluated, but is interesting from a pedagogical point of view. The problem is to evaluate $$\int_0^{\infty} dx \frac{x}{(e^x-1) (x^2+4 \pi^2)^2}$$ This integral may be done via the residue theorem, by considering […]