I'm working on a problem which asks to write the error function $$ \text{erf}(x) = \frac{1}{\sqrt{2\pi}} \int_0^x e^{-t^2/2} dt $$ as a power series -- i.e., a series in the form $$ \text{erf}(x) = \sum_{k=0}^\infty a_k x^k. $$ As a first step, I know I can use the Taylor expansion of $e^x$ to rewrite $\text{erf}(x)$ as $$ \text{erf}(x) = \frac{1}{\sqrt{2\pi}} \int_0^x \sum_{k=0}^\infty \frac{(-t^2/2)^k}{k!}dt. $$ And since the sum converges uniformly on the range $(-r,r)$ for $r \in \mathbb{R}$, we can swap the integral and summation so that $$ \text{erf}(x) = \frac{1}{\sqrt{2\pi}} \sum_{k=0}^\infty \int_0^x \frac{(-t^2/2)^k}{k!}dt $$
However, I am having trouble integrating the terms $$ \int_0^x \frac{(-t^2/2)^k}{k!}dt $$
Does integration here proceed using substitution? Thanks
$$\int_0^x\frac{(-t^2/2)^k}{k!}dt=\int_0^x\frac{(-1/2)^k}{k!}t^{2k}dt=\frac{(-1/2)^k}{k!(2k+1)}x^{2k+1}.$$