expectation in probablity. Problem:For any random variable $X$ having the mean $\mu$ and finite second moment show that $E((X-\mu)^2) \leq E((X-c)^2)$,$\forall c\in R$
I tried to solve using following steps:
assuming given equation is correct
$E(X^2+\mu^2-2X\mu)\leq E(X^2+c^2-2Xc)$
$E(\mu^2-2X\mu)\leq E(c^2-2Xc)$
$E(\mu^2)-2\mu E(X)\leq E(c^2)-2cE(X)$
$\mu^2-2\mu E(X)\leq c^2-2cE(X)$
$2\mu(c-\mu) \leq c^2-\mu^2$
$2\mu \leq c+\mu$
now I can choose $c < \mu$ and my inequality become incorrect.What is wrong in solution. 
 A: The mistake is in the second last line where the inequality is divided across by $c-\mu$. Implicit in this is $c>\mu$, otherwise the inequality would need to be reversed. Instead, it should be continued as follows: $2 \mu c - 2 \mu^2 \le c^2 - \mu^2$, which becomes $0 \le (c-\mu)^2$, which is always true. When you reverse this line of reasoning, you get the desired result.
However, I think the following route is more illuminating:
Let $\phi(c) = E(x-c)^2$. Then $\phi(c) = E (x^2-2cx + c^2) = E x^2 -2 c Ex +c^2$. This is a strictly convex quadratic in $c$, minimizing gives $2c=2 Ex$, or $c = Ex$. Hence we have $\phi(Ex) \le \phi(c)$ for all $c$.
A: In the calculation, $c-\mu$ was cancelled for no good reason. Cancellation is almost a reasonable move when we are solving an equation (though there is the risk of losing a root).  But cancellation is dangerous when we are working with an inequality, since division by a negative quantity reverses the direction of an inequality.
One approach to the problem is to calculate 
$$E(X-c)^2-E(X-\mu)^2.$$
Using calculations very much like those that you did, we find that
$$E(X-c)^2 -E(X-\mu)^2=-2\mu c+c^2+\mu^2=(c-\mu)^2.$$
Since a square is never negative, we conclude that 
$$E(X-c)^2 -E(X-\mu)^2 \ge 0,$$ 
which implies that
$$E(X-c)^2 \ge E(X-\mu)^2.$$
A: Well, let's call $\sigma^2=E(X^2)$ - the second moment.
Then you have:
$$E(X^2+\mu^2-2X\mu)\leq E(X^2+c^2-2Xc)$$
Open the brackets:
$$E(X^2)+E(\mu^2)-E(2X\mu)\leq E(X^2)+E(c^2)-E(2Xc)$$
Use definitions:
$$\sigma^2+\mu^2-2\mu E(X)\leq \sigma^2+c^2-2E(X)c$$
Simplify (cancelling out some terms):
$$\sigma^2-\mu^2\leq \sigma^2+c^2-2\mu c$$
$$0\leq \mu^2+c^2-2\mu c$$
Collect the rest:
$$0\leq (\mu-c)^2$$
which is true for all $c$
