Given the following equation $$EPE(f) = E_{X}E_{Y|X}([Y-f(X)]^{2}|X)$$
We can model the function $f(X)$ to generate an arbitrary value $c$ and then minimize $EPE(f)$ pointwise by solving for the value of $c$. By writing the equation for this, we get, $$f(x)=argmin_{c}E_{Y|X}([Y-c]^{2}|X=x)$$
Now, the authors of The Elements of Statistical Learning indicate that the solution for the equation above is $$f(x) = E(Y|X=x)$$
Can someone explain to me through a mathematical derivation how the authors arrived at this solution?
We have $$E((Y - c)^2 | X = x) = E(Y^2 | X = x) - 2c E(Y | X= x) + c^2$$ using linearity of expectation. Taking the derivative with respect to $c$ gives $$-2E(Y | X=x) + 2c$$ Set the above equal to $0$ and solve for $c$. Since the second derivative is positive, this value of $c$ is the minimizer.