I would like to calculate the following recursion with mathematica $$f_n(x)=\int_{B}^{A}f_{n-1}(x-\omega)f(\omega)\mbox{d}\omega\quad\quad f_1(w):=f(w)$$ This is simply the convolution of $f$ with itself in the range $(B,A)$. I think it is possible to rewrite this in ordinary convolution form as

$$f_n(x)=\int_{B}^{A}f_{n-1}(x-\omega)f(\omega)\mbox{d}\omega=\int_{-\infty}^\infty f_{n-1}(x-\omega)f(\omega)1_{\{B<\omega<A\}}\mbox{d}\omega\\=\int_{-\infty}^\infty f_{n-1}(x-\omega)g(\omega)\mbox{d}\omega\quad\mbox{with}\quad g(\omega)=f(\omega)1_{\{B<\omega<A\}}$$ which says that $f_n$ is obtained by convolving $f_{n-1}$ with $g$


this corresponds to multiplication at the Fourier domain


For $n=2$ we have $F_2=F_{1}G=FG$. For $n=3$, $F_3=F_{2}G=F_{1}GG=FG^2$, continuing like this we get

$$F_n=F G^{n-1}$$

First of all I wonder if what I have done is correct or is there something missing or incorrect?

Next I wrote a code in mathematica as follows to implement this for $n=3$. I wanted it for all $n$ but it didnt work. Here is the code:

opts = {Method -> {Automatic, "SymbolicProcessing" -> None},AccuracyGoal -> 8}
a = 2;
b = -2;
f1[x_] := Evaluate@PDF[NormalDistribution[2, 2], x]
g1[x_] := f1[x]*(UnitStep[x - b]*UnitStep[-x + a])
ff1[u_] = FourierTransform[f1[x], x, u, FourierParameters -> {1, 1}]
gg1[u_] = FourierTransform[g1[x], x, u, FourierParameters -> {1, 1}]
den[x_?NumericQ] := NInverseFourierTransform[ff1[u]*gg1[u]^2, u, x,FourierParameters -> {1, 1}, Evaluate@opts]
NIntegrate[den[x], {x, -8, b}, Evaluate@opts]
0.00463943 - 1.7541*10^-18 I

The result should however be $0.00397888$. For $n=2$ namely when

den[x_?NumericQ] := NInverseFourierTransform[ff1[u]*gg1[u]^1, u, x,FourierParameters -> {1, 1}, Evaluate@opts]
NIntegrate[den[x], {x, -8, b}, Evaluate@opts]
0.0105702 + 9.00034*10^-18 I

I get the correct result..

I am really confused. Can anybody see what is the problem here?

Thank you very much in advance.

  • $\begingroup$ How is this question different from your previous - and what is wrong with those answers? mathematica.stackexchange.com/q/33790/1783 $\endgroup$ – bill s Jun 22 '14 at 15:53
  • $\begingroup$ @bill once again the problem is not taking the fourier transform. The problem is that the true results that i get via convolution do not coincide with the results that I get via the recursion at the Fourier domain and I dont know the reason... $\endgroup$ – Seyhmus Güngören Jun 22 '14 at 16:35
  • $\begingroup$ In the code above you have not defined ff1 or gg1 so it is not clear what you are trying to do. Why are you loading Needs[FourierSeries]? What's wrong with FourierTransform and InverseFourierTransform? And if you are going to do it numerically, then Fourier and InverseFourier should be the correct commands. $\endgroup$ – bill s Jun 22 '14 at 16:55
  • $\begingroup$ @bills thanks for the comment. I forgot anyhow ff1 and gg1. I've just edited and included them. FourierTransform is not okay because taking the integral of error function is not an analytic function therefore FourierTransform fails.. thats the reason why I used NFourierTransform. As long as I know Fourier was for discrete data, that is the reason why I chose NFourierTransform: $\endgroup$ – Seyhmus Güngören Jun 22 '14 at 17:00
  • $\begingroup$ Do you have a good reason for writing forms containing ... := Evaluate @ ...? In general, such forms produce slow-running code. Unless you have said good reason, replace := witth =. $\endgroup$ – m_goldberg Jun 23 '14 at 7:42

Your Answer

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

Browse other questions tagged or ask your own question.