On a minimization problem involving the expectation of the logarithm of a normal random variable. Let $X$ be a random variable distributed as a normal with variance $\theta \sigma^2$ I would like to show (I don't know if it's true) that
$$E \left[ \frac{1}{2} \ln\beta X^2 - \frac{1}{2} \ln \theta \sigma^2 + \frac{1}{2 \beta} - \frac{X^2}{2 \theta \sigma^2}   \right]$$
is minimized (in the variable $\beta$) when $\beta = \theta$.
I tried differentiating under the integral (and obtained $\beta = 1$) but I am afraid I can't swap the derivative and the integral in this case since I can't find a function that dominates $\left|\frac{\partial}{\partial \beta} \ln\beta X^2 \right|$ for all $\beta$.
Maybe there is another route to do this and somebody can illuminate me.
 A: In this case, one should be able to make the following simplification
\begin{align}
\mathbb{E}_{x}\left[\frac{1}{2} \ln\left(\beta x^2\right) - \frac{1}{2} \ln \left(\theta \sigma^2\right) + \frac{1}{2\beta} - \frac{x^2}{2 \theta \sigma^2}\right] &= \mathbb{E}_{x}\left[\frac{1}{2} \ln\beta + \frac{1}{2\beta} + \frac{1}{2} \ln\left(\frac{x^2}{\theta \sigma^2}\right) - \frac{x^2}{2 \theta \sigma^2}\right] \\
&= \frac{1}{2} \left(\ln\beta + \frac{1}{\beta}\right) + \underbrace{\frac{1}{2}\mathbb{E}_{x}\left[\ln\left(\frac{x^2}{\theta \sigma^2}\right) - \frac{x^2}{ \theta \sigma^2}\right]}_{\text{Independent of $\beta$}}
\end{align}
Thus we can just solve the unconstrained optimization problem 
\begin{align}
\min_{\beta \in \mathbb{R}} \left(\ln\beta + \frac{1}{\beta}\right)
\end{align}
Define $\beta^*$ as the optimal value. Notice there is no required dependence on $\theta$ in the above objective, so your hypothesis that $\beta^* = \theta$ should not be right. Going off of above, we then have that $\nabla_{\beta}\left(\ln\beta + \frac{1}{\beta}\right) = \frac{1}{\beta} - \frac{1}{\beta^2} = \frac{1}{\beta}\left(1 - \frac{1}{\beta}\right)$. Setting this equal to zero, and assuming the optimal value $\beta^* \neq 0$, we can find that
\begin{align}
0 &= \frac{1}{\beta}\left(1 - \frac{1}{\beta}\right) \\
\implies 0&= \beta - 1 \\
\implies \beta &= 1
\end{align}
Thus, we arrive at the solution you also got of $\beta = 1$ but in this case, it should be clear that this result is fine since the derivatives were not taken over any integral quantities.
