Solve $P=\frac{1}{\alpha}\log\int_{0}^{\infty}\sqrt{\frac{2}{\pi}}e^{\alpha x}e^{-x^2/2}dx$ numerically Let $P=\frac{1}{\alpha}\log \mathbb E[e^{\alpha X}]$ and $X\sim f(x)=\sqrt{\frac{2}{\pi}}e^{-x^2/2},x>0$
I'm asked to calculate $P$ numerically (and plot it). How can I calculate this numerically? Do I need some sort of approximation? If so, which one do I take?
We have $$P=\frac{1}{\alpha}\log\int_{0}^{\infty}\sqrt{\frac{2}{\pi}}e^{\alpha x}e^{-x^2/2}dx$$
The integrand is equal to $$e^{\alpha^2/2}\Bigg(\operatorname{erf}\bigg(\frac{a}{\sqrt 2}\bigg)+1\Bigg)$$
 A: $$P(\alpha)=\frac{1}{\alpha}\,\log  \int_0^{\infty } \sqrt{\frac{2}{\pi }} e^{-\frac{x^2}{2}} e^{\alpha x} \, dx$$
Integrating we get
$$P(\alpha)=\frac{1}{\alpha}\,\log \left(e^{\frac{\alpha ^2}{2}} \left(\text{erf}\left(\frac{\alpha }{\sqrt{2}}\right)+1\right)\right)=\\= \frac{1}{\alpha}\cdot \frac{\alpha ^2}{2}+\frac{1}{\alpha}\,\log \left(\text{erf}\left(\frac{\alpha }{\sqrt{2}}\right)+1\right)=\\=
\frac{\alpha}{2}+\frac{1}{\alpha}\,\log \left(\text{erf}\left(\frac{\alpha }{\sqrt{2}}\right)+1\right)$$
At $\alpha=0$ the function is not defined, but we have
$$\underset{\alpha \to 0}{\text{lim}}\left(\frac{\alpha }{2}+\frac{\log \left(\text{erf}\left(\frac{\alpha }{\sqrt{2}}\right)+1\right)}{\alpha }\right)=\sqrt{\frac{2}{\pi }}$$
$$
\begin{array}{rl}
 \alpha  & P(\alpha ) \\
\hline
 -8 & 0.292363 \\
 -7 & 0.313023 \\
 -6 & 0.340604 \\
 -5 & 0.37437 \\
 -4 & 0.416739 \\
 -3 & 0.471526 \\
 -2 & 0.545019 \\
 -1 & 0.647874 \\
  0 & 0.797885 \\
 1 & 1.02039 \\
 2 & 1.33507 \\
 3 & 1.7306 \\
 4 & 2.17328 \\
 5 & 2.63863 \\
 6 & 3.11552 \\
 7 & 3.59902 \\
 8 & 4.08664 \\
 9 & 4.57702 \\
 10 & 5.06931 \\
\end{array}
$$
$$...$$

