Q:

Value of a that Minimizes $\mathbb{E}([aX-\frac{1}{a}]^2)$

Suppose X is a random variable with mean $\mu$ and variance
  $\sigma^{2}$. 
For what value of a, where a > 0, is $\mathbb{E}([aX-\frac{1}{a}]^2)$
  minimized?

A:

Hint:
$$
\mathrm{E}[(aX-\tfrac1a)^2]=a^2(\sigma^2+\mu^2)+\tfrac{1}{a^2}-2\mu.
$$
Now minimize this function with respect to $a$.

A:

Without thinking too much - brute force method:
$$g(a) \triangleq E\left[\left(aX - \frac {1} {a}\right)^2\right] 
= a^2E[X^2] - 2E[X] + \frac {1} {a^2} = (\sigma^2+\mu^2)a^2 - 2\mu + \frac {1} {a^2} $$
Differentiating with respect to $a$, we have
$$ \frac {\partial g(a)} {\partial a} = 2(\sigma^2+\mu^2)a - \frac {2} {a^3}
= \frac {2} {a^3}[(\sigma^2 + \mu^2)a^4 - 1]$$
Note
$$ (\sigma^2 + \mu^2)a^4 - 1 
\begin{cases} 
> 0 & \text{if} & 
\displaystyle a < -\frac {1} {(\sigma^2 + \mu^2)^{1/4}}  \\
= 0 & \text{if} & 
\displaystyle a = -\frac {1} {(\sigma^2 + \mu^2)^{1/4}}  \\
< 0 & \text{if} & 
\displaystyle -\frac {1} {(\sigma^2 + \mu^2)^{1/4}} < a <
\frac {1} {(\sigma^2 + \mu^2)^{1/4}}   \\
= 0 & \text{if} & 
\displaystyle a = \frac {1} {(\sigma^2 + \mu^2)^{1/4}}  \\
> 0 & \text{if} & 
\displaystyle a > \frac {1} {(\sigma^2 + \mu^2)^{1/4}}  \\
\end{cases}$$
Therefore
$$\frac {\partial g(a)} {\partial a} 
\begin{cases} 
< 0 & \text{if} & 
\displaystyle a < -\frac {1} {(\sigma^2 + \mu^2)^{1/4}}  \\
= 0 & \text{if} & 
\displaystyle a = -\frac {1} {(\sigma^2 + \mu^2)^{1/4}}  \\
> 0 & \text{if} & 
\displaystyle -\frac {1} {(\sigma^2 + \mu^2)^{1/4}} < a < 0 \\
< 0 & \text{if} & 
\displaystyle 0 < a < \frac {1} {(\sigma^2 + \mu^2)^{1/4}}\\
= 0 & \text{if} & 
\displaystyle a = \frac {1} {(\sigma^2 + \mu^2)^{1/4}}  \\
> 0 & \text{if} & 
\displaystyle a > \frac {1} {(\sigma^2 + \mu^2)^{1/4}}  \\
\end{cases}$$
So $g$ has two local minima at $\displaystyle\pm \frac {1} {(\sigma^2 + \mu^2)^{1/4}}$, and you can check they are both the global minima. Since you restrict $a > 0$ (just seen it), you take the positive one.

