Solving argmin $E[(Y-c)^2 | X]$ [duplicate]

This question already has an answer here:

While reading a book on statistics, I encountered the following:

$$f(x) = \mathop{\text{argmin}}\limits_c E_{Y|X}([Y-c^2]|X=x)\tag{1}$$ which somehow equates to $$f(x) = E(Y|X=x)\tag{2}$$ How do we get from result $$(1)$$ to $$(2)$$?

marked as duplicate by Dilip Sarwate, user158565, kjetil b halvorsen, jpmuc, gung♦Aug 2 at 14:08

Simply differentiate $$f$$ with respect to $$c$$ (your square operation must be outside the differencing): \begin{align}\frac{\partial f}{\partial c}&=\frac{\partial}{\partial c}\left(E[(Y-c)^2|X=x]\right)\\&=\frac{\partial}{\partial c}\left(E[Y^2|X=x]-2cE[Y|X=x]+c^2\right)\\&=-2E[Y|X=x]+2c=0\end{align} which yields $$c=E[Y|X=x]$$. This $$c$$ minimizes $$f$$, because the second derivative is greater than $$0$$. Also, it's obvious that $$f$$ is a parabola with respect to $$c$$, and $$E[Y|X=x]$$ is the bottom of it.
Say your proba $$\mathbb{P}(.|X=x)$$ is just a another proba $$\mathbb{Q}$$, then you know
$$argmin_c \mathbb{E}_{\mathbb{Q}}[Y-c]^2$$ is $$\mathbb{E}_{\mathbb{Q}}[Y]$$. It comes from the fact that you can find the minimum of a polynomial equation. Since $$\partial_c\mathbb{E}_{\mathbb{Q}}[Y-c]^2=-2\mathbb{E}_{\mathbb{Q}}[Y-c]$$. Or by any other way.
Now since your conditional proba is a normal proba the result follow if you replace $$\mathbb{Q}$$.