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]


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

  • $\begingroup$ Are you looking for Nest? $\endgroup$ – Martin Ender Apr 7 '16 at 13:39
  • $\begingroup$ 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? $\endgroup$ – maniA Apr 7 '16 at 13:56
  • $\begingroup$ Have you seen this? $\endgroup$ – J. M.'s ennui Apr 7 '16 at 14:01

You could also use:

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



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

enter image description here

  • $\begingroup$ I'm surprised InverseLaplaceTransform[] even works… :) $\endgroup$ – J. M.'s ennui Apr 20 '16 at 13:02
  • $\begingroup$ @J.M. Actually so was I...I am sure it is brittle but for some straight forward situations may be enough :) $\endgroup$ – ubpdqn Apr 20 '16 at 13:04
  • $\begingroup$ @ubpdqn ok your solution is more elegant :) just one question: dose it work with every function, I mean e.g. with truncated exponential too? $\endgroup$ – maniA Apr 20 '16 at 15:31
  • $\begingroup$ @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 :) $\endgroup$ – ubpdqn Apr 21 '16 at 4:45
  • $\begingroup$ @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 $\endgroup$ – maniA Apr 25 '16 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


you get the 4-fold convolution.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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