A problem about the convergence of an improper integral Let $f:\mathbb R\longrightarrow\mathbb R$ be a function with 
$$f(x)=\frac{1}{3}\int_x^{x+3} e^{-t^2}dt$$
and consider  $g(x)=x^nf(x)$ where $n\in\mathbb Z$. 

I have to discuss the convergence of the integral 
  $$\int_{-\infty}^{+\infty}g(x)dx$$ at the varying of $n\in\mathbb Z$.

Any idea? We have an integral of an "integral function", and I'm a bit confused!
Thanks in advance.

Basically, you are considering the integral
$$ I := \frac{1}{3}\int_{-\infty}^{\infty}x^n f(x) dx= \frac{1}{3}\int_{-\infty}^{\infty}x^n \int_{x}^{x+3}e^{-t^2}dt \,dx.$$ 
Changing the order of integration yields
$$ I = \frac{1}{3}\int_{-\infty}^{\infty}e^{-t^2} \int_{t-3}^{t}x^ndx \,dt $$
$$ = \frac{1}{3}\int_{-\infty}^{\infty}e^{-t^2}\left(\frac{t^{n+1}-(t-3)^{n+1}}{n+1} \right) \,dt $$
$$ = \frac{1}{3(n+1)}\int_{-\infty}^{\infty}t^{n+1} e^{-t^2} dt - \frac{1}{3(n+1)}\int_{-\infty}^{\infty}(t-3)^{n+1} e^{-t^2} dt dt $$

$$\implies I = \frac{1}{3(n+1)} I_1 + \frac{1}{3(n+1)} I_2. $$

Now, note this, for $n\in \mathbb{N} \cup \left\{ 0\right\}$, $I_1$ is convergent (see the analysis for the case $I_2$ at the end of the answer) and can be evaluated in terms of the gamma function as

$$ I_1 = \frac{1}{2}\, \left( 1+ \left( -1 \right)^{n+1} \right) \Gamma  \left( \frac{n}{2}
+1 \right).$$

Examining the convergence of $I_2$ $n\in \mathbb{N} \cup \left\{ 0\right\}$, we have
$$ I_2 = \int_{-\infty}^{\infty}(t-3)^{n+1} e^{-t^2} dt = \int_{-\infty}^{\infty}y^{n+1} e^{-(y+3)^2} dy $$
$$ = (-1)^n \int_{0}^{\infty}y^{n+1} e^{-(y-3)^2} dy + \int_{0}^{\infty}y^{n+1} e^{-(y+3)^2} dy $$
$$ I_2 = I_{21} + I_{22}. $$
Now, both of the integrals $I_{21}$ and $I_{22}$ converge, since

$$ y^{n+1}e^{-(y-3)^2} \leq e^{y} e^{-(y-3)^2}, \quad y^{n+1}e^{-(y+3)^2}\leq e^{y} e^{-(y+3)^2} $$ 

and 

$$ \int_{0}^{\infty} e^{y} e^{-(y-3)^2}dy <\infty,\quad  \int_{0}^{\infty} e^{y} e^{-(y+3)^2}dy <\infty. $$

You can check Gaussian Integrals for the last two inequalities.
Note: For the case $n$ is negative integer, we have

1) If $n=-1$, then $I_1$ and $I_2$ converge.
2) If $n$ is a negative even integer, then $I_1$ and $I_2$ are undefined.
3) If $n$ is a negative odd integer, then $I_1$ and $I_2$ diverges to infinity. 

