Let $X:\Omega\rightarrow\mathbb{R}$ be a random variable such that $\mathbf{E}(X), \mathbf{var}(X)$ exist.
a) Consider a function $f:\mathbb{R}\rightarrow\mathbb{R}$ defined: $$ f(t)=\mathbf{E}(X-t)^2 \quad \text{ for } t\in \mathbb{R}$$
Show that the minimum of $f$ on $\mathbb{R}$ is attained at $t=\mathbf{E}(X).$
b) Suppose that $a \leq X(\omega)\leq b $ for some $a,b \in \mathbb{R}$ and all $\omega \in \Omega$. Deduce from part a) that $$\mathbf{var}(X) \leq \frac{(b-a)^2}{4}. $$
Attempt at a) We know that $$\begin{align} \mathbf{E}(X-t)^2=&\mathbf{E}(X^2-2tX+t^2) \\ =&\mathbf{E}(X^2)-2t\mathbf{E}(X)+t^2 \end{align}$$ To find a minimum we take a derivative with respect to $t$ and set it equal to zero: $$\begin{align} -2\mathbf{E}(X)+2t \\ \mathbf{E}(X)=t \end{align} $$ To make sure it is indeed a minimum we take a second derivative with respect to $t$: $$2>0 $$ Which indeed tells us that $t=\mathbf{E}(X)$ is a minimum.
for Part b) Should I be doing something with a uniform distribution here?
Let $Y=X-\frac {a+b} 2$. Then $-\frac {b-a} 2 \leq Y \leq \frac {b-a} 2$ so $EY^{2} \leq (\frac {b-a} 2)^{2}$ Now just put $t=\frac {a+b} 2$ in a) to get b). [ When $t=EX$, $E(X-t)^{2}$ is nothing but variance of $X$].