Suppose I have a function $f$ which appears in some complicated formula in a term that looks like $\int_{-\infty}^{\infty} f(x, v)\,\text{d}v$. Basically, I want to write $f$ in a series of functions so I can get rid of the integral. I want the "$x$ part" to be in terms of $\mathcal{P}_{\ell}\big(\tanh(x))$ where $\mathcal{P}_{\ell}$ is a Legendre polynomial. The "$v$ part" is a lot tricker for me. First I thought I would just write something like $$ f(x, v) = \sum_{\ell = 0}^{\infty}\mathcal{P}_{\ell}\big(\tanh(x)\big) \sum_{n=0}^{\infty}A_{\ell n} v^n, $$
where $A_{\ell n}$ is some matrix of coefficient to be determined. The issue with this is that obviously you can't just integrate term by term since none of them even converge. My next idea was to just somewhat arbitrarily factor out a Gaussian term and write
$$ f(x, v) = \sum_{\ell = 0}^{\infty}\mathcal{P}_{\ell}\big(\tanh(x)\big) \sum_{n=0}^{\infty}A_{\ell n} e^{-v^2}v^n. $$
Can you just do that? Now it looks like I can just integrate term-by-term since each one doesn't just blatantly diverge. Also, this is for a numerical application, in practice I would actually be truncating the series at $\ell_{\text{max}}$ and $n_{\text{max}}$ so I guess I want to know if this looks like a valid way to try to approxiamate a function plus the issue of wanting to get rid of that infinite integral.