# Nested integration

I wish to perform the following nested integral: \begin{align} I_n=\int_{-\infty}^\infty dx_n~f(x_n,x_{n+1})\int_{-\infty}^\infty dx_{n-1}~f(x_{n-1},x_n)...\int_{-\infty}^\infty dx_1~f(x_1,x_2)\int_{-\infty}^\infty dx_0~f(x_0,x_1) \end{align} where $f$ is a known function. While this is easily done using Do loop (or something similar), I wished to make it more elegant using Nest and the function f[x,y]. But after several failed attempts I am beginning to wonder if this can be done at all. Any help in this regard is much appreciated.

You don't really need Nest[] for this. Taking into account Mathematica's convention that the outermost integral corresponds to the first iterator in Integrate[], we have

With[{n = 5},
Integrate[Product[f[Subscript[x, k], Subscript[x, k + 1]], {k, 0, n}],
Sequence @@ Table[{Subscript[x, k], -∞, ∞}, {k, n, 0, -1}]]]


$$\scriptsize {\int _{-\infty }^{\infty }\int _{-\infty }^{\infty }\int _{-\infty }^{\infty }\int _{-\infty }^{\infty }\int _{-\infty }^{\infty }\int _{-\infty }^{\infty }f\left(x_0,x_1\right) f\left(x_1,x_2\right) f\left(x_2,x_3\right) f\left(x_3,x_4\right) f\left(x_4,x_5\right) f\left(x_5,x_6\right)dx_0dx_1dx_2dx_3dx_4dx_5}$$

• Oh, if this is the case, then I misinterpreted the formula and my answer is wrong. – halirutan Aug 27 '17 at 7:18
• Well, in "physicist's format", they usually put the integral and differential first before the function, so I interpreted it in that way, and (say) $x_1$ in both $f(x_0,x_1)$ and $f(x_1,x_2)$ should be scoped by the differential $\mathrm dx_1$. At least, that was my interpretation, and we should wait for the OP to clarify. – J. M. will be back soon Aug 27 '17 at 7:20
• Yes, I know about the physical convention. Let's see. – halirutan Aug 27 '17 at 7:23
• @J.M. The rightmost integral is $g_1(x_1)\equiv\int_{-\infty}^\infty dx_0 ~f(x_0,x_1)$. This gets fed into the next integral to obtain $g_2(x_2)\equiv\int_{-\infty}^\infty dx_1 ~f(x_1,x_2)g_1(x_1)$, and so on. Does the structure of integral in your answer actually achieve this effect? Even then I would like to have a format in which I can compute $I_{k+1}$ given $I_k$ using $I_{k+1}\equiv\int_{-\infty}^\infty dx_n~f(x_{k+1},x_{k+2})I_k$, while outputting each $I_k$. – Deep Aug 27 '17 at 8:38
• You don't have to take my word for it, @Deep; test the method yourself (just change the value of n) and you'll see that it evaluates exactly as you wanted it. I'll think about your recursive version, tho, but if you're impatient, you might get a few ideas from here. – J. M. will be back soon Aug 27 '17 at 11:06