# n fold convolution of a function via a recursion function

I wanted to write a recursion function to calculate the n-th convolution of a function f[x_]. I wrote the function

g[f[x_], y_, z_] := Convolve[f[x], y, x, z]


where

f[x_] := \[Lambda]*
Exp[-\[Lambda]*x/L]/((1 - Exp[-\[Lambda]])*L) UnitStep[x]


But now I want to put an n into the g function

g[f[x_], y_, z_,n_]


wich does the same n times! With DO[...] I have the problem the there is no output. How can I do it? thanks in advanced

• Are you looking for Nest? Apr 7, 2016 at 13:39
• I do not know Nest, do you think is it the solution? I checked it but the parameter z should be changed in every step, how can we manage it? Apr 7, 2016 at 13:56
• Have you seen this? Apr 7, 2016 at 14:01

You could also use:

cm[f_, s_, t_, n_] :=
InverseLaplaceTransform[LaplaceTransform[f, s, t]^(n + 1), t, s]


(s>0):

e.g.

TableForm[Table[{j, cm[Exp[-a s] UnitStep[s], s, t, j]}, {j, 1, 10}],
TableHeadings -> {None, {"n", "n-fold Convolution"}}]


• I'm surprised InverseLaplaceTransform[] even works… :) Apr 20, 2016 at 13:02
• @J.M. Actually so was I...I am sure it is brittle but for some straight forward situations may be enough :) Apr 20, 2016 at 13:04
• @ubpdqn ok your solution is more elegant :) just one question: dose it work with every function, I mean e.g. with truncated exponential too? Apr 20, 2016 at 15:31
• @maniA I am not sure how robust it is. It may not work for your purposes. It appears to work with a number of functions. Apologies for delay: time zones :) Apr 21, 2016 at 4:45
• @ubpdqn no matter thanks any way :) ok I tick your response as the answer, however be warned guys that it may not work for the general case ;) then use just my proposal Apr 25, 2016 at 16:50

Thanks to all who helped or tried to help me here, finally I found a solution. My special function was the exponential distribution but one can apply it for any arbitrary function.

f[x_] = \[Lambda]*Exp[-\[Lambda]*x] UnitStep[x];
g[x_] = \[Lambda]*Exp[-\[Lambda]*x] UnitStep[x];
convi[n_] := {Do[
g[x[i]] = Convolve[f[x[i - 1]], g[x[i - 1]], x[i - 1], x[i]], {i,
1, n}], g[x[n]]}[[2]]


and if you excuse for instance

convi[4]


you get the 4-fold convolution.