I'm trying to integrate a function that involves a finite sum:
$$\int_{-\infty}^{\infty}\sum_{j=1}^n (e^{-b t^2}r_j) \,dt$$
I think it should be possible to take the exponent outside the sum:
$$\int_{-\infty}^{\infty}\left(e^{-b t^2} \sum_{j=1}^n r_j \right)dt=\sum_{j=1}^n r_j \times \int_{-\infty}^{\infty}e^{-b t^2} dt$$
I write it in Mathematica like this:
$Assumptions=_\[Element]Reals
Assuming[
b>0,
Integrate[Sum[Exp[-b t^2]*r[j],{j,1,n}],{t,-\[Infinity],+\[Infinity]}]
]
This, however, simply returns the integral unchanged:
$$\int_{-\infty }^{\infty } \left(\sum _{j=1}^n e^{-b t^2} r(j)\right)\, dt$$
If I specify a number for $n$, I get the expected result:
$$\frac{\sqrt{\pi } (r(1)+r(2)+r(3)+r(4)+r(5))}{\sqrt{b}}$$
How do I extract $e^{-bt^2}$ outside the sum? Alternatively, how do I bring the integral inside the sum? More generally, how do I integrate this?
Sum[r[j], {j, 1, n}]*Integrate[Exp[-b t^2], {t, -\[Infinity], +\[Infinity]}]– Domen Jan 20 '22 at 16:36SimplifyandFullSimplifyalso can't bring a constant factor outside the sum:FullSimplify[Sum[a*Indexed[r, j], {j, 1, n}]]returns the sum ofa*r_j(as opposed. toatimes the sum ofr_j), but specifying a number instead ofncorrectly producesa*(r_1+r_2+...)– ForceBru Jan 20 '22 at 16:45r[j]is finite. For example, if you replacer[j]with justjthen it works.ClearAll[b,n,j,r,t]; f[t_]:=Sum[Exp[-b t^2]*j,{j,1,n}]; Assuming[Element[b,Reals]&&b>0,Integrate[f[t],t]]and gives(n*(1 + n)*Sqrt[Pi]*Erf[Sqrt[b]*t])/(4*Sqrt[b])... – Nasser Jan 20 '22 at 17:42finiteorr[j]is finite, then may be there will be a better chance to have it work. – Nasser Jan 20 '22 at 17:43Indexed[r, j] > 0 && Indexed[r, j] < 1to both the sum and the integral, but this didn't change anything. I also tried addingn > 0 && n < 6to these assumptions to indicate that the sum is finite, but this didn't help either... – ForceBru Jan 20 '22 at 17:58