Integration by parts: Am I doing this right? So I'm working through the problems in this book. While I'm not at school, I can totally see how this might be someones homework, so if I have made any egregious errors in anything outside of the specific question, be a sport and don't blurt it out.
I should stress, I haven't taken a calculus course in (>10) years, and even when I did, I only passed by the thinnest of margins. Possibly a rounding error on the school system.
Anyway, I dug up my old books, and am using integration by parts to evaluate this equation
$$
\left<x^2\right> = \sqrt{\frac{\lambda}{\pi}} \int_{-\infty}^{+\infty}{x^2 e^{-\lambda(x-a)^2}}dx.
$$
I start by dusting of my calculus textbook, turn to page 316 to find this helpful integration rule/strategy:
$$\int{U(x)\frac{dV}{dx}}dx = U(x)V(x) - \int{V(x)\frac{dU}{dx}}dx.$$
I won't bore you with all the details, but after a little massaging I get the equation down looking like this:
$$
\left<x^2\right> = \sqrt{\frac{\lambda}{\pi}} \Big[
        \overbrace{x^2}^{U(x)} \cdot \overbrace{e^{-\lambda (x-a)^2}}^{V(x)} - 
          \int_{-\infty}^{+\infty}{
            \overbrace{e^{-\lambda (x-a)^2}}^{V(x)} \cdot 
            \overbrace{e^{-\lambda (x-a)^2} \cdot -2\lambda (x-a)}^{\frac{dV}{dx}}
           }dx
\Big].
$$
(Let's just ignore any errors I may have made in applying the chain rule or using a poor substitution strategy or anything of that nature)
Now I was surprised to find the integral on the right hand side is actually not so hard to evaluate (it only took me a week of bugging the chat room to nut out). But now I am left scratching my head about how I evaluate the functions on the left, namely $U(x)$ and $V(x)$.
But then I realized, typing up this post, the rule is for an indefinite integral, I am evaluating a definite integral. So I just need to evaluate the functions at the endpoints, ie what is missing is:
$$
\left<x^2\right> = \sqrt{\frac{\lambda}{\pi}} \Big[
        {x^2} \cdot e^{-\lambda (x-a)^2} - 
          \int_{-\infty}^{+\infty}{
            {e^{-\lambda (x-a)^2}}\cdot 
            e^{-\lambda (x-a)^2} \cdot -2\lambda (x-a)
           }dx
\Big] \Big|_{-\infty}^{+\infty}
$$
Am I on the right track there?
Edit:
From @David K's comment I think what I meant was. I'm not really familiar with typing out an integral mid-evaluation.:
$$
\left<x^2\right> = \sqrt{\frac{\lambda}{\pi}} \Big[
        \big({x^2} \cdot e^{-\lambda (x-a)^2}\big)\ \Big|_{-\infty}^{+\infty} - 
          (-2\lambda) \int_{-\infty}^{+\infty}{
            (x-a) e^{\lambda^2 (x-a)^4}
           }dx
\Big]
$$
 A: The general rule for integration by part is understood more easily as follows. For two functions $u$ and $v$, consider there derivatives $u'$ and $v'$ and a range of integration between $a$ and $b$ both finite. Then:
$$\int\limits_{a}^b u'(x) v(x) dx = u(b)v(b) - u(a)v(a) - \int\limits_{a}^b u(x)v'(x) dx$$
Now for $a$ and/or $b$ infinite, take a limit. This should be enough to set you on the right tracks.
A: A nice thing that you have as well is:
$$\int V\frac{dV}{dx}dx=\int VdV=\frac{V^2}{2}+C$$
A: In the line that reads
$$
<x^2> = \sqrt{\frac{\lambda}{\pi}} \Big[
        \overbrace{x^2}^{U(x)} \cdot \overbrace{e^{-\lambda (x-a)^2}}^{V(x)} - 
          \int_{-\infty}^{+\infty}{
            \overbrace{e^{-\lambda (x-a)^2}}^{V(x)} \cdot 
            \overbrace{e^{-\lambda (x-a)^2} \cdot -2\lambda (x-a)}^{\frac{dV}{dx}}
           }dx
\Big]
$$
The integral is supposed to be $\int_{-\infty}^{+\infty}V(x)\frac{\mathrm{d}U}{\mathrm{d}x}\,\mathrm{d}x$, not $\int_{-\infty}^{+\infty}V(x)\frac{\mathrm{d}V}{\mathrm{d}x}\,\mathrm{d}x$

This integral is simplified a whole lot using $y=x-a$, giving
$$
\sqrt{\frac\lambda\pi}\int_{-\infty}^{+\infty}(y+a)^2e^{-\lambda y^2}\,\mathrm{d}y
$$
Expanding $(y+a)^2=y^2+2ay+a^2$ gives a sum of three integrals, one of which is
$$
\sqrt{\frac\lambda\pi}\int_{-\infty}^{+\infty}y^2e^{-\lambda y^2}\,\mathrm{d}y
$$
where you can use Integration by parts with $U(y)=-\frac{y}{2\lambda}$ and $V(y)=e^{-\lambda y^2}$. This gives $\frac{\mathrm{d}V}{\mathrm{d}y}=-2\lambda y\,e^{-\lambda y^2}$. Furthermore,
$$
\sqrt{\frac\lambda\pi}\int_{-\infty}^{+\infty}U(y)\,\frac{\mathrm{d}V}{\mathrm{d}y}\,\mathrm{d}y=\sqrt{\frac\lambda\pi}\int_{-\infty}^{+\infty}y^2e^{-\lambda y^2}\,\mathrm{d}y
$$
One of the other two integrands is odd, and the final one is kind of well-known.
