I have some doubts about this convolution exercise. Take two functions defined as:

$$f(t) = \begin{cases} 2 ~~~~~ 0< t< 3 \\ 0 ~~~~~ \text{elsewhere} \end{cases}$$

$$g(t) = \begin{cases} 2 ~~~~~ 0< t< 1 \\ 0 ~~~~~ \text{elsewhere} \end{cases}$$

And calculate their convolution $f * g $

So by the definition

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

That is

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

How should I proceed?

Mathematica gives the CORRECT result:

$$\begin{array}{cc} & \begin{array}{cc} 4 & 1<\tau \leq 3 \\ -4 (\tau -4) & 3<\tau <4 \\ 4 \tau & 0<\tau \leq 1 \\ \end{array} \\ \end{array}$$

And of course $0$ elsewhere.

  • $\begingroup$ Are f(t) and g(t) independent? $\endgroup$ Commented Jan 7, 2018 at 15:14
  • $\begingroup$ @callculus Yes, they are two distinct piecewise functions $\endgroup$
    – Enrico M.
    Commented Jan 7, 2018 at 15:14
  • $\begingroup$ Just expand the piecewise, find values of $\tau$ such that $0 < t-\tau < 3$ and $0 < \tau < 1$, which $f(t-\tau) g(\tau) = 4$, else it is $0$. $\endgroup$
    – user202729
    Commented Jan 7, 2018 at 15:38
  • 2
    $\begingroup$ Read this answer of mine over on dsp.SE. $\endgroup$ Commented Jan 7, 2018 at 15:44
  • $\begingroup$ @DilipSarwate "Hey Ma, I am beginning to see a pattern here! Lookit, I can write $y(t) = \int_{-\infty}^\infty h(\tau)x(t-\tau)\mathrm d\tau, ~\forall t$ and the world was never the same again" honesty this is the best explanation i saw for this... $\endgroup$
    – Holo
    Commented Jan 7, 2018 at 16:18

3 Answers 3


we have:

$f(t) = \begin{cases} 2 & 0< t< 3 \\ 0 &\text{elsewhere} \end{cases}$

$g(t) = \begin{cases} 2 & 0< t< 1 \\ 0 & \text{elsewhere} \end{cases}$

so let's take a look over the intervals $\Bbb R,(0,3),(0,1)$:

Using those interval we can see $4$ cases: $(-\infty,0],(0,1),[1,3),[3,\infty)$, I want to point out that there are 4 cases but we will use $[1,3),[3,\infty)$ as one:

if $\tau\in(-\infty,0]$ then $g(\tau)=0$

if $\tau\in[1,3)\cup[3,\infty)=[1,\infty)$ then $g(\tau)=0$

so we can reduce the integral: $\int_{-\infty}^{+\infty} f(t - \tau) g(\tau) \ d\tau\to \int_{0}^{1} f(t - \tau) g(\tau) \ d\tau$

now in the interval $(0,1),\ g(\tau)$ is a constant, so we can take it out:$\int_{0}^{1} f(t - \tau) g(\tau) \ d\tau\to2\int_{0}^{1} f(t - \tau)d\tau$

now we have $g*f(t)=2\int_{0}^{1} f(t - \tau)d\tau$, set $\omega=t-\tau\implies d\omega=-d\tau,\omega(0)=t,\omega(1)=t-1$ so we get: $2\int_{0}^{1} f(t - \tau)d\tau\to-2\int_{t}^{t-1} f(\omega)d\omega\to2\int_{t-1}^{t} f(\omega)d\omega$

Can you solve this kind of intervals?

I learnt that playing with functions can help a lot for intuition.

for example: try: $t=-5,t=0.5,t=1,t=2,t=3.5,t=5$ and see what happens. after that try to find intervals for which the function gives the same value, see how it connects to the original $4$ cases i presented, what is the same and what is different.

  • $\begingroup$ Why do you consider as one, the two different intervals? $(1, 3)$ and $(3, +\infty)$ are different: in one of them the function do exist $\endgroup$
    – Enrico M.
    Commented Jan 8, 2018 at 10:53
  • $\begingroup$ Also I don't get the point of "try some values". $\endgroup$
    – Enrico M.
    Commented Jan 8, 2018 at 10:54
  • $\begingroup$ @ArtificialIntelligence because when we are looking at $g(\tau)$ they are equal, so at this point there is no point to look at each of them alone $\endgroup$
    – Holo
    Commented Jan 8, 2018 at 10:55
  • 1
    $\begingroup$ @ArtificialIntelligence plug in some values of $t$, play around with the function $g*f$ $\endgroup$
    – Holo
    Commented Jan 8, 2018 at 10:56

Note $$ \int_\mathbb{R} f(t-\tau)g(\tau)\mathrm d\tau=2\int_0^1f(t-\tau)\mathrm d\tau $$ for obvious reasons. Performing the change of variable $s=t-\tau$ converts our integral to $$ \int_{t-1}^tf(s)\mathrm ds $$ Now, if $t>4$ or $t<0$ this integral is zero, since $f$ is identically zero.

For this part, I found drawing a picture immensely helpful.

If we straddle zero with $t-1$ and $t$, $t<1$ and $t<3$ we have the the integral is $$ \int_{t-1}^tf(s)\mathrm ds=2t $$ Similarly, if we straddle $3$, we have $$ \int_{t-1}^tf(s)\mathrm ds=2(3-(t-1))=2(4-t) $$ Leaving us with $(t-1,t)$ being contained entirely in the the interval $(0,3)$ in which case we just have $$ \int_{t-1}^tf(s)\mathrm ds=2 $$ this leaves us with $$ f*g(t)=\begin{cases}0&t<0\\ 4t&0\leq t<1\\ 4&1\leq t<3\\ 16-4t&3\leq t<4\\ 0&t\geq 4\end{cases} $$

This sort of matches my (hopefully correct) intuition. Firstly, we notice that we got out a continuous function, so convolution is smoothing things. Secondly, we took in two piecewise constant functions (with the same height) with overlapping pieces and "smoothly averaged" them over time. I would expect this to look linear with positive slope as we start to pick up the piecewise function $g$, then $2$ as we pick up both ($\frac{1}{2}(2+2)=2$). Finally, one of the functions in the convolution is zero again, and we have a negative slope as $g$ is getting lost.

  • $\begingroup$ very very helpful, thank you! $\endgroup$
    – Enrico M.
    Commented Jan 7, 2018 at 17:23
  • $\begingroup$ Excuse me for the bothering, but how exactly did you get $2$ in the first integral? The limits are $t-1$ and $t$, and so how did you get a number? Also the same question applies to the second integral. This is something I am missing perhaps... I think it's a question of ranges but I would appreciate more details. I never faced a piecewise convolution, and I can't find any good examples or theory, and our professor's is not really complete. $\endgroup$
    – Enrico M.
    Commented Jan 8, 2018 at 10:41
  • 2
    $\begingroup$ @ArtificialIntelligence in the end you have $\int_{t-1}^t f(s)ds$, so the intervals you are looking at is: when both $f(t)$ and $f(t-1)$ are $0$, when only $f(t)=0$, when only $f(t-1)=0$ and when none of them is $0$. At $t<0$ it is case one, at $0\le t<1$ it is case 3, at $1\le t<3$ it is case 4, at $3\le t<4$ it is case 2, and at $t\ge 4$ it is case one again $\endgroup$
    – Holo
    Commented Jan 8, 2018 at 11:03
  • $\begingroup$ @Holo Sure this was clear, but what I don't understand is how we compute the integral, for the case $3 \leq t < 4$ to obtain that result. In that case $f(t) = 0$ and $f(t-1) \neq 0$ but given this I'd expect an integral of $2\ ds$ from $t-1$ to $t$ which leaves $-2(t-1)$. [?] $\endgroup$
    – Enrico M.
    Commented Jan 8, 2018 at 12:39
  • $\begingroup$ so $3\le t<4:$ so over some interval(from $t-1$ to $3$) we have $f(t)=2\implies\int f(t)dt=2t$. over the rest of the interval(from $3$ to $t$) we have $f(t)=0$ hence $\int f(t)dt=0$. so $\int_{t-1}^t f(t) dt=\int_{t-1}^3 f(t) dt +\int_3^t f(t) dt=(8-2t)+0=8-2t$ $\endgroup$
    – Holo
    Commented Jan 8, 2018 at 12:56

Those guys only make confusion. I will answer you with a very easy method you can use with piecewise functions.

First of all you have two steps functions, which you can easily figure in your mind to be like 2 dimensional boxes of height $2$.

Think about them as two boxes, one of which has to move towards the other. Those are two signals, and the convolution is nonzero only when they do intersect. Figure it out as the following picture:

enter image description here

Before some obnoxious arsehole points it out: this figure does not represent your problem but it's a great help to figure it out.

The first box goes from $0$ to $1$, whilst the second one goes from $\tau -3$ to $\tau$.

In your case, you maintain the smallest step function you have, that is the $g$ and you make $f$, the larger step, to move towards the first box.

Hence you will follow several steps.

Step 1

The signals are like the above figure: separated. In this case, their convolution is simply zero which happens in the range

$$\tau - 3 > 1$$

That is

$$\tau > 4$$

Step 2

The larger box start to insinuate itself onto the smallest, hence you will have

$$\int_{\tau -3}^1 4\ d\tau = 16 - 4\tau$$

And this happens in the range

$$\begin{cases} 0 < \tau -3 \\ 1 > \tau -3 \end{cases}$$

Which means

$$3 < \tau < 4$$

Step 3

The big box is all passing through the small box, id est the smaller is totally contained into the larger. Hence

$$\int_0^1 4\ d\tau = 4$$

In the range

$$\begin{cases} 0 > \tau -3 \\ 1 > \tau \end{cases}$$

Which means

$$1 < \tau < 1$$

Step 4

Now the larger box fades away, but with a bit to it still inside the smaller box.

$$\int_0^{\tau} 4\ d\tau = 4\tau$$

Which happens in the range

$$0< \tau < 1$$

Step 5

Finally the big box goes away, and the convolution is zero again for

$$\tau < 0$$

At the end you have your result:

$$f*g = \begin{cases} 0 & \tau > 4 \\ 16 - 4\tau & 3<\tau < 4 \\ 4 & 1<\tau < 3 \\ 4\tau & 0 < \tau < 1 \\ 0 & \tau < 0 \end{cases}$$

This is a trapezoid, and if you plot it you will get

enter image description here

As it has to be.

  • 1
    $\begingroup$ "Those guys only make confusion." Are you serious? This is the way you respond to someone taking the time to answer your question? $\endgroup$ Commented Jan 8, 2018 at 19:38
  • $\begingroup$ @qbert If someone makes confusion, then yes. Please, don't misapprehend me. I didn't say you answered badly or with wrong and useless answers, but frankly I understood nothing of what you explained to me. Probably your way to teach certain things is bugged, or maybe it's just because we did not talk face to face. I gave a +1 to you both for the time and the effort, but personally I understood more by studying textbooks and notes. Thank you anyway! $\endgroup$
    – Enrico M.
    Commented Jan 8, 2018 at 19:45
  • $\begingroup$ What you said is "those guys only make confusion" implying that our answers were worthless to you. This is particularly odd because you thanked me and said it was very helpful. It's also just obnoxious. Why do you assume I have a bug in my teaching? $\endgroup$ Commented Jan 8, 2018 at 19:48
  • $\begingroup$ This problem boils down to some calculus, the final paragraph I added was tentatively meant to flesh out some intuition for convolutions, which are highly important in advanced math $\endgroup$ Commented Jan 8, 2018 at 19:49
  • 1
    $\begingroup$ OP, if my and @qbert answers confused you, you should havent upvote but keep asking, I find it hard to believe that qbert will ignore you as both he and I took our time to answer you with a lot of details, and both he and I already answer you existing comments. Now saying the way he teach is bugged is just insulting, I'll return to the previous point, if you find the way he teach weird ask, if you don't want to ask, ignore, no need to regard to it and insult him... his answer is perfect, the only reason I added my answer is because I find importance in understanding the intervals better. $\endgroup$
    – Holo
    Commented Jan 9, 2018 at 12:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .