I have two functions;

f[x_] = (1/k) Exp[-x/k] ;
g[x_] = (1/p) Exp[-x/p] ;

How I can convolve them?

In Mathematica for convolving two functions we have this function:

Convolve[f, g, x, ??]

But I don't know how to do the convolution with the above function for my case.

before I ask this question I searched in detail but I didn't find what I need.

Note: the solution of the above functions is:

(1/k) Exp[-x/k]  *  (1/p) Exp[-x/p]  =  (1/(k-p)) ( Exp[-x/k]  - Exp[-x/p] )

where * is the convolution.

So, how to do this convolution in Mathematica?

  • $\begingroup$ Convolve[f, g, x, y] gives zero (y is the convolution dummy variable) $\endgroup$
    – Nasser
    Sep 10, 2013 at 18:08
  • $\begingroup$ @Nasser You don't happen to have used the OP definitions of the functions? They are not written with the correct Mathematica syntax. Should have been f = (1/k) Exp [-x/k];g = (1/p) Exp [-x/p]; $\endgroup$ Sep 10, 2013 at 18:38
  • $\begingroup$ You need to use proper Mathematica syntax; the exponential function is Exp[]. Next issue is that the integral will not converge on [-Infinity, Infinity]. $\endgroup$ Sep 10, 2013 at 18:38
  • $\begingroup$ @SjoerdC.deVries I just copied what OP wrote and did not even notice the exp vs. Exp ;) , oh boy, now I look at it, I see more syntax errors , using "(" vs. "[" . I need to go make some strong coffee $\endgroup$
    – Nasser
    Sep 10, 2013 at 18:45

2 Answers 2


The functions do not have a finite area, so they cannot be real distributions as your title claims they are.

Let's change them a bit so they have area 1.

f[x_] = (1/k) Exp[-x/k] UnitStep[x]; 
g[x_] = (1/p) Exp[-x/p] UnitStep[x]; 

Integrate[f[x], {x, -∞, ∞}]

ConditionalExpression[1, Re[1/k] > 0]

The convolution:

Convolve[f[x], g[x], x, y] 

Mathematica graphics

which equals (well apart from the unit step) what you were expecting.

Since your title mentions convolution of distributions let's explore that route as well. A convolution of two probability distributions is defined as the distribution of the sum of two stochastic variables distributed according to those distributions:

      x + y, 
         x \[Distributed] ProbabilityDistribution[f[x], {x, -∞, ∞}], 
         y \[Distributed] ProbabilityDistribution[g[x], {x, -∞, ∞}]

Mathematica graphics


Well, almost. Better to be a bit more complete.

$$\mathrm{E}\mathrm{D}\mathrm{C}\left(b,\beta; t\right)=\mathrm{b}{e}^{-bt} \otimes \beta {e}^{-\beta t} = \left\{\begin{array}{l}\left.\begin{array}{l}\mathrm{b}\beta \frac{e^{-\beta t}-{e}^{-bt}}{\mathrm{b}-\beta },\ \mathrm{b}\ne \beta \\ {}\kern1.75em {\mathrm{b}}^2t\ {e}^{-\mathrm{b}t}\kern0.5em ,\ \mathrm{b}=\beta \end{array}\right\}t\ge 0\\ {}\left.\kern3.75em 0\kern4.1em \right\}t<0\end{array}\right..$$

From this link.

That is, there is a special case and another way to do a convolution for simple cases:


$\begin{array}{cc} \Big\{ & \begin{array}{cc} b^2 t e^{-b t} & t>0 \\ 0 & \text{True} \\ \end{array} \\ \end{array}$


Your Answer

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

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