Bug introduced in 9.0 or earlier and fixed in 11.0.0

Let $h[n]=(\frac{1}{2})^n u[n]-3(\frac{1}{2})^{n-1}u[n-1]$
$g[n]=3^n u[n]-\frac{1}{2}3^{n-1}u[n-1]$

I convolved $h[n]$ and $g[n]$ in Mathematica and obtained the following result:

h = (1/2)^n UnitStep[n] - 3*(1/2)^(n - 1) UnitStep[n - 1]
g = 3^n UnitStep[n] - (1/2)*3^(n - 1) UnitStep[n - 1]
DiscretePlot[DiscreteConvolve[h, g, n, m], {m, -5, 5}]

Here is the plot that Mathematica showed me:

enter image description here However, after doing the convolution by hand I obtained a discrete delta function. (i.e. $h[n]*g[n]=\delta[n]$), which I know is the correct answer.

Why is Mathematica giving me an incorrect answer for the convolution?

  • $\begingroup$ Did you try on a fresh kernel? I get a different plot than you do, where the convolution is indeed zero for positive m and 1 for m==0. For negative m I see negative values. $\endgroup$ Apr 18, 2016 at 16:46

1 Answer 1


This is a bug in DiscreteConvolve[].

The bug is caused by a missing condition (m>=0) in one term of the answer returned by DiscreteConvolve[] for your example.

A workaround for the problem is to apply PiecewiseExpand[] to the first two arguments of DiscreteConvolve[] as shown below.

h = (1/2)^n UnitStep[n] - 3*(1/2)^(n - 1) UnitStep[n - 1];

g = 3^n UnitStep[n] - (1/2)*3^(n - 1) UnitStep[n - 1];

DiscreteConvolve[PiecewiseExpand[h], PiecewiseExpand[g], n, m] // InputForm

(*Piecewise[{{3^m, m == 0}}, 0]*)

Table[%, {m, -5, 5}]

(*{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}*)

Sorry for the confusion caused by this problem.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.