How do I show that the mean of the posterior density minimizes this squared error loss function? This exercise comes from Koop's Bayesian Econometrics. Given $\theta$, the parameter(s) of a model (in this case $\theta$ is a scalar), $\tilde{\theta}$, the point estimate of $\theta$, and constants $c_1 > 0, c_2 > 0$, the goal of the exercise is to show that $\tilde{\theta} = E[\theta \mid y]$ minimizes the expected loss of the squared error function $C(\tilde{\theta}, \theta) = (\tilde{\theta} - \theta)^2$, where, to quote the book, "the expectation is taken with respect to the posterior of $\theta$", i.e. $\theta \mid y$.

Per this meta question, I'm including my solution as a separate answer, both for feedback on that solution and for other people to post their own solutions.
 A: This is my solution:
\begin{align}
\cfrac{\partial}{\partial \tilde{\theta}} E_{\theta \mid y} \left[ C(\tilde{\theta}, \theta) \mid y\right]
&= \cfrac{\partial}{\partial \tilde{\theta}} E_{\theta \mid y} \left[ (\tilde{\theta} - \theta)^2 \mid y\right] \\
&= \cfrac{\partial}{\partial \tilde{\theta}} E_{\theta \mid y}  \left[ (\tilde{\theta}^2 - 2 \tilde{\theta} \theta + \theta^2 ) \mid y\right] \\
&= \cfrac{\partial}{\partial \tilde{\theta}} \left (E_{\theta \mid y}  \left[ \tilde{\theta}^2 \mid y \right] - 2 \tilde{\theta} E_{\theta \mid y} \left[ \theta \mid y \right] + E_{\theta \mid y} \left[ \theta^2 \mid y \right] \right) \\
&= \cfrac{\partial}{\partial \tilde{\theta}} \left( \tilde{\theta}^2 - 2 \tilde{\theta} E_{\theta \mid y} \left[ \theta \mid y \right] + E_{\theta \mid y} \left[ \theta^2 \mid y \right] \right) \\
&= 2 \tilde{\theta} - 2 E_{\theta \mid y} \left[ \theta \mid y \right]
\end{align}
Setting this equal to zero gives the critical value $\tilde{\theta} = E_{\theta \mid y} \left[ \theta \mid y \right]$. Since
\begin{equation}
\frac{\partial^2}{\partial^2 \tilde{\theta}} E_{\theta \mid y} \left[ C(\tilde{\theta}, \theta) \mid y\right]
= \frac{\partial}{\partial \tilde{\theta}} \left( 2 \tilde{\theta} - 2 E_{\theta \mid y} \left[ \theta \mid y \right] \right)
= 2
> 0
\end{equation}
this critical value is a minimum. Feedback on this solution, and other solutions, are welcome.
